I'm running into some problems while testing my Lambda function. I my test, I execute in parallel N
executions of my Lambda function. In my lambda function, I retrieve a database connection through Knex. I was messing around with the setting in the db init pool: { min: 0, max: [1 or 5] }
, which seems to fix/break things, depending on other things in my code.
Executing my lambda function 20 times outputs correct results, however, when I up it to 500 (what I am expecting to see in production will easily exceed this), things start to break. I'm running into errors such as Error: ER_CON_COUNT_ERROR: Too many connections
, Error: pool is draining and cannot accept work
(if I use Knex's knex.destroy()
interface at the end of my lambda function). What is the correct way to handle connections and pooling for scale in AWS Lambda and RDS? Are the problems that I'm seeing on my local machine going to replicate if I were to run the same stress tests on AWS?
max_connections
system variable in MySQL? Are you familiar withSHOW PROCESSLIST;
?