OWASP / OWASP/Nest

Improve Database Connection Management to Prevent Availability Issues

Open
#3,962 2 comments 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
Python
Stars
451
Forks
707
Avg merge
22h 59m
Merged PRs (30d)
91

Description

**Is your feature request related to a problem? Please describe.**

The current `DATABASES` configuration does not define `CONN_MAX_AGE`, `CONN_HEALTH_CHECKS`, or connection pool limits. Under high concurrency, this may lead to connection exhaustion, stale connections, and service unavailability. This represents a reliability and availability risk in production environments.

**Describe the solution you'd like**

Enable persistent connections and proper connection management by configuring:
- `CONN_MAX_AGE`
- `CONN_HEALTH_CHECKS`
- Appropriate connection pool limits (driver-level or via PgBouncer)

This would improve application resilience, prevent connection exhaustion, and reduce the risk of cascading failures under load.

**Describe alternatives you've considered**

An external connection pooler such as PgBouncer can also mitigate this risk. However, enabling proper connection settings at the application level provides an immediate and low-effort reliability improvement.

**Are you going to work on implementing this?**

- [x] Yes
- [ ] No

**Additional context**

This is a small configuration change with high impact on production stability and availability, especially for public-facing or high-traffic deployments.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.