简体   繁体   中英

How to autoscaling VM in Google Cloud Platform for WordPress site

We are running a VM on GCP with 8GB ram and when traffic spike, the server crashed due to out of memory. We are thinking autoscaling VM instead of adding more memory to the VM.

Then I found out we need to set up a load balancer and build instance group with instance template.

My question is does it works for Wordpress site which we keep adding the contents every day. How the autoscaling work for that situation?

Also, I found the monthly cost for setting up a load balancer is more than I add 2GB ram extra on the VM.

Any idea, how to handle the traffic spike on WordPress site?

Thanks!

To handle bursts of traffic for Wordpress you have several options:

  1. Pick an instance size that can handle the traffic bursts. This may or may not be cost efficient. Just depends on how large of a difference you have between steady state traffic and peak traffic.
  2. Implement content caching. Select a caching plugin to cache pages that do not change. This can decrease CPU and MySQL query traffic significantly. However, add more memory to your instance so that caching does take away memory for MySQL.
  3. Implement load balancing, auto scaling, static Wordpress machine images and move MySQL to a separate instance or service. This is the best setup for Wordpress.

The key is to understand how Wordpress creates a web page. In most cases, Wordpress issues multiple queries to MySQL for content. This creates a lot of I/O. If your instance is small and short on memory, MySQL will not be able to cache your database content in memory. This means increased disk I/O. If during steady-state traffic your setup keeps data in MySQL cache memory and then during peaks MySQL is forced to go to disk, you site can become very slow or unresponsive. This is a metric that you want to figure out for your site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM