Scaled VM: Part 1. “Just scale my VM!”

Valentyn Shybanov
3 min readSep 23, 2017

How to create the most simplest auto scaling solution in the Google Cloud.

“I have VM that works perfectly and I can install whatever I like there. Can you just scale it up?”

Not so long ago one my business partner asked me to suggest some auto scaling solution for hosting web sites. Not surprisingly, requirements were to make it cheap but able to scale in case of sudden raise of requests.

The stack of technologies that where used was quite typical: Apache2, PHP and MySQL.

TL;DR: Short list of steps needed to be performed to have described solution.

So let’s see what are the options and the solution.

[Part 1: introduction] [Part 2: FS/VM] [Part 3: Web] [Part 4: Load Balancer] [Quick walkthrough]

PaaS solution (AppEngine)

First try was to use PaaS (Platform as Service), as Google AppEngine has quite good support of PHP. As the replacement of MySQL we could use CloudSQL.

Pros:

  • Auto scaling out of the box: no need for any additional configuration. Just drop your code and it works.
  • Auto scaling can go down to 0. So in case if for some period of time nobody is using your service, you are not billed.
  • No any maintenance — everything is fully managed. You have a code, Google provides and manage environment to run that code. That’s it.

Cons:

  • No FTP/SFTP/SSH: For people who used to work with hosted solutions it is very hard to understand “deployment” principles. You can’t just FTP/SSH to your server and change files. You need to deploy.

“Scaled VM”

You can explain a lot about distributed systems, “cloud nature”, VM templates, but you will still hear back “With VM it was so easy — I just SSHed there and modify files”. If enterprise-sized projects can’t leave without Continuous Integration/Continuous Deployment, small and medium sized projects will still need VM-like access and management.

So I decided to provide same VM-like features for autoscaled instance group. Here is a high-level diagram:

You need to configure your instances to use files and configuration from mounted NFS partition from filer and then just provide access to filter — and you’re done!

There are some things that still differs from “normal VM”:

  • You can’t install CPanel or other things that automate OS management. Because there is no OS to manage — you can’t create users, maintain OS-level configurations etc.
  • You can change files. But to install system-level modules (e.g. Apache modules, PHP modules etc.) you need to configure instance template.

In the next articles I’ll explain how to setup configuration above, starting with Part 2: How to setup shared FS and VM Instances.

--

--