How to optimize imports on deno deploy?
I have a medium project (44 files) deployed on deno deploy, where works.
But, I'm getting inconsistent and sometimes very long cold start times in my deno project, like the attached image.
All my dependencies:
After some tests, I suspect there is a problem with Imports, because only to import a module with 5x files the deploy is having 2 secs, sometimes 4 secs.
I would like to know if this is normal and if not, How can i fix it?
6 Replies
This is other big cold start:
I'm not that familiar with deploy, but many npm packages tend to be huuuuuge. eg. drizzle here is 5mb of code, vine 2mb. it doesn't matter how many files your project is, if your npm deep dependencies are 100x-1000x that (i guess that's the nature of npm ecosystem) - not that surprising if cold starts are high. Libraries made specifically for deno tend to be much smaller. But again I'm not sure if there are ways to optimize that on deploy. Just my personal experience; it's best to bring from npm only what you absolutely need and can't find elsewhere.
Maybe you're right. I'll try do some lazy load for my handlers based in the route to see if I can get some result. Maybe it can help
Create a lazy loading system give better results. However after 24 hours, I get random and some times long long very cold start.
This problem its not 100% for all locations. For example the first request of the day for us-east-4 and europe in general is acceptable. The main problem is in the south america