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 Fletcher04 Apr 2025
Managing .gitignore changes
When working with Git, the .gitignore file plays a critical role in controlling which files and folders are tracked by version control. Yet, many developers are unsure when changes to .gitignore take effect and how to manage files that are already being tracked. This uncertainty can lead to...
Andrew Fletcher26 Mar 2025
How to fix the ‘Undefined function t’ error in Drupal 10 or 11 code
Upgrading to Drupal 10.4+ you might have noticed a warning in their code editor stating “Undefined function ‘t’”. While Drupal’s `t()` function remains valid in procedural code, some language analysis tools — such as Intelephense — do not automatically recognise Drupal’s global functions. This...
Andrew Fletcher17 Mar 2025
Upgrading to PHP 8.4 challenges with Drupal contrib modules
The upgrade from PHP 8.3.14 to PHP 8.4.4 presents challenges for Drupal 10.4 websites, particularly when dealing with contributed modules. While Drupal core operates seamlessly, various contrib modules have not yet been updated to accommodate changes introduced in PHP 8.4.x. This has resulted in...