Is a persistent db connection required?

System Information
  • Strapi Version: 3.3.4
  • Operating System: Alpine Linux
  • Database: AWS Aurora MySql Serverless
  • Node Version: 14.15.1
  • NPM Version: 6

I’m not sure if this is a bug or not, so I figured I would ask here first. I recently deployed Strapi into AWS Fargate and pointed the database to an AWS Aurora serverless setup. Aurora is configured to go to sleep after 5 min of inactivity, but I noticed it never goes to sleep. When I checked the logs, it looks like the connection from Strapi is persistent. Strapi is the only app running in the cluster.

I want to know if this is an intentional design decision, or is this a bug? Should Strapi be releasing the connection?


Two things of here to note:

  • AWS Aurora actually is not in our list of supported databases, Aurora is listed as compatible with PG and MySQL but does not run the same codebase and we do not actively test it’s usage.

  • Database connections are managed by Knex (specifically the tarn pooling provided by Knex) and you can customize the timeouts and min/max connections via the database.js. See the Bookshelf configuration on our documentation

The key points of that documentation are the options.pool object

  • Min => Keeps x amount of connection alive at all times (default is 1)
  • Max => Maximum number of connections allowed in the pool
  • idleTimeoutMillis => Wait time before destroying idle connections in the pool
  • reapIntervalMillis => How often to check for idle connections

In your case I believe it’s likely the min pool option as the default of 1 causing the issue, however you are running an “at your own risk” type of setup by using Aurora. Any bugs found while using that database that cannot be replicated into a supported version of PostgreSQL, MySQL, or MariaDB we cannot help you with.


how did you setup aurora serverless local setup. I was not able to find any article regarding this. Appreciate your help if you can share more insight into how you configured it.