4

A working guide to understanding Google Compute Engine Pricing Options — Part 1

 3 years ago
source link: https://rominirani.com/a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

A working guide to understanding Google Compute Engine Pricing Options — Part 1

This is series of articles that I plan to write to help understand the various pricing levers that you have in Google Cloud Platform’s core compute offering : Google Compute Engine. I plan to explain this vis easy to understand and practical examples with the help of the Google Cloud Cost Calculator, that is available publicly.

Let’s get going.

Google Compute Engine provides a core infrastructure component : Virtual Machines (VM). These VMs are classified into different families

  • General purpose
  • Memory Optimized
  • Compute Optimized

Each family has various machine types. How do you select which machine type, what kind of workloads are they best suited for? You can use this guide as a start for the same:https://cloud.google.com/compute/docs/machine-types and I produce a screenshot from there that covers the various workloads that are best suited for which machine types.

0*lQu3Fu5xPGo6ZjSl?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

Each of the machine types (e.g. N1 general purpose) will have several *fixed* or *pre-defined* configurations (instance types) of VPU and RAM. You can choose the appropriate instance types depending on your requirements.

A set of instance types for N1 (General purpose) machine types is shown below:

0*_LaI_GDDpAVbe7B-?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

An important thing to consider when you choose a machine type is whether it is available in the GCP Region (actually zone) since VMs are zonal resources.

Check out the list of regions that GCP is available in and more importantly, the availability of machine types per region. Bookmark this since this can change. https://cloud.google.com/compute/docs/regions-zones

0*J0yqH9EGGCyMknb2?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

VM is a rented resource and hence you are charged for the time that you use the Virtual VM. Let’s qualify that. You are charged for the amount of time that you keep a VM in running state. If a VM is stopped, you are not charged for it. https://cloud.google.com/compute/vm-instance-pricing

Is there any minimum charge and then charged by second/minute/hour — whats the granularity by which you are charged? I reproduce this from the official documentation linked above:

  • All vCPUs, GPUs, and GB of memory are charged a minimum of 1 minute. For example, if you run your virtual machine for 30 seconds, you will be billed for 1 minute of usage.
  • After 1 minute, instances are charged in 1 second increments.

Each VM instance type has a pricing associated with it i.e. per hour pricing. As you consider higher vCPU and more RAM, the pricing inches upwards. Take a look at pricing for N1 instance types (https://cloud.google.com/compute/vm-instance-pricing#n1_predefined).

Remember* the prices are not the same in each region. When we get to using the Google Cloud Calculator in a while, ensure that you choose the correct region for the pricing to avoid any surprised.

In the screenshot below, you will find that there is a dropdown for the region that you can select and see the prices.

0*se9ZwqHRtcHvFoiw?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

The pricing is classified into:

  • On-demand price
  • Preemptible price
  • 1 year commitment price
  • 3-year commitment price

This can be confusing but let’s understand it with an example that we shall work through with the help of the GCP Cost Calculator. We will also throw in some other variations.

Our Running Example

First up, we will finalize that we are interested in provisioning a Compute Engine VM instance type (n1-standard-1), which has the following configuration:

vCPU     : 1
RAM (GB) : 3.75 GB
Region : Mumbai
OS : Free (Linux)

Remember that I mentioned that GCP charges you for duration that you keep the VM running. So you run it 24 x 7 i.e. 7 days a week and for 24 hours a day i.e. you keep the VM running. GCP charges you by the rate per hour for that instance type.

But do consider that not everything needs to run 24 x 7. For e.g. consider organizations that have a development , test and production environments. Sure the production environments run 24 x 7 but my development / test environment might only run for 5 days a week (Mon-Fri) and 8 hours a day (9:00AM — 5:00 PM).

So I should be charged less right ? Correct. Let’s go step by step.

First up, we will use the GCP Cost Calculator available at (https://cloud.google.com/products/calculator) and see what it costs to run this VM.

Visit the URL and enter the values as:

# instances : 1
OS : Free
Series : N1
Machine Type : n1-standard-1
Region : Mumbai

Ensure that you select 24 hours per day and 7 days per week as shown below. Click on “Add to Estimate”

0*F8H0Pu3gplheWDeW?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

This will show the pricing to you on the right side:

0*C6FOqedK7KphymGG?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

Note 3 things here first:

  • The pricing is for the full month : 730 hours per month i.e. your VM is in running state throughout the month.
  • You can change the currency to one that you want. This is very useful to share with clients that would like to be billed or want to see what it costs for them in their currency of choice.
  • You can email this estimate or even click on Save Estimate to get a URL to share and keep collaborating on the pricing.

Notice one of the entries in the billing details “Sustained Use Discount : 30%” . What is going on here? Google Cloud provides an automatic discount (upto a certain %) off the list price, when you use the VM for more time , in our case the full duration of the month.

The more you use, the more discount you get. Check this graph out.

0*T7mvERAvpZIzqt-l?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

If you use it for just 15 days a month, we still give you a % discount. This is Sustained Use Discount (SUD) and it is covered here: https://cloud.google.com/compute/docs/sustained-use-discounts

That’s great , isn’t it ? No need to do complex calculations — we pass on the discount as per your usage.

What about Developer and Test Environments?

Next up, remember the dev and test environments? What if you wanted to run this for the following:

  • 5 days a week (Monday — Friday)
  • 8 hours a day

Let’s click on the Edit button for the pricing as shown below. This will populate the entries in the form of the GCP Calculator, where you can then tweak any settings.

0*TaEtMRR94d7APYbD?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

Now go ahead and change the values as shown below:

  • 8 hours per day
  • 5 days per week

And click on “Add to Estimate” again.

0*B0PZTl0z5lgxXJ6o?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

This will bring up the revised pricing as shown below:

0*ruG8yh0I2Rddjr3_?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

That’s a nice discount , isnt it ? So always plan out your different environments (Production, Development , Testing) and how long the VMs need to be running.

Don’t pay for resources that are idle and you are not using. Best Practice : https://cloud.google.com/compute/docs/instances/schedule-instance-start-stop

What are Committed Use Discounts (CUD)?

Now, what let’s come to Committed Use Discounts (CUD). If you are willing to commit to running these instances all the time for a period of 1 yr or 3 yr, Google Cloud can give additional discounts. Read about CUD here (https://cloud.google.com/compute/docs/instances/signing-up-committed-use-discounts )

Let’s see how to do that in the calculator. Let’s edit the previous entry back to running it 24x7 , so that the total is shown as below. This time, we will also label this line item as : SUD Server.

0*HmfueBoo32814CVN?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

Next up, add another VM resource with the following:

# instances : 1
What for : CUD-1yr
OS : Free
Series : N1
Machine Type : n1-standard-1
Region : Mumbai
Committed Use Discount : 1 yr

Click on “Add to Estimate”

Next up, add another VM resource with the following:

# instances : 1
What for : CUD-3yr
OS : Free
Series : N1
Machine Type : n1-standard-1
Region : Mumbai
Committed Use Discount : 3 yr

Click on “Add to Estimate”

This will bring up the following pricing and you can see how it is beneficial to go for CUD pricing, if you plan to commit to GCP.

0*EZGtrdFixa6xz8e2?q=20
a-working-guide-to-understanding-google-compute-engine-pricing-options-part-1-d71f2cf2bd14

Hope this was useful.

I plan to cover more some nuances next on Compute Engine pricing vis-a-vis Custom Machine Types and Preemptible VMs in another thread.

Till then, Happy Pricing !


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK