It's not always simple to know which kind of instance type we need in AWS for a database. So here is a point of view to help you in your choice : with the maximum simultaneous connexions possible.
(This tips can also be used to know which engine you want to use depending if you need a really high number)
Before going further
To be able to do the calculations, we need to know :
- where we can found the list of memory size for each kind of instance
- and how to convert a GiB in bytes
Memory size of each kind of instance
For that point, please check the AWS documentation : https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html#Concepts.DBInstanceClass.Summary
How to convert a GiB in bytes
1 GiB = 1 073 741 824 bytes
MariaDB & MySQL
Following the AWS Documentation (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Limits.html#RDS_Limits.MaxConnections), the calcultation of the max connections is :
DB Instance Class Memory / 12 582 880
Where DB Instance Class Memory is the memory size in bytes of an instance type.
It's maximum value is 100 000 for MySQL and MariaDB, but if the value is greater than 16 000 AWS RDS set it to 16 000.
So for a db.m5.xlarge instance :
16 GiB / 12 582 880
16 * 1 073 741 824 / 12 582 880
17 179 869 184 / 12 582 880
1 365 simultaneous connexions
Oracle
Following the AWS Documentation (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Limits.html#RDS_Limits.MaxConnections), we can setup the maximum of sessions between 100 - 65 535 manually.
But here it's the number of processes which depends of the instance class. Here is the calculation:
LEAST((DB Instance Class Memory / 9 868 951), 20 000)
So for a db.m5.xlarge instance :
LEAST((16 GiB / 9 868 951), 20 000)
LEAST((16 * 1 073 741 824 / 9 868 951), 20 000)
LEAST((17 179 869 184 / 9 868 951), 20 000)
LEAST(1 740, 20 000)
1 740 processes
PostgreSQL
Following the AWS Documentation (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Limits.html#RDS_Limits.MaxConnections), the calculation is :
LEAST((DB Instance Class Memory / 9 531 392), 5 000)
So for a db.m5.xlarge instance :
LEAST((16 GiB / 9 531 392), 5 000)
LEAST((16 * 1 073 741 824 / 9 531 392), 5 000)
LEAST((17 179 869 184 / 9 531 392), 5 000)
LEAST(1 802, 5 000)
1 802 simultaneous connexions
SQL Server
In AWS, by default, the maximum number of concurrent connections is unlimited.
I hope it will help you! 🍺
Top comments (0)