You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React SSR can be a pretty expensive blocking CPU operation for a node server, which is bad, because it blocks the whole main event loop for the process, interrupting any other work underway. We should add a mode to fastify-renderer that allows rendering in a background worker. It will still block that worker's event loop, but only that worker, leaving the main thread to do its thing.
I think the right level to do this at is just for the rendering, and not for the props gathering or any other bits of the request flow. The fastify route handler still needs access to the fastify plugins to gather the props for that page, and to do stuff like making database calls, caching, running authentication handlers, etc. So, I think the right point at which to do work in the background thread is after the props have been returned by the route hander, and before we start sending them into React land.
I imagine there will be some challenges getting vite to work ok in the background thread but I think it is worth investigating as the performance and stability of this is a big win.
The text was updated successfully, but these errors were encountered:
React SSR can be a pretty expensive blocking CPU operation for a node server, which is bad, because it blocks the whole main event loop for the process, interrupting any other work underway. We should add a mode to fastify-renderer that allows rendering in a background worker. It will still block that worker's event loop, but only that worker, leaving the main thread to do its thing.
I think the right level to do this at is just for the rendering, and not for the props gathering or any other bits of the request flow. The fastify route handler still needs access to the fastify plugins to gather the props for that page, and to do stuff like making database calls, caching, running authentication handlers, etc. So, I think the right point at which to do work in the background thread is after the props have been returned by the route hander, and before we start sending them into React land.
I imagine there will be some challenges getting vite to work ok in the background thread but I think it is worth investigating as the performance and stability of this is a big win.
The text was updated successfully, but these errors were encountered: