Serverless (Vercel) Prisma Cold Start Optimizations
Prisma's performance in serverless environment is a hot topic currently and I made this topic to collect best practices, optimizations and tips to use prisma's extremely great developer experience with vercel's blazingly fast serverless functions.
As I've previously seen it, cold start are around 2 seconds, while warm requests are handled in ~600ms in a very simple scenario.
I understand, high traffic sites don't face this issue as much as others, since they keep functions warm.
Switching to (or using them parallel) kysely or drizzle is not really an solution imho.
Going back to container based deployment is currently my go-to option if performance matters this much, but having leave Vercel's awesome features behind is a real pain.
I'd be happy to see your solutions & optimizations for this problem. thanks!
15 Replies
option 1: change to some serverless variants (edge)
option 2: change what is slow
option 3: keep the lambda warm (cron job)
3 seems the easier but next is deployed for multiple lambdas
would edge not work similarly to serverless in this case?
i mean how is it different?
edge is a "simpler" runtime
with much smaller coldstarts
but is very limited in native apis, like you can't use prisma on the edge runtime
so that way prisma data proxy would be required, right?
no, the data service is bad bad bad
then how do you work with prisma in edge env?
btw whats wrong with this?
Prisma
Data Proxy
Data Proxy in the Prisma Data Platform provides database connection management and pooling, load balancing, scaling, and fault tolerance features so that you can manage and scale database connections for applications that use Prisma ORM. With Data Proxy, your application can scale and maintain predictable database performance because it also lim...
maybe the json protocol can help that
the service idea itself isnt bad
the their implementation does not work most of the time
huh thats weird
With the Data Proxy and with a reduced bundle size, you achieve faster serverless cold starts.this sounds exactly what we are looking for 😄
if you can make their service work
i wish you the luck
the sad part about that prisma cloud is that there is no api documentation, actually not even a usable api, no tokens and pretty much anything that is necessary to work in a larger scale
i really miss a terraform provider but i feel like thats not happening
Switching to (or using them parallel) kysely or drizzle is not really an solution imho.Why? 😦
I love prisma's query builder, it feels very natural and easy to use. kysely also looks great, i (personally) don't like the builder's structure as much as I do prisma's
Using the experimental json protocol is definitely one
What do you think new applications should choose:
1. Use a not fully equipped library like drizzle ORM, taking a DX hit.
2. Use Prisma, by the time performance will matter the new speed improvements will be ready and will be sufficient.