Is there any way to reduce the dependency size of ...
# prisma-client
m
Is there any way to reduce the dependency size of prisma in my lambda functions? 7.5MB of minified JS is causing some brutal cold starts
n
Hey Mischa 👋 the best way to reduce the bundle size in Lambdas is by using the Data Proxy since that will deploy the Query Engine binary (which is mostly responsible for the bundle size) to an extra server instead of bundling it via node_modules.
m
I’ll take a look thanks. However I already have the query engine offloaded to a lambda layer, the code that’s bundled in my app is the generated clients (right?). Does the data proxy obviate the need for the generated clients?
I don’t really know what the difference is between .prisma/client/index.js and @prisma/client/runtime either
does using data proxy help with my app bundle size with the generated client? do I need both .prisma/client/index.js and @prisma/client/runtime?
would data proxy help with these issues?
n
Hey Mischa 👋 sorry for the delay, I just heard back from one of the engineers about this.
do I need both .prisma/client/index.js and @prisma/client/runtime?
Yes you need both indeed 👍 Quoting our engineer: From looking at his graph, it looks like his generated client .prisma/client/index.js which contains the DMMF is very big. On a higher level, this generated file is in charge of creating a new client defined in @prisma/client/runtime with that DMMF. In other words, this probably means that he has a big schema and the generated/saved DMMF is very huge. Can you confirm that you have quite a sizeable Prisma schema? Generally, the Data Proxy should be able to improve the situation so I’d certainly suggest giving it a try! Also, we’d love to have more information about the cold start, so it would be great if you could open up an issue with as much information as possible about your setup so that we can look into it properly 🙂
As a potential solution, we’re considering compressing the DMMF (which we already do in some cases but it seems like it could be useful as a default for schemas of a certain size…).
m
what constitutes a very big schema? my schema.prisma file is about 800 lines
my issue isn’t really with connection pooling although i am happy to try out data proxy. i’m using aurora serverless postgres which in many ways is basically a data proxy itself. i’d rather use the aurora data API and bypass all of the connection and VPC nonsense
i can try to write up a ticket with more info but pretty much all i have is the bundle map i posted above
n
my schema.prisma file is about 800 lines
Doesn’t seem unlikely unfortunately 😐 we’ll probably look into the DMMF compression soon!
i can try to write up a ticket with more info but pretty much all i have is the bundle map i posted above
That would certainly be helpful! We’re very eager to resolve these kinds of problems in serverless environments and persisting this on GitHub would help us a lot in doing so 🙂
m
sure thing! thanks for looking into it!
🙏 1
this is the biggest issue I have with prisma and I’m trying to figure out how I’m going to deploy my new prisma app to production without a really poor user experience as far as the cold starts go. I can throw money at it for my most important lambdas by keeping them warm but it’s not a sustainable solution and I have a lot of functions
👍 1