{"id":438,"date":"2016-02-11T10:48:27","date_gmt":"2016-02-11T10:48:27","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=438"},"modified":"2016-02-11T10:48:27","modified_gmt":"2016-02-11T10:48:27","slug":"mysql-running-out-of-memory-being-killed-by-oom","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2016\/02\/11\/mysql-running-out-of-memory-being-killed-by-oom\/","title":{"rendered":"MySQL running out of memory being killed by OOM Killer"},"content":{"rendered":"<p>So, every now and then we get customers asking if they can increase their memory because MySQL keeps on being killled by the kernel, mainly because on say a 2GB physical RAM server, MySQL eats it all up and even tries to use more than is there. So the kernel scheduler is like &#8216;no.. stop that&#8217;. This kind of thing could be avoided by configuring MySQL with proper limits as to not flood the physical hardware. <\/p>\n<p>This is often and commonly overlooked in MySQL databases, and no tuning is done, but it&#8217;s important to base the MySQL configuration (\/etc\/my.conf) on the physical hardware of the server. So IF you increase the RAM on the server, to get the optimum speed you&#8217;d want to increase some of the RAM usage. A friend of mine said of a great trick used by many organisations of pointing the mysql filesystem to memory, this is a great performance increase, as it completely avoids the filesystem, the only downside is if the box turns off, the database is gone \ud83d\ude00<\/p>\n<pre>\r\ninnodb_buffer_pool_size = 384M\r\nkey_buffer = 256M\r\nquery_cache_size = 1M\r\nquery_cache_limit = 128M\r\nthread_cache_size = 8\r\nmax_connections = 400\r\ninnodb_lock_wait_timeout = 100\r\n<\/pre>\n<p>I found this config for a 2GB server on stack overflow, and it looks just about right. Adjusting the connections to suit should ensure that the box doesn&#8217;t get too overloaded, but also the memory is important too. One thing to bare in mind, by restricting RAM queries might not run as fast, but the database won&#8217;t suddenly go offline and process be killed this way. That&#8217;s what you want, really isn&#8217;t it;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, every now and then we get customers asking if they can increase their memory because MySQL keeps on being killled by the kernel, mainly because on say a 2GB physical RAM server, MySQL eats it all up and even &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2016\/02\/11\/mysql-running-out-of-memory-being-killed-by-oom\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,2],"tags":[],"class_list":["post-438","post","type-post","status-publish","format-standard","hentry","category-linux","category-mysql"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=438"}],"version-history":[{"count":1,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/438\/revisions"}],"predecessor-version":[{"id":439,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/438\/revisions\/439"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}