2 months ago
Can you help us how can we increase the max connection in the mariadb.
Pinned Solution
2 months ago
Hello Sir,
The best way to do is that you create a custom MariaDB image with max_connection set to .
Steps to do this:
Deploy a MariaDB from the template section.
On your local system build the custom MariaDB. Below is the Dockerfile
FROM mariadb:11.4
# Copy custom MariaDB config
COPY my.cnf /etc/mysql/conf.d/my.cnf
# Expose default MySQL port
EXPOSE 3306
Copy this into my.cnf
[mysqld]
max_connections=500
And build the docker image push it on DockerHub or Github
then come to railway and just change the image of MaraDB with you custom image.
And done
8 Replies
2 months ago
This question appears to be about your application code rather than the Railway platform, which is outside the scope of what we can help with.
Status changed to Awaiting User Response Railway • about 2 months ago
Status changed to Awaiting Railway Response Railway • about 2 months ago
2 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open Railway • about 2 months ago
2 months ago
Hi, so there are 2 ways how you can increase max connection in mariadb
one is you can set it at runtime but note that this is temporary becasue its at runtime and normally resets when you restart the mariadb database.
You do this by setting this SQL Query
SET GLOBAL max_connections = 500;
this takes effects immediatley but it will reset when you restart the db.
Option 2, which I can say is a bit the most better persistent way.
you can set in the
my.conf
.env
depending on your project configurations or your preference.
I will recommend you use the .env approach becasue its the more better approach.
so in the .env youll just set
MARIADB_EXTRA_FLAGS=--max-connections=500
If you are using the my.conf I suppose maybe you are running the MariaDB here on railway then if that is the case you can add this to your my.conf
max_connections = 500
Also one thing to note additional thing is that just know that each connection normally consumes RAM probably 1 MB per connection.
So with like 500 connections thats like 500MB reserved just for connection overhead you know.
And more connection more ram that means usage is gooing to be higher so you can implement sth like connection pooling using PGBOUNCER.
ndegwadavid
Hi, so there are 2 ways how you can increase max connection in mariadb one is you can set it at runtime but note that this is temporary becasue its at runtime and normally resets when you restart the mariadb database. You do this by setting this SQL Query > SET GLOBAL max\_connections = 500; this takes effects immediatley but it will reset when you restart the db. Option 2, which I can say is a bit the most better persistent way. you can set in the > my.conf > > .env depending on your project configurations or your preference. I will recommend you use the .env approach becasue its the more better approach. so in the .env youll just set > MARIADB\_EXTRA\_FLAGS=--max-connections=500 If you are using the my.conf I suppose maybe you are running the MariaDB here on railway then if that is the case you can add this to your my.conf > max\_connections = 500 Also one thing to note additional thing is that just know that each connection normally consumes RAM probably 1 MB per connection. So with like 500 connections thats like 500MB reserved just for connection overhead you know. And more connection more ram that means usage is gooing to be higher so you can implement sth like connection pooling using PGBOUNCER.
2 months ago
a
adityabisenn
a
2 months ago
Try making chnages to the .env of the my.conf and let me know if it works.
2 months ago
Hello Sir,
The best way to do is that you create a custom MariaDB image with max_connection set to .
Steps to do this:
Deploy a MariaDB from the template section.
On your local system build the custom MariaDB. Below is the Dockerfile
FROM mariadb:11.4
# Copy custom MariaDB config
COPY my.cnf /etc/mysql/conf.d/my.cnf
# Expose default MySQL port
EXPOSE 3306
Copy this into my.cnf
[mysqld]
max_connections=500
And build the docker image push it on DockerHub or Github
then come to railway and just change the image of MaraDB with you custom image.
And done
2 months ago
Hi Rohit, I hope you are well!
You can increase the maximum number of connections in MariaDB by changing the max_connections setting. Let me know which server you are trying Windows or Linux?
adityabisenn
a
2 months ago
Did it work
bravo-rohit
Hello Sir, The best way to do is that you create a custom MariaDB image with max\_connection set to <number of connection you want to have>. Steps to do this: Deploy a MariaDB from the template section. On your local system build the custom MariaDB. Below is the Dockerfile FROM mariadb:11.4 \# Copy custom MariaDB config COPY my.cnf /etc/mysql/conf.d/my.cnf \# Expose default MySQL port EXPOSE 3306 Copy this into my.cnf \[mysqld\] max\_connections=500 And build the docker image push it on DockerHub or Github then come to railway and just change the image of MaraDB with you custom image. And done
2 months ago
Yaa, that worked!
Status changed to Solved brody • about 2 months ago