How is working the Nextjs server?
Unanswered
Giant Angora posted this in #help-forum
Giant AngoraOP
Lets say i have an application running in prod, and 100 clients access to the application, and this app have servers components. my server components interacts with an api, the question is?
due that node is a single thread how the next js server process all the request to interact with the api and serve the component to the client, for the clients accessing at the same time.
its a difference if i host the app in vercel or Google cloud. ?
is there a bottle neck in nextjs server, or does it use multiple instances ?
Thanks
15 Replies
Black and yellow mud dauber
@Giant Angora I'm not sure if that's the point of your question, but although Javascript is single-threaded, both Node and Browsers provide features outside of the engine that allow concurrency.
In case of Browsers, it's through Web APIs, in case of the former - libuv.
The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible. [...]Giant AngoraOP
i just wanted to know how nextjs server works handling several request at the time , and if vercel handle it automatically or i need to handle it manually using google cloud
it will be a serverless function if you host it on vercel
@Ray it will be a serverless function if you host it on vercel
Giant AngoraOP
ok but if i want to use kubernetes in google cloud provider. do i need to increase pod numbers to handle it?
yes
it is just a node server
Giant AngoraOP
i want to solve a performance problem, in gcp i have 1 nextjs app pod and 10 api pods, but i think nextjs server generating some servercomponents are causing a bottleneck to the app
client componets wont because the components are hitting api directly from browser
that will be hurt the performance if all the page are dynamic
Giant AngoraOP
what u suggest? increase pods for the app ? or move to vercel and let it do it automatically ?
you have a bottleneck of 1 frontend pod. add a hpa, set some sane limits. and see if it still feels slow when you arent trying to push a hotdog through a straw 😂