question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lambda Cold Start, influenced by schema size

See original GitHub issue

Bug description

Continuing from #10724 - please see there for more details. It contains data I gathered while profiling lambda cold starts with prisma.

Problem: lambda cold starts are increased by importing prisma.

I believe part of the problem is that despite us having a medium-sized DB schema, a very large DMMF string (6,492,708 characters) is produced which must be parsed at startup. The difference in startup between an empty DMMF string and a large one is around one second.

Please see the repro repo: https://github.com/jetbridge/prisma-bundle-size

Using the repro repo you can observe the difference in startup time for two lambdas, one without prisma and one that imports prisma and tries to do a query with DATABASE_URL=file:./dev.db set.

My goal is to reduce the cold start time of my lambda functions that use prisma as much as possible.

Screen Shot 2022-01-19 at 13 36 53 Screen Shot 2022-01-19 at 14 01 48 Screen Shot 2022-01-19 at 14 01 45

How to reproduce

See repo README

Expected behavior

No response

Prisma information

3.8.0

Environment & setup

  • OS:
  • Database:
  • Node.js version:

NodeJS 14 on AWS Lambda

Prisma Version

prisma                  : 3.8.1
@prisma/client          : 3.7.0
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at ../../../../usr/local/lib/node_modules/prisma/node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at ../../../../usr/local/lib/node_modules/prisma/node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at ../../../../usr/local/lib/node_modules/prisma/node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at ../../../../usr/local/lib/node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f
Studio                  : 0.452.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
pabachamcommented, Jan 21, 2022

Let me join this thread. My Prisma schema is around 15k lines and Cold Starts are high

1reaction
pabachamcommented, Jan 23, 2022

@janpio I am not sure that there is a direct influence. I am about to get access to x-ray from devops, once I get I will provide the results.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Operating Lambda: Performance optimization – Part 1
This post describes the Lambda execution environment lifecycle, and explains defining, measuring, and improving cold starts.
Read more >
How does language, memory and package size affect cold ...
Comparing the cold start times of AWS Lambda using different languages, memory allocation, and sizes of deployment package. Learn more!
Read more >
End Cold Starts in Your Serverless Apps with AWS Lambda ...
Running latency-sensitive serverless applications, such as web and mobile back-ends, has been challenging to do effectively.
Read more >
AWS Lambda Performance and Cost Optimization
Cold starts → Execution environments are influenced by the following factors from the AWS side. Memory allocation; Size of function package ...
Read more >
Zero cold start for lambda? : r/aws - Reddit
Lambdas that call other lambdas might be affected even more. Latency is getting more and more important for user experience these days... the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found