Thursday, March 31, 2016

Tuning a Google Compute Engine (GAE) Micro Instance for WordPress

Google Compute Engines click to deploy Wordpress deployment has recently added the ability to deploy to a micro instance stacked with a whopping 512k ram. Yep, this is less than cell phones from like 10 years ago... but for people like me who want to host blogs without all the costs (I mean who doesn't... ), I decided to tune out this GCE Wordpress install. Infact after a great tune up, the site is able to do 10k or so traffic easily a day. For 5$ a month, not too shabby...

First things first if you haven't already signed up for google's free trial, give it a try, When you have made an account, click on over to "Cloud Launcher" in the menu. I am sure google will change this several 100 times after I write this blog, so in general look for google's click to deploy solution.

As of this writing the click to deploy solution has 3 different options for Wordpress and 6 different options in different categories:






Click on the single site icons until you find the click to deploy for a micro instance. The price should be somewhere around 5$ a month.

Google changes the setup frequently so I won't walk through much of this. Select the correct disk type you would like, I prefer at time of writing the SSD persistant disk, the speed seems a little better. But of course this changes frequently. Also make sure to click the allow http and https traffic for the site.

Now at this point, google spins up a VM with pretty standard configurations. Sadly too standard, and the instance won't run stable for very long after you setup WordPress. It loves to run out of memory, so lets start configuring this first.

First thing to attack is our main memory hog, Apache. Apache loves to launch multiple processes and sit in RAM waiting to be called. Lets limit these down to needed processes only, and if you need to configure the tuning some, that is ok.

Configure your apache2.conf with the following information:


<IfModule mpm_prefork_module>
    StartServers          1
    MinSpareServers       1
    MaxSpareServers       3
    MaxClients           10
    MaxRequestsPerChild 3000
</IfModule>
 
<IfModule mpm_worker_module>
    StartServers          1
    MinSpareThreads       5
    MaxSpareThreads      15 
    ThreadLimit          25
    ThreadsPerChild       5
    MaxClients           25
    MaxRequestsPerChild 200
</IfModule>

Also make sure to adjust the KeepAliveTimeout to 10 or 15.

UPDATE:

So we ran for a week or so on this, seemed to work for awhile and then finally it failed again. Don't worry! We have quite a few options we are just going 1 by 1 to determine what is most needed and what is just extra tuning. Next up, lets limit Innodb memory allocation. Our error clearly states SQL has requested unavailable memory, so lets go ahead and change that.

Lets go ahead and tune innodb's memory usage.

Open my.cnf  and add this line: innodb_buffer_pool_size = 64M

Save it and back up the system, and lets see if that finishes the job.




















No comments: