- Newest
- Most votes
- Most comments
- Your application might not be closing database connections properly, leading to a build-up of idle sessions. Ensure that your application properly closes database connections after use. Use connection pooling libraries (like HikariCP for Java) to manage connections efficiently.
- Long-running queries that take a long time to execute can keep sessions open for an extended period. Identify and optimize long-running queries. Use tools like AWS Performance Insights, RDS Enhanced Monitoring, or query analysis tools specific to your database engine.
- Your RDS instance may lack CPU, memory, or IOPS to handle the load. Consider scaling your RDS instance vertically (to a larger instance type) or horizontally (adding read replicas).
- Database parameters or application configurations might not be optimized for your workload. Review and optimize database parameters (e.g., max_connections, work_mem, shared_buffers). Ensure that your application’s connection pool settings match the database's capacity.
- Bugs in the application code can lead to excessive connection usage or failure to release connections. Review application logs and code to identify and fix bugs that might cause connection leaks or excessive session creation.
- Sudden spikes in traffic or load can overwhelm the database with connection requests. Implement auto-scaling solutions and load balancers to distribute the load. Use caching mechanisms (like Redis or Memcached) to reduce the database load.
Analyze Slow Queries: Use the database’s native tools (e.g., EXPLAIN in PostgreSQL, EXPLAIN PLAN in MySQL) to analyze and optimize slow queries.
You haven't said what the client application is - for example, as your user connections increase and each user connects to an individual container or Lambda function then each of those will connect to the database. No matter what you do (in terms of increasing the maximum number of connections) you may still eventually reach a limit beyond which the database cannot scale.
You should investigate database connection pooling - where the clients connect to a system which then manages the queries to the database itself, keeping the number of connections lower. For RDS, have a look at RDS Proxy which is specifically designed to solve this problem.
The Application is Magento. I have analyzed usually after any lock on the table RDS sessions increasing rapidly
Relevant content
- asked 2 years ago
- asked a year ago
- asked 6 years ago

Usually it happens when the realtime users reaches upto 10K