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.

We could give some numbers for connection pool size / concurrency limits for Serverless AWS Lambda or link to GitHub issue

See original GitHub issue

To me my default thinking was that Lambda only have 1 CPU, looking on Google says that sometimes they have 2 but real testing below says it’s always 2 so it could be nice to have a reference to that in the docs section for users:

Memory (MB) CPU (Cores) Default Pool Size (= 2 * CPU + 1)
128 2 5
256 2 5
512 2 5
1024 2 5
2048 2 5
3008 2 5

So now I just changed the memory setting, but the reported cpu value is always the same, meaning we’ll give 2 IO threads per lambda and 5 connections.

And to be clear. This is what we see from the OS layer. It might be wrong, it might be less or more. But the system sees 2 and will act based on that.

_Originally posted by @pimeys in https://github.com/prisma/prisma/issues/942#issuecomment-558153490_

Different popular PostgreSQL instances and their limits:

Instance Size used_at_start max_conn res_for_super res_for_normal
t2.micro 7 87 3 77
t2.small 7 198 3 188
t2.medium 7 413 3 403
t2.large 7 856 3 846
t2.xlarge 7 1743 3 1733
t2.2xlarge 7 3518 3 3508
m5.large 7 823 3 813
m5.xlarge 7 1691 3 1681
m5.2xlarge 7 3429 3 3419
m5.4xlarge 7 5000 3 4990

Some of the connections are used already when the instance is running, so I’d base my calculations for the connections reserved for normal users (the last column).

So with the default pool size of five connections: Lambda Concurrency Limit based on Different popular PostgreSQL instances

Instance Size Lambda Concurrency Limit
t2.micro 15
t2.small 37
t2.medium 80
t2.large 169
t2.xlarge 346
t2.2xlarge 701
m5.large 162
m5.xlarge 336
m5.2xlarge 683
m5.4xlarge 998

_Originally posted by @pimeys in https://github.com/prisma/prisma/issues/942#issuecomment-558269427_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
mhwelandercommented, Apr 16, 2021

Added link to this in doc.

1reaction
mhwelandercommented, Feb 24, 2021

@Jolg42 Salutations - could you tell me a bit more about when a user might want this information? Is it something I would mention in the deployment docs?

Does it change this sentence?

Serverless (FaaS): It’s recommended to set the connection limit to 1 if you’re not using an external connection pooler because each incoming request starts a short-

And what does “Lambda Concurrency Limit based on Different popular PostgreSQL instances” affect?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lambda quotas - AWS Documentation
Each instance of your execution environment can serve an unlimited number of requests. In other words, the total invocation limit is based only...
Read more >
AWS Lambda Concurrency - Lumigo
Reserved concurrency – guarantees the maximum number of concurrent ... By default, AWS Lambda gives you a pool of 1000 concurrent executions per...
Read more >
Connection management (Guide) - Prisma
Depending on your serverless concurrency limit (the number of serverless functions running in parallel), you might still exhaust your database's connection ...
Read more >
Can Lambda and RDS Play Nicely Together? - Thundra Blog
Can AWS Lambda and RDS work together seamlessly? ... so it's no longer an issue when you connect to VPC-internal resources like RDS...
Read more >
AWS Lambda Functions - Serverless Framework
By default, AWS uses account concurrency limit ... You can specify an array of functions, which is useful if you separate your functions...
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