feat: update benches to speed up nextjs servers

This commit is contained in:
Valerio Ageno
2024-08-17 15:00:43 +02:00
parent 0d33150f30
commit a497937106
5 changed files with 43 additions and 23 deletions
+17 -19
View File
@@ -38,48 +38,46 @@ to mock an heavy network load over the application server.
Running 30s test @ http://localhost:3000/ Running 30s test @ http://localhost:3000/
12 threads and 400 connections 12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev Thread Stats Avg Stdev Max +/- Stdev
Latency 69.13ms 149.25ms 1.81s 88.24% Latency 79.72ms 162.90ms 1.71s 87.70%
Req/Sec 11.52k 12.76k 36.27k 68.64% Req/Sec 11.50k 15.04k 42.40k 67.36%
4112347 requests in 30.06s, 3.03GB read 4111435 requests in 30.06s, 3.03GB read
Requests/sec: 136796.43 Requests/sec: 136788.14
Transfer/sec: 103.09MB Transfer/sec: 103.08MB
``` ```
``` ```
// NextJs pages router // NextJs pages router
> pnpm build > pnpm build
> pnpm start > pm2 start ./ecosystem.config.js
> wrk -t12 -c400 -d30s http://localhost:3000/ > wrk -t12 -c400 -d30s http://localhost:3000/
Running 30s test @ http://localhost:3000/ Running 30s test @ http://localhost:3000/
12 threads and 400 connections 12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev Thread Stats Avg Stdev Max +/- Stdev
Latency 179.44ms 80.47ms 1.99s 86.03% Latency 36.02ms 21.81ms 608.77ms 93.99%
Req/Sec 175.00 102.16 1.12k 76.97% Req/Sec 0.96k 183.53 3.38k 84.99%
48510 requests in 30.08s, 69.58MB read 344202 requests in 30.10s, 493.73MB read
Socket errors: connect 0, read 0, write 0, timeout 298 Requests/sec: 11434.43
Requests/sec: 1612.85 Transfer/sec: 16.40MB
Transfer/sec: 2.31MB
``` ```
``` ```
// NextJs app router // NextJs app router
> pnpm build > pnpm build
> pnpm start > pm2 start ./ecosystem.config.js
> wrk -t12 -c400 -d30s http://localhost:3000/ > wrk -t12 -c400 -d30s http://localhost:3000/
Running 30s test @ http://localhost:3000/ Running 30s test @ http://localhost:3000/
12 threads and 400 connections 12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev Thread Stats Avg Stdev Max +/- Stdev
Latency 577.15ms 122.46ms 1.99s 81.42% Latency 61.03ms 18.65ms 341.31ms 86.25%
Req/Sec 84.17 78.74 323.00 77.03% Req/Sec 547.55 96.59 1.16k 80.59%
19285 requests in 30.09s, 86.61MB read 195590 requests in 30.10s, 715.91MB read
Socket errors: connect 0, read 0, write 0, timeout 199 Requests/sec: 6498.62
Requests/sec: 640.90 Transfer/sec: 23.79MB
Transfer/sec: 2.88MB
``` ```
@@ -0,0 +1,10 @@
module.exports = {
apps: [
{
script: 'node_modules/next/dist/bin/next',
args: 'start',
instances: 'max',
exec_mode: 'cluster',
},
],
}
+6 -4
View File
@@ -1,10 +1,12 @@
export default async function Home(): Promise<JSX.Element> { export const dynamic = 'force-dynamic'
const { data } = await mockServerSideAPI()
return <h1>The random number is: {data}</h1>
}
const mockServerSideAPI = async (): Promise<{ data: number }> => { const mockServerSideAPI = async (): Promise<{ data: number }> => {
return { return {
data: Math.floor(Math.random() * 10), data: Math.floor(Math.random() * 10),
} }
} }
export default async function Home(): Promise<JSX.Element> {
const { data } = await mockServerSideAPI()
return <h1>The random number is: {data}</h1>
}
@@ -0,0 +1,10 @@
module.exports = {
apps: [
{
script: 'node_modules/next/dist/bin/next',
args: 'start',
instances: 'max',
exec_mode: 'cluster',
},
],
}