RDS max connections by engine and instance class
RDS derives the default max_connections from the instance's memory. MySQL uses DBInstanceClassMemory/12582880 (about one connection per 12 MB), PostgreSQL uses LEAST(DBInstanceClassMemory/9531392, 5000), and MariaDB 10.5 and later uses LEAST(DBInstanceClassMemory/25165760, 12000). Because DBInstanceClassMemory excludes memory reserved for the OS and RDS, a MySQL instance with 8 GiB gets roughly 630 connections, not 683. You can override the value in a custom parameter group.
Default formulas by engine
| Engine | Parameter | Allowed values | Default |
|---|---|---|---|
| MySQL | max_connections | 1 to 100,000 | {DBInstanceClassMemory/12582880} |
| MariaDB 10.5+ | max_connections | 1 to 100,000 | LEAST({DBInstanceClassMemory/25165760}, 12000) |
| MariaDB 10.4 | max_connections | 1 to 100,000 | {DBInstanceClassMemory/12582880} |
| PostgreSQL | max_connections | 6 to 262,143 | LEAST({DBInstanceClassMemory/9531392}, 5000) |
| Oracle | processes | 80 to 20,000 | LEAST({DBInstanceClassMemory/9868951}, 20000) |
| SQL Server | user connections | 0 to 32,767 | 0 (unlimited) |
| Db2 | (not settable) | - | 64,000 |
DBInstanceClassMemory is in bytes and is smaller than the advertised memory, because RDS subtracts what the operating system and its own management processes use. That's why the numbers in published "max connections per instance type" tables are only approximations.
Worked examples (approximate)
| Instance memory | MySQL default | PostgreSQL default |
|---|---|---|
| 1 GiB (e.g. db.t4g.micro) | ~60 to 85 | ~80 to 110 |
| 8 GiB (e.g. db.m7g.large) | ~630 | ~800 to 900 |
| 32 GiB | ~2,600 | ~3,400 |
| 128 GiB | ~10,000+ | 5,000 (cap) |
The 8 GiB MySQL figure is AWS's own example (630 rather than the 683 you get from the full 8 GiB). Treat the other rows as estimates and read the live value from the database.
Check the real value
-- MySQL / MariaDB
SHOW VARIABLES LIKE 'max_connections';
SHOW STATUS LIKE 'Threads_connected';
-- PostgreSQL
SHOW max_connections;
SELECT count(*) FROM pg_stat_activity;From the CLI, see whether the parameter group overrides the default:
aws rds describe-db-parameters --db-parameter-group-name app-mysql8 \
--query "Parameters[?ParameterName=='max_connections'].[ParameterValue,Source,ApplyType]"A value that is a formula in braces means the default is in force. The DatabaseConnections CloudWatch metric shows the trend; an alarm on it at around 80% of max_connections is a sensible early warning.
Should you raise it?
Each connection uses memory (per-connection buffers in MySQL, a backend process in PostgreSQL). Setting max_connections well above the default can push the instance into memory pressure, swapping, or the incompatible-parameters state if the configuration cannot start. Raise it only after checking FreeableMemory headroom, and prefer these first:
- Pool connections in the application and size pools so that pods or tasks multiplied by pool size stays below the limit.
- Use RDS Proxy for Lambda and other bursty clients; it multiplexes many client connections onto fewer database connections.
- Close idle sessions: set
wait_timeout(MySQL) oridle_in_transaction_session_timeout(PostgreSQL) in the parameter group. - Scale up the instance class if you genuinely need more concurrent work; the default rises with memory.
If you do change it, set a fixed number or a formula in a custom parameter group. max_connections is static on PostgreSQL (needs a reboot) and dynamic on MySQL.
When you hit it
MySQL returns ERROR 1040 (HY000): Too many connections; PostgreSQL returns FATAL: sorry, too many clients already, or a message that the remaining connection slots are reserved, because a few slots are held back for privileged roles. The too many connections fix covers recovery.
Questions
How do I calculate max_connections for RDS MySQL?
Divide DBInstanceClassMemory (in bytes, slightly less than the instance's advertised memory) by 12,582,880. That is roughly the memory in MB divided by 12.
What is the max_connections limit for RDS PostgreSQL?
The default is LEAST(DBInstanceClassMemory/9531392, 5000), so it never exceeds 5,000 unless you override it; the parameter accepts up to 262,143.
Does changing max_connections require a reboot?
On RDS for PostgreSQL yes, it is a static parameter. On RDS for MySQL it is dynamic and applies immediately.
Connection exhaustion usually starts with a deploy or a Lambda spike and takes the whole app down. CloudConsole, a phone app for AWS, is being built to show database connection alarms on your phone so you can catch the climb before it hits the ceiling.
About the app → · Download on the App Store