-
|
Hi, I'm trying to understand, how I can combat, a slow first request, to a SvelteKit app. I'm currently working on a project, using SvelteKit, and I've noticed that the CPU utilization for the first request, is noticeably higher, than subsequent requests, and this increases when more libraries are added to the project. In development, this is not that noticeable, as CPU resources are typically not that limited. But this becomes apparent when starting the app, in a container with limited resources. Maybe too limited, in my case, though. (Sidenote: I'm running this project in multiple containers, deployed in a Nomad cluster, where each instance is given 250MHz and 100Mb of memory.) I've made a bare bones example, over at https://github.com/jeppech/sveltekit-first-request, which illustrates my "issue". There's also a compose file, for building and running the app, in a container with restricted resources. In the repository, you'll see that by adding and using a function from the I'm aware that this only happens on every "cold-start" of the app, and is not a unique thing to SvelteKit. But I think the CPU utilization is still a bit on the higher side. So, my question... Is there anything I can do to optimize this initial load, when building the app? - I've scratched my head long enough, and I cannot come up with any solution, besides throwing more resources, at the instances I'm running. I've tried upping the cpu limit to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
The first request will use server-side rendering by default, thus creating more work on the server. |
Beta Was this translation helpful? Give feedback.
The first request will use server-side rendering by default, thus creating more work on the server.
If your server is severely underpowered, it might make sense to disable SSR, so the rendering happens on the client. This has its own downsides, though usually one of the goals of SSR is to provide a faster first load, so if it goes against that, it might be worth considering.