I have problems with high server cpu and low number of requests in my app. In production, with 200 concurrent users, latency is almost 2 seconds.
I have tried clean nuxt 3 app with one plugin and there is the same problem. Within that plugin, i am fetching some jsonplaceholder data with promise.all.
I am testing load on production build, node cluster preset with 'wrk' (wrk -t4 -c100 -d30 http://localhost:3000/).
Here is what i have in my plugin. And this is the whole code. There are no other fetch calls.
export default defineNuxtPlugin(async nuxtApp => {
await Promise.all([$fetch('https://jsonplaceholder.typicode.com/posts'),
$fetch('https://jsonplaceholder.typicode.com/albums'),
$fetch('https://jsonplaceholder.typicode.com/users'),
$fetch('https://jsonplaceholder.typicode.com/users'),
$fetch('https://jsonplaceholder.typicode.com/comments')
]);
});
With each fetch, number of possible requests drops by large number. For example:
one request: 1148.60 req/sec two requests: 719.52 req/sec three requests: 408.80 req/sec etc.
If you add few components with fetch calls, app soon become unusable for production. Drops to 6 req/sec and with latency over 1 second. Event with caching enabled, there is the same problem.
This should not be normal. Is there any way to configure node for more concurrent connections, write different code, place it somewhere else... I would appreciate any help if someone had similar issues. Thanks