MariaDB max connections

You can scale up your max_connections just fine. Put a line like


in your MariaDB my.cnf file. But don’t just set it to a very high number; each potential connection consumes RAM, and with only 8GiB you need to be a bit careful about that.

If you give this command you’ll get a bunch of data about your connections.

SHOW STATUS LIKE '%connect%';

The important ones to watch:

  • Connection_errors_max_connections The number of connection attempts that failed because you ran out of connection slots.
  • Connections The total number of connections ever handled
  • Max_used_connections The largest number of simultaneous connections used.
  • Max_used_connections_time The date and time when the server had its largest number of connections.

The numbers shown are cumulative since the last server boot or the most recent FLUSH STATUS; statement.

Keep an eye on these. If you run short you can always add more. If you have to add many more connections as you scale up, you probably will need to provision your VPS with more RAM. The last two are cool because you can figure out whether you’re getting hammered at a particular time of day.

And, in your various microservices be very careful to use connection pools of reasonable maximum size. Don’t let your microservices grab more than ten connections unless you run into throughput trouble. You didn’t say what client tech you use (nodejs? dotnet? php? Java?) so it’s hard to give you specific advice how to do that.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top