Skip to main content

The issue of over 300 simultaneous database connections in the context of AWS and Drupal can have several potential causes. Here are some common factors to consider:

Server Configuration

Check your server configuration to ensure it can handle the expected number of simultaneous connections. This includes parameters like max_connections in your database server configuration.

Traffic or Load Spike

A sudden increase in traffic or load on your Drupal site can lead to more simultaneous database connections. Analyze your site's traffic patterns and server load during the occurrence of the issue.

Database Connection Pooling

If your application uses connection pooling, review the configuration settings. Connection pooling can help manage and reuse database connections efficiently.

Unclosed Database Connections

Ensure that your Drupal application closes database connections properly after use. Unclosed connections can accumulate over time and lead to a large number of simultaneous connections.

Long-Running Queries

Identify and optimise any long-running queries that might be holding database connections for an extended period. Long queries can tie up resources and prevent the release of connections.

Module or Theme Issues

Some contributed modules or custom themes might not release database connections properly. Check if the issue persists when disabling certain modules or themes.

Connection Leaks

Look for any potential connection leaks in your application code. Connections that are not properly closed can accumulate and lead to the observed behavior.

AWS RDS Scaling

If you are using Amazon RDS for your database, check the RDS metrics and scaling settings. It might be necessary to adjust the allocated resources or scale your database instance to handle the load.

Database Configuration

Review your database configuration, including the number of allowed connections, connection timeout settings, and other relevant parameters.

Database Logs

Examine your database logs for any error messages or warnings related to connections. Database logs can provide valuable insights into issues.

Monitoring and Logging

Implement comprehensive monitoring and logging to track database connections over time. AWS CloudWatch or other monitoring tools can assist in identifying patterns and potential issues.

Drupal Cache and Performance

Optimise your Drupal site's cache and performance settings. A well-optimised site can reduce the number of database queries and, consequently, the number of simultaneous connections.

Identifying the specific cause may involve a combination of monitoring, logging, and analysis of your Drupal and AWS configurations. It's recommended to make changes cautiously and test them in a staging environment before applying them to a production site.

Related articles

Andrew Fletcher17 Feb 2024
Drupal - Solr working through tm_X3b_en_body error
Having updated Solr, re-indexing wasn't working. The error in the logs wasDrupal\search_api_solr\SearchApiSolrException while indexing item entity:node/2386:en: Solr endpoint http://127.0.0.1:8983/ bad request (code: 400, body: Exception writing document id...