I'm running MariaDB 10.2.27 on Ubuntu 16.04 (10 cores, 40 GB RAM).
We have a queued message handling system (using Symfony Messenger) that normally has 20 workers consuming messages from the queue. These spawn jobs that connect to the database and perform various tasks.
Most of the time it works fine, but occasionally all the workers hit the database simultaneously and the server is slammed. When this happens, the usage on all 10 cores hits 100% (according to htop monitor). The database starts dropping connections and the server is unusable. This was happening 2 to 3 times a day. RAM usage is only at 50% and there is no swap usage.
I reduced the number of active workers to six and the problem seems to have gone away. It's only been two days, but I have not had any problems since then. I still get an occasional dropped connection, but they are infrequent.
Instead of reducing the number of workers, is there a way to configure MariaDB to "throttle" queries or avoid this kind of overload problem?