{"id":102,"date":"2022-02-03T11:32:12","date_gmt":"2022-02-03T04:32:12","guid":{"rendered":"http:\/\/warawich.com\/?p=102"},"modified":"2022-02-03T11:32:12","modified_gmt":"2022-02-03T04:32:12","slug":"memory-leak-use-minimum-cost-for-droplet-lets-create-swap-file","status":"publish","type":"post","link":"https:\/\/warawich.com\/index.php\/2022\/02\/03\/memory-leak-use-minimum-cost-for-droplet-lets-create-swap-file\/","title":{"rendered":"Memory Leak , use minimum cost for droplet , Let&#8217;s create swap file."},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I use wordpress, nginx, mysql, php-fpm with minimun cost on DigitalOcean and found the memory leak problem. This cause MySQL stop working and my websit goes down.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"93\" class=\"wp-image-103\" style=\"width: 600px;\" src=\"http:\/\/warawich.com\/wp-content\/uploads\/2022\/02\/Screen-Shot-2565-02-03-at-09.37.43.png\" alt=\"\">   <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I also found there are lots child processes of php-fpm. I thought I should consider to increase the memory (use 1 GB) or not.   Anyway I don&#8217;t want to spent my money for my website as I&#8217;m person to check it out only one HaHa if you came across to read this. You are second. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These are I did for fix the memory issue.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create swap file https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-add-swap-on-centos-7 I create 2GB swapfile because my memory has 1 GB . If you have memory more than 1 GB , you should multiply 1.5 of physical memory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/Check Swap usage\nswapon -s\n\/\/if no return message, it mean no swap \n\n\/\/create swap file\nsudo dd if=\/dev\/zero of=\/swapfile count=2096 bs=1MiB\n\n\/\/change permission read write only\n<code>sudo chmod 600 <mark>\/swapfile<\/mark><\/code>\n\n\/\/make a swapfile\nmkswap \/swapfile\n\n\/\/enable swap \nswapon \/swapfile\n\n\/\/Check Swap usage again\nswapon -s\n\/\/should return swap size\n[root@ake warawich.com]# swapon -s\nFilename Type Size Used Priority\n\/swapfile file 2097148 264 -2\n\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Make the Swap File Permanent<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">vi \/etc\/fstab<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/swapfile   swap    swap    sw  0   0<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then reboot OS<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, you have memory more but the root cause is php-fpm create lots of child process and consume your memory , so you need to limit php-fpm create child process too.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">vim \/etc\/php-fpm.d\/www.conf<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/change configure as below\npm = ondemand\npm.max_children = 20\npm.start_servers = 5\npm.process_idle_timeout = 10s\npm.max_requests = 100<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">save and restart php-fpm service<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart php-fpm <\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/check memory free\nroot@ake warawich.com]# free -m\ntotal used free shared buff\/cache available\nMem: 990 544 111 12 335 294\nSwap: 2047 0 2047<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">All of these what i did!  Please suguest me if what you think or what I miss. Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I use wordpress, nginx, mysql, php-fpm with minimun cost on DigitalOcean and found the memory leak problem. This cause MySQL stop working and my websit goes down. I also found there are lots child processes of php-fpm. I thought I should consider to increase the memory (use 1 GB) or not. Anyway I don&#8217;t want &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/warawich.com\/index.php\/2022\/02\/03\/memory-leak-use-minimum-cost-for-droplet-lets-create-swap-file\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Memory Leak , use minimum cost for droplet , Let&#8217;s create swap file.&#8221;<\/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":[1],"tags":[],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/comments?post=102"}],"version-history":[{"count":1,"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":104,"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/posts\/102\/revisions\/104"}],"wp:attachment":[{"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/warawich.com\/index.php\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}