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
Neto
Neto•2y ago
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
SGeri
SGeri•2y ago
would edge not work similarly to serverless in this case? i mean how is it different?
Neto
Neto•2y ago
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
SGeri
SGeri•2y ago
so that way prisma data proxy would be required, right?
Neto
Neto•2y ago
no, the data service is bad bad bad
SGeri
SGeri•2y ago
then how do you work with prisma in edge env? btw whats wrong with this?
SGeri
SGeri•2y ago
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...
Neto
Neto•2y ago
maybe the json protocol can help that the service idea itself isnt bad the their implementation does not work most of the time
SGeri
SGeri•2y ago
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 😄
Neto
Neto•2y ago
if you can make their service work i wish you the luck
SGeri
SGeri•2y ago
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
Igal
Igal•2y ago
Switching to (or using them parallel) kysely or drizzle is not really an solution imho.
Why? 😦
SGeri
SGeri•2y ago
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
Ramazan
Ramazan•2y ago
Using the experimental json protocol is definitely one
Mendy
Mendy•2y ago
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.
Want results from more Discord servers?
Add your server