A step-by-step guide to launching high-performance WordPress site on Google Cloud Platform (GCP) using Easy Engine.
When you start as a blogger or running a small business then shared hosting is fine as it cost less and no hosting skills required to install/setup/maintain the infrastructure platform.
However, when your traffic or user base increase then you need a robust hosting platform to serve millions of customer without slowing down the site.
However, if you are ok to spend a little bit of time in learning and doing by yourself, then you can think about VPS/Cloud servers.
In this article, I will explain how to get WordPress site running on Google Cloud Platform in less than 15 minutes.
This setup would cost around $20 per month and ready to serve 500,000 page views per month. Post setup, I will do a load test to verify the performance.
Prerequisite
- I assume you already have a domain, if not you can buy from Namecheap or Google.
- Google cloud account with billing enabled
- Some WordPress theme but I will use Newspaper by Tagdiv
Provision New Google Cloud Server
- Login to Google Cloud and go to Compute Engine >> VM Instances (direct link)
- Click “Create Instance” and enter the required information
- Select the zone (choose the nearest location of your targetted audience)
- Choose the machine type (I will choose g1-small)
- Change boot disk to Ubuntu 16.04 LTS and boot disk type to SSD persistent disk with 10 GB size
- Allow HTTP and HTTPS firewall and click Create
In few seconds, you will have the new instance ready.
Installing WordPress using EasyEngine
There are multiple ways to install WordPress, but one of the easiest ways is using EasyEngine.
EasyEngine is script wrapper which takes care of installing required components like a database, PHP, Nginx, WordPress, etc.
If you install them manually, then it may take longer and room for human errors.
- Login to newly created Google Cloud VM and switch to root user Note: it’s recommended to setup
Note: it’s recommended to setup sudo access to root from a normal user in production, but in this exercise, I will use root.
- Install EasyEngine with the below command
1 |
wget -qO ee rt.cx/ee && sudo bash ee |
It will take a minute or two and once done; you will be returned to the prompt
Now it’s time to create a WordPress site. EasyEngine gives you an option if you want to install WordPress with caching plugins.
Currently, it supports WP Super, W3 Total, Nginx, Redis. I’ve tried all and Redisalways performed better for me.
- Let’s create a site with Redis cache.
1 |
ee site create techpostal.com --wpredis |
Above, I am asking EasyEngine to create a site for techpostal.com (It’s my lab domain) with Redis cache.
- You will get an experimental information configuration, type ,
y
and pressEnter
1 2 3 4 5 |
root@my-wordpress-site:~# ee site create techpostal.com --wpredis Redis is experimental feature and it may not work with all CSS/JS/Cache of your site. You can disable it by changing cache later. Do you wish to enable Redis now for techpostal.com? Type "y" to continue [n]:<strong>y</strong> |
It will take few seconds, and you will be returned to the prompt with WordPress login credential.
1 2 3 4 5 6 |
WordPress admin user : Chandan WordPress admin user password : GBHkx9lgawfErje Configure redis-cache: http://techpostal.com/wp-admin/options-general.php?page=redis-cache Object Cache: Enable Successfully created site http://techpostal.com root@my-wordpress-site:~# |
- Save the password in secure place.
WordPress is successfully installed, and it’s time to point your domain to server IP.
Getting Static IP
By default, Google Cloud assign an ephemeral IP to the instance which you don’t want to configure with the domain as it may change in next instance reboot.
To avoid the risk, we will reserve a static IP.
- Go to VPC Network >> External IP addresses from left navigation
- Drop-down Ephemeral type and select static
- Give the name and click RESERVE
- You will notice type is changed to Static
GCP VM is ready with the static external IP and WordPress, and the last thing to do is map domain to the static IP.
Update Domain A Record
- Go to domain registrar
- Update the A record for your domain to the external IP you just reserved
It may take some time to get propagated globally. You can use DNS record lookup tool to verify.
Once domain A record is updated, you can access WordPress site with the domain you used with EasyEngine command. In my example – http://techpostal.com
Performing Load Test
Let’s see how newly setup WordPress site on Google Cloud Platform performs. Before doing a speed test, I will install a theme by Tagdiv as mentioned earlier.
This is not necessary but just to ensure I have some post/media files to simulate real-site scenario.
So as you can see techpostal.com is ready on GCP.
There are multiple ways to do performance benchmarking, and one of the easiest ways is to do from a cloud. I used Loader.io to put a load for 100 to 500 users for a one-minute duration, and the results are:
Average response time = 597 ms
Max response time – 1.4 seconds
I know this is basic WordPress setup and require to install additional plugins, add security, SSL certificate, etc. in a production environment. But that would increase the load time by few percentage.
I hope this gives you an idea how to setup WordPress on Google Cloud Platform to serve over 100 users concurrently per minute.
This requires a little bit of time to setup and skills, but if you would like to save $$ per month, then I believe it’s worth it.
Alternatively, if you don’t have time to setup or manage WordPress and at the same time want to enjoy Google Cloud.
- Advanced Ways to Improve Your Site’s SEO - September 29, 2017
- How to Optimize DotNetNuke speed by improving page load, caching and use of CDN - September 28, 2017
- How to solve Joomla is not able to install the extensions - September 27, 2017