Maximize Cost Savings in Azure

Maximize Cost Savings in Azure

In the last decade, I was part of some consulting assignments with our customers for Cloud Adoption.  Quick and easy setup, no maintenance, no long-term contracts, High flexibility, and Maximum uptime are some of the key benefits we used to influence business to move to Cloud.  While I advocate for Cloud adoption and cost savings because of it, one of our new customers who already migrated to Azure came to us with a different requirement.  They want to maximize cost savings in Azure. 

Their cloud expenditure grew from 100K USD to 500K USD per month in a span of a year.  At the beginning of the year 2019, only 10% of their applications were in Cloud.  Now almost half of their application portfolio is moved to Azure.  The increase in cost is also because they migrate their applications consistently to Cloud and deployed some brand-new applications.  They want a solution to this before the entire application landscape is moved to Azure.

Background

A little background on the original migration started in 2019.  They have an internal deadline to move all their applications to Azure before a certain date.  There is also a rule to design all the green field applications for Cloud and there are a lot of legacy applications in the enterprise which are not compatible with PaaS.

This typical requirement motivates me to write this post on how to maximize cost savings in Azure.  After the analysis of the resources and the technology landscape, I came up with a list of topics.  Some of these points need to be looked up during the migration planning and some after the migration.  I will also talk about the tools and functionalities provided by Azure to help achieve the desired cost savings.

Before Migration

Choose the Right Cloud Service (IaaS, PaaS, or Serverless)

Choosing the right flavor of cloud service can really help you modernize the IT stack and allows you to reduce the cost significantly.  The selection between these offerings depends on a lot of things.  I tried to list a few of them.

  • Timeline the organization decided to migrate to Cloud
  • Legal requirements (mostly related to data like GDPR etc.)
  • Services provided by the preferred Cloud provider
  • Legacy applications (e.g. Mainframes, Lotus Notes, PowerBuilder, etc.)
  • Integration concerns

PaaS pricing is always cheaper than IaaS.  When possible, use the platform as a service (PaaS) rather than infrastructure as a service (IaaS).  IaaS is like having a box of parts.  You can build anything, but you must do it yourself.  On the other hand, PaaS offerings are easier to configure and administer.  You don’t need to provision VMs, setup VNET, manager patches and updates for the VM.  You can also explore Azure Functions (Serverless) and move towards a true serverless architecture.

Choose the right datastore

Choosing the right data store is a key design decision.  With Azure, you have a lot of options to go with.  You must carefully analyze the business requirements and select the storage technology that is the best fit for your data.  Remember that data includes more than the application data.  It also includes your cache, messaging, images, files and application logs.

Consider the following to keep the cost of storing data under control

  • Understand the type of data
  • Pick the right redundancy option
  • Utilize Azure Storage Reserved Capacity
  • Select between Premium, Hot, Cool and Archive tiers

Application modernization strategy

As part of the portfolio analysis, you need to carry out a deep dive analysis of each application in the landscape to determine the best method to take full advantage of long-term benefits, considering time, cost and impact on the business.  You should carefully choose from one of the following options. 

Re-Host: Commonly called lift and shift migration, it is the fastest and easiest method to move any application to the cloud.  No changes will be made to the underlying application.  This is the most common migration technique uses to migrate legacy applications that were not designed for the cloud.   

Refactor: Refactoring an application is like rehosting, but it includes code changes to some of the components to fit a PaaS based model. 

Rearchitect: Rearchitect the applications that aren’t compatible with the cloud.  This involves restoring the codebase and move towards a Cloud-Native based architecture

Rebuild: Develop the application from scratch to align with the Cloud Native approach. 

Replace: Replace the current application with a SaaS offering or COTS product.

Cloud rationalization

Post Migration

We can control the cost mostly if the application is migrated by following the azure design principles.  But there are some factors that the team might not have complete control during the migration.  It may be an issue with the project deadline, budget or limited information on the business objectives and non-functional requirements.  We will see some of the actions you need to take to reduce the cost and keep it in check.  You need a baseline of your cloud spends to start.  This exercise must be iterative, and you should compare the cost savings for every iteration.  Ideally, the percentage of the cost savings will go down gradually when you move towards the exercise.

Opportunities to reduce Azure costs

Azure Reservations

Azure Reservations help you save money by committing to one-year or three-years plans for virtual machines, Azure Blob storage or other Azure resources.  Buying a reservation can significantly reduce your resource costs up to 72%.  You can pay up for a reservation monthly or upfront. 

To be eligible to purchase a reservation, you must have a subscription owner role in an Enterprise or Pay-As-You-Go subscription.  You can scope a reservation to a subscription or resource groups. The cost in the below table is calculated with the help of the Azure Pricing Calculator. The region used is “East US” and the costs are monthly.

Pricing ModelD2 V3 VMAzure SQL + RA-GRSAKS – D2 V3
Pay as you go$152.57$371.87$70.08
1 year reserved$125.08$294.13$41.75
3 year reserved$104.21$249.63$26.89

Azure Reservations

Customized Azure pricing for Enterprise customers

Enterprise agreement offers discounts over pay-as-you-go subscriptions.  It minimizes Azure upfront costs by locking in pricing.  EA customers will get benefitted either the price goes up or down.  If Azure prices go up for a specific service, EA customer’s pricing will not change. If Azure prices go down, Microsoft will automatically pass on the applicable pricing levels and adjustments to EA customers.  Enterprise customers are also entitled to additional offers such as Azure HUB, IoT suites and other Azure plan SKUs release in the future.

Enterprise Agreement Benefits
Source – Microsoft Docs

Azure Dev/Test Pricing

This feature is available for Enterprise Agreement customers.  It provides discounted rates on Azure to support your ongoing development and testing.  Some of the benefits provided are

  • No Microsoft software charges on VMs
  • Significant dev/test pricing discounts on a variety of Azure services
  • Access to Windows 10 VMs

Azure Reserved Instances

This significantly reduced costs up to 72% compared to pay-as-you-go prices with one year or three-year commitment on Windows and Linux VMs.  While this requires upfront commitment, Microsoft also provides flexibility should your business needs change.  You can cancel an Azure RI at any time for an early termination fee.  Azure RI can be assigned at the enrolment or subscription level, so you can manage the usage across the organization or at the department level.

Reserved Instances

Reserved Instance with Azure Hybrid Benefits
Source – Microsoft Docs

Azure Storage Reserved Capacity

Azure Storage reserved capacity offers you a discount on the capacity for block blobs and for Azure Data Lake Storage Gen2 data in standard storage accounts when you commit to a reservation for either one year or three years.  You can apply reserved capacity pricing to a single subscription or across multiple subscriptions.   You can cancel the capacity anytime and receive a prorated refund.  The reservation can be changed to another Azure region, deployment type, performance tier, or term as needed.

Reserved Capacity

Migrate to Azure PaaS

Some of your applications may have specific requirements that make an IaaS approach more appropriate. However, even if your application is based on IaaS, look for places where it may be natural to incorporate PaaS options.  Following are some of the options to start with

Current Target
Message Queue in an Azure VM Azure Service Bus
Elastic Search Azure Search
Hadoop HD Insight
IIS App Service
Mongo DB Cosmos DB
Redis Azure Cache for Redis
SQL Server Azure SQL Database

Use the right resource size

Choose a VM size that matches your expected needs for CPU, memory storage, and I/O bandwidth.  There are literally dozens of different types and sizes.  Depends on the business requirement, you can go for Compute-optimized VM or Memory-optimized VM or Storage Optimized VM or other types.  As I mentioned earlier, there is a big list of available VMs to choose from and the cost will significantly vary between these options.

It’s a tough job to predict the right size for the VM when creating it.  You can schedule a periodic review to check the metrics that the application under load generates.  You can then resize those overprovisioned VMs.

Azure B-series Virtual Machines are ideal for workloads that do not need the full performance of the CPU continuously, like web servers, proof of concepts, small databases, and development build environments.  B-Series VMs are designed to offer that burstable performance when needed.  Careful consideration is required before you convert your workload to B-series deployment.

Deallocate VMs

A significant cost can be saved by shutdown the VMs when not in use.  The reason this works is that the CPU, Memory and other hardware reserved for the VM will be released upon deallocation.  The ideal place to start this exercise is from your non-production VMs. 

Assume, you have an Azure VM Instance of type D16a V4 (16 vCPUs, 64 GB RAM, 400 GB Temporary storage).  I came up with the calculations for 3 different pricing models for 1 year.  If the VM is available 24 X 7, 12 hours on all days and 12 hours only on weekdays.

Pricing ModelCost / Hour24X712X7 – Cost12X7 – Savings12X5 – Cost12X5 – Savings
Pay as you go$0.7680$6,727.68$3,363.8450%$2,405.3872%
1 year reserved$0.4576$4,008.58$2,004.2950%$1,433.2072%
3 year reserved$0.2947$2,581.57$1,290.7950%$923.0072%

Note:  The cost savings mentioned in the above table are approximate.  Though you deallocate the VMs, you will still be incurring charges for the attached storage.

Imagine your non-production environment have multiple VMs, the savings would be huge.  Other possibilities to maximize the savings are

  • Start the VM only during office hours or when necessary
  • There are VMs that are only needed a certain amount of time in a week/month
  • Deallocate VMs during holidays

Deallocate VMs

Delete unused resources

Managing costs in Azure begin with monitoring your usage.  Be it a VM, Storage or an App service, you need a monitoring solution to review the cost of your Azure services every month. 

  • Did you get the storage deleted after you delete the VM?
  • Do you have Azure VM backups in Recovery services vault, which is no longer required? 
  • Do you have a resource that serves no function in any of your applications?

If carefully done, this exercise would provide a large cost saving without any impact.

Monitoring your usage and spending is critically important for cloud infrastructures because organizations pay for the resources they consume over time.  Azure Cost Management can be used to gain greater insights into where your cloud money is going.

Switch Region

Not all the Azure regions have the same pricing for the same resources.  The cost of Azure resources varies from region to region.  Not all workloads can be moved to another region blindly.  A careful study needs to be done on the business and regulatory requirements.  You may not able to find the same resources across the region as well. 

Assume, you have an Azure VM Instance of type D16 V3 (16 vCPUs, 64 GB RAM, 400 GB Temporary storage). 

Pricing Model Australia Central Canada Central Central India South India Japan West
Pay as you go $1,267.28 $1,185.52 $1,150.48 $1,381.16 $1,290.64
1 year reserved $995.11 $909.28 $893.94 $1,038.61 $1,012.28
3 year reserved $844.70 $778.84 $762.22 $853.47 $861.17

Data redundancy option and Access Tier

When deciding which redundancy option is best for your scenario, consider the trade-offs between lower costs and higher availability and durability.  Validate your business requirement by asking the following questions.

  • Does the application require data replication?
  • Does the data need to be replicated to more than one region?
  • Does the application need read access from the secondary region?
  • What is the acceptable outage limit?
  • What are the Recovery Time Objective (RTO), Recovery Point Objective (RPO), and Maximum Tolerable Outage (MTO)?
  • Is the data frequently accessed or rarely accessed?

See the cost difference between the redundancy options and access tier for Blob storage with Standard performance tier in the East US region.  I didn’t change the number of operations and used the default ones.

Tier/Zone LRS ZRS GRS RA-GRS
Hot $21.84 $27.29 $67.84 $80.94
Cool $26.80 $30.73 $71.50 $75.60
Archive $422.49   $446.09 $446.09

Note – This is only for the pay-as-you-go model.  You will get a good discount with other models

Azure Storage Redundancy

Elastic Pools

SQL Database elastic pools are a simple, cost-effective solution for managing and scaling multiple databases that have varying and unpredictable usage demands.  The price of an elastic database pool is based only on the total resources allocated for the databases and is independent of the number of databases it contains.

Elastic Pools

Set Spending Limits

You can prevent unexpected charges by setting spending limits with Azure billing and cost management.  When your usage results in charges that exhaust your spending limit, the services that you deployed are disabled for the rest of that billing period.  You can also configure to receive email notifications about subscriptions that have reached the spending limit.  This option is not available for Enterprise agreement or Pay-as-you-go users.  It is available for Visual Studio subscribers.  For a detailed list please refer to this link.

Azure Hybrid Benefit

The Azure Hybrid Benefit is a pricing offer that helps you maximize the value of your existing on-premises Windows Server and/or SQL Server license investment while you are migrating to Azure. With it, eligible customers pay a reduced rate on Azure Virtual Machines (Infrastructure as a service or IaaS) and a reduced rate on Azure SQL Database (platform as a service or PaaS) and SQL Server on Azure Virtual Machines (IaaS).  You can calculate the savings across eligible VMs per month in Azure Hybrid Benefit Savings Calculator.

Use Azure credits

Visual Studio subscribers can activate a monthly benefit.  It offers $50 – $150 in Azure credits per month based on the subscription.  This credit can be used to try out new services and do small POCs.  This monthly credit is only for development and testing.

Use Azure Provided Tools

There are abundant tools provided by Azure that can help you with analyzing and auditing your current spending.

Azure Pricing Calculator – Use the Pricing Calculator to determine your costs based on your business requirements.  It is a nice tool for simulating and understanding what it would cost to use the resources under various considerations.

Pricing Calculator

Azure Cost Management – You can Monitor, allocate and optimize cloud costs with transparency, accuracy, and efficiency to maximize cloud potential using Azure Cost Management.  It helps you analyze costs, create and manage budgets, export data, and review and act on optimization recommendations to save money.  It Integrates with Azure Advisor to optimize cloud costs by taking advantage of reservations, rightsizing, or removing idle resources. 

Azure Cost Management

Azure TCO Calculator – The Azure Total Cost of Ownership (TCO) Calculator is used to estimate the cost savings you can achieve by migrating your application workloads to Microsoft Azure.  The calculators also give you the option to modify assumptions that best meet your business needs.  The TCO Calculator recommends a set of equivalent services in Azure that will support your applications. Our analysis will show each cost area with an estimate of your on-premises spends versus your spending in Azure. There are several cost categories that either decrease or go away completely when you move workloads to the cloud.

TCO Calculator

Azure Advisor – Advisor is a personalized cloud consultant that helps you follow best practices to optimize your Azure deployments. It analyses your resource configuration and usage telemetry and then recommends solutions that can help you improve the cost-effectiveness, performance, high availability, and security of your Azure resources.

Azure Advisor

Summary

I hope you find this post useful.  While we discussed a lot of ways to reduce Azure spend post-migration, it is advisable to do proper research and analysis on cost savings before the migration.  There are a lot of additional ways to save money on your monthly Azure spend, some of which are more complicated than others.  The reality is that to reduce costs, you must optimize usage.  The critical factor is to monitor usage and educate users appropriately.

Leave a Reply