Abdul Rehman
Abdul Rehman

Reputation: 5684

Setup Autoscaled site on Google Compute Engine for WordPress

I'm trying to build an autoscaled infrastructure for a WordPress site on Google Compute Engine. For WordPress, I want to use the LEMP(Ubuntu-18, Nginx, Mysql, PHP) stack but with a separate Cloud SQL instance as Database.

Here's my plan:

  1. Create a Boot disk with the WordPress site installed & setup
  2. Create an Instance template from that Boot Disk
  3. Create Instance Groups for my required regions with the Template above.
  4. Create an HTTP Load Balancer to autoscale the instances.

But, I'm really confused at the first step, how I should set up for WordPress site to create an Instance Template, I don't know how can we set up our Apps on Custom Image OR Boot Disk.

Is the approach above is the right one? How can I set up my WordPress site to use in an Instance Template?

Help me, please!

Thanks in advance!

Upvotes: 0

Views: 398

Answers (1)

Kamran
Kamran

Reputation: 3537

Autoscaling feature of managed instance groups is usually applicable to stateless VM instances. An autoscaler adds or removes instances from a managed instance group. Therefore, any data stored on root disks of VMs can be lost.

As you specified in your plan, the stateful component of your LEMP stack (Databases) has to be implemented outside of the managed instance group.

To create a template for the managed instance group, you can take the following steps:

  • Setup, configure and test your website on a single VM (stateless components) which is configured to connect to Cloud SQL instance (stateful component).
  • Create a custom image from the VM's disk

    gcloud compute images create [IMAGE_NAME] --source-disk [SOURCE_DISK] --source-disk-zone [ZONE]
    
  • Use this custom image to create an instance template for your managed instance group

These steps can be done by using gcloud command or Google Cloud Console.

Upvotes: 1

Related Questions