Avoid OOM for the MySQL Service

Hi

So I have an database (with OK’ish traffic). We sometimes see that the database is killed with OOM, I’ve tried to adjust the OOM score, set to -1000. Unfortunately, this has caused the whole server to crash again, so properly not the best approach. :laughing:

The server has 8G of memory, and the innodb pool size is set to 4G. So I really dont unstand why the MySQL service basically eats up all the memory. Is it just because of the size / indexes on the MySQL DB ?

If I check the load on the server, it basically uses all 8G (not cached or anything)

free -m
               total        used        free      shared  buff/cache   available
Mem:            7936        7398         184           0         352         267
Swap:           2047          77        1970
  1. What should we monitor for, like inside MySQL ?
  2. How can we avoid this? Is the only option really to increase the memory of the server ?

You should consider checking this blog

MySQL does not only use the memory that assigned for buffer pool but other than that it needs the memory for each connections made and for other caches like sorting, joining, temp tables etc.

You should find out where the memory is being utilized.

If there is a leak, you can also try installing Jemalloc library for better memory management

Thanks for response to this. I will take a look at it. :slight_smile: