We have a web app that has an area that displays user controls depending on if the user is authenticated or not. Authentication is done via JWT token. Stack: Vue/Nuxt, AWS ECS, Aurora.
So Node applications sit on a single CPU core. Unless you are not using clusters or not using PM2 with -i parameter. PM2 can automatically balance load between instances sitting on each CPU core. That’s fine. And of course our ECS tasks can be provided with CPU cores > 1.
My Senior Frontend and Fullstack developers couldn’t answer me with confidence if we CAN run Nuxt app in cluster mode using NITRO_PRESET=node_cluster env variable. Since Nuxt is stateful (it renders parts of HTML dependent on the user) I suppose it’s not possible. Because simple round robin balancing of PM2 will not work. And I’m not sure that NITRO_PRESET=node_cluster performs any balancing at all. Or gives a possibility to handle balancing.
The questions: is it possible to run Nuxt app in clustering mode without ruining the stateful nature of the Nuxt app? Or is there a way to make the app stateless using Vue/Nuxt stack?
I’m expecting usage of all CPU cores available by Nuxt app so that user experience won’t be ruined by session-lost issues.