Home / 

Looking for ways to reduce cloud costs? Every organization strives to adapt the techniques that will enable them to achieve supremacy in optimizing cloud costs. One of the best cloud cost optimization strategies is the adoption of preemptible virtual machines (VMs) on the cloud. An intriguing fact about these preemptible VMs is that they cost 80% less than the regular instances and, hence, can help in achieving the desired cloud cost optimization.

An Overview of Google Cloud Preemptible VMs

A preemptible VM is an instance that can run on a lower price and shorter duration, which is usually counseled for fault-tolerant applications and batch job executions. Preemptible VMs are the latest services in the Google Cloud and are available at low prices. Google can shut down these VMs within 24 hours without necessarily notifying the user.

Using Google Cloud preemptible VM instances, you can reduce costs by autoscaling the VMs depending on their workloads. If you are using preemptible VMs for processing batch jobs, they will slow down the batch job without stopping completely. Create preemptible instances in managed instance groups that will allow you to process the batch jobs and fault-tolerant applications easily.

Preemptible instances can be used for basic operations in lower-level environments like development and quality assurance, where the availability of instances is insignificant. These instances can also be used for batch jobs as they do not need to be available all the time.

The preemptible instances are used actively for one of our clients. It is a US-based Fortune 500 departmental store chain with over $20B annual sales, more than 1000 offline store, and manages a huge e-commerce platform. The client needs to perform multiple batch jobs for smooth functioning of the e-commerce portal and was incurring a lot of cost. We used preemptible VMs for Dev, QA, and Release environments to save cost.

Google Preemptible Architecture Diagram

Difference Between Preemptible and Non-Preemptible VMs

Preemptible VM Standard Instances
A unit of preemptible resources is allotted for a restricted time. The VM will be active until the process is complete / changed / stopped.
The waiting and interval periods are extremely less. The waiting and latency periods are extremely high.
There may be interruptions between the process. The process cannot be terminated until it is complete.
Preemptible programming is versatile. Non-preemptible programming is faster.
In preemptible programming, the running method can be replaced by the next priority method at any time. In non-preemptible scheduling, once the CPU is allocated to the process, it keeps the CPU until it releases or switches to a waiting state.

A Use Case for Google Cloud Preemptible VMs

The main objective of using preemptible VMs is to save up to 80% of the cost compared to the regular on-demand virtual machines. Similarly, AWS users can use a Spot Instance and Azure users can utilize low priority VMs. Preemptible instances are not appropriate for long-running services, such as a database, webservers, etc. However, they are good for batch job processing and building agents as a part of your continuous integration/continuous delivery (CI/CD) infrastructure and short-lived processes, code testing frameworks, or things that do not seem to be imperative and may be done at any time like money modeling, rendering, and encoding.

A Comparison between GCP Preemptible Instances and AWS Spot Instances

GCP Preemptible Instances AWS Spot Instances
80% cheaper than regular standard instances. The price is fixed with no bidding. Specify the price that you are willing to pay per hour. If the spot instance price is below your bidding price, you can use that instance until the spot instance price is above your bid price.
While creating preemptible instances, you must specify configurations like VM size, networks, firewalls, SSH keys, zones, and regions. When you submit a spot instance request, you must specify configuration details like instance type and availability zone.
These instances shut down after 24 hours. However, they will still be shown on the Google Cloud Console in the terminated state. You must prepare for interruptions - when the spot instance price is above your bidding price, the instance will be terminated.
They can be used with managed instance groups for auto-scaling. They are integrated with auto-scaling configuration.
If a preemptible instance gets terminated, the compute engine will try to launch the new instance as a replacement. With EC2 Spot Fleet feature, user can bid and launch a bunch of EC2 instances with a single API request. Even though Spot Instance prices will change, Spot Fleet will try to maintain the desired instance capacity.

Preemptible VM Instances for Non-Production Environments

Preemptible VM instances can only be used in non-production environments, and not in production environments, since the preemptible VMs are capable of terminating and creating a new instance. Autoscaling can help in producing a new preemptible VM once the CPU usage reaches its user-defined limit. While deploying the instance, you must define if it is preemptible or not in the settings. The preemptible VMs can terminate within 24 hours after completing the job.

Preemptible VM instances are not as secure as traditional VM instances. Google Kubernetes Engine behaves like a managed cluster instance. Preemptible VM instances in Google Cloud Kubernetes is a unit subject to constant limitations as a preemptible instance in a managed cluster instance. Node preemption is capable of shutting down the Kubernetes pods forcefully without notifying it.

The Process of Creating Google Cloud Preemptible VMs

You can create Google Cloud preemptible VMs by using a Google Cloud console and SDK command-line tool. The creation process is the same as creating a standard VM. You need to select configurations (VM size, networks, firewalls, SSH keys, zones, regions) of the VM and make a slight modification in the setting by selecting ‘true’ for the preemptible flag. You must also create a termination script to determine what happens to your processes and information if the instance is stopped without your knowledge.

One of the advantages of Google preemptible VMs is their ability to connect native SSD drives and GPUs to the instances. This feature helps in getting additional extensibility and performance for the process that you are running while saving your cost. You will also have preemptible instances in an exceedingly managed instance cluster for better quantifiability. This process will assist a lot of your jobs promptly once your preemptible VMS start running.

Google Cloud Preemptible VM Pricing

The prices of Google Cloud preemptible VMs are fixed. You'll get on-demand costs of the preemptible VMs in Google’s figure-evaluation list and/or evaluation calculator. The on-demand prices are usually 70-80% off and even more for a 3-year usage commitment. Google Compute Engine charges based on the usage and type of VMs as per the Google Cloud pricing sheet.

Conclusion

The organization that wants cost-efficient use of Google resources typically combines Google preemptible VMs with different supported instances. It is recommended to opt for preemptible VMs as they can help in leveraging most out of the cloud with minimal efforts as they don’t require any architectural changes and are easy to implement.