OOM Killer

Discussion in 'Server Operation' started by kaostc, Jun 15, 2023.

  1. kaostc

    kaostc Member HowtoForge Supporter

    OOM Killer is killing mariadb process repeatedly. In this cases, what should be done?
    - Disable OOM Killer. I think this is not a good idea because server will run out of memory.
    - Configure the service to relaunch automatically after being killed. Is this a good idea?
    - Scale up the server. OOM killer being invoked repeatedly means that server has a lot of load, so it would be undersized.
    Any thoughts will be welcomed
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Add swap.
    Maybe server just has too little memory? You did not show memory and swap sizes.
     
    ahrasis likes this.
  3. kaostc

    kaostc Member HowtoForge Supporter

    Yes, it is a tiny VPS, 2GB-no swap.
    I use Debian and started dealing with OOM some months ago, I don't know if it is a new feature but time before when a server reached it limit, it simply get locked due to overloading, and you had to reboot it. I just want to know how to deal with this situations now with OOM, I guess that the symptom of it being invoked repeatedly is the alarm to upscale the VPS :), and there is nothing more to do. Sorry, maybe I am asking or sharing thoughts about something that is quite obvious... :).
    Thanks a lot!
     
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    The 2 GB memory is enough with 4 GB swap. If you can not have swap, as a partition or swap file, I would switch to host with more memory. My opinion is adding 4 GB swap is best solution.
    It may be possible to tweak mariadb settings to make it use less memory, if you do not want to upgrade host.
     
  5. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    well.. if it's running out of memory, and obvious solution for now is just more memory..
    at least until it starts using all that extra memory and starts happening again..

    adding swap as @Taleman suggests is another option, which should probably be done on all servers anyway..
    it will reduce the frequency of OOM events, if not remove them completely, but depending on your systems usage, it may make some applications (or whole server) unacceptably slow for some periods..

    what else is running at the time it runs out of memory? perhaps you have large databases? maybe a website is getting lots of activity..
    maybe clamav is running a periodic scan (can easily use up 2GB+ on it's own)

    if it's a backlog of processes waiting to run, maybe more cpu's would allow concurrent processes to finish quicker, and reduce the overall ram usage... maybe splitting applications across multiple servers is a better solution..
    more memory / more swap are good solutions to the immediate issue, but you should really do something to find out what is using all the memory and then look to see if there's any way to stop that happening in the first place.
     

Share This Page