How to optimize and save money in Microsoft Azure
It’s critical for businesses to keep costs under control or even at a minimum. Sometimes, the cost of a cloud architecture, more specifically Microsoft Azure cost, can represent a significant proportion of total operating expenses. Thus, minimizing the cost of cloud resources is one of the key success factors for anyone whose business depends on services deployed in the cloud.
In this article, we’ll look at a strategy that will help you optimize your use of Microsoft Azure cloud resources and save your money.
Why do you spend money in Azure?
The main feature of cloud architecture pricing is that the total cost of ownership (TCO) is significantly lower than on-premises data centers. This is due to the lack of capital expenditures on the data center, hardware, and maintenance staff. Fully managed and PaaS services further reduce labor costs.
However, operating costs for cloud infrastructure are not fixed. These costs include the cloud resources needed for your solution, as well as resources that are not needed but consume money.
There are 4 ways unwanted redundancy can occur:
- Using the wrong service for your application.
- Using the wrong pricing model for your service.
- Misconfigured sizing or scaling.
- Leaving services running which should be turned off.
Let’s look at a common algorithm for saving money in Azure by identifying and eliminating these causes.
Microsoft Azure Cost Optimization Strategy
Our Microsoft Azure cost optimization strategy, in a simplified form, consists of the following stages:
Stage 1: Analysis of existing infrastructure
- Resources should be logically grouped into the resource groups and enriched by the metadata in tags.
- Monitoring should be configured on all system hierarchical levels: Azure Core Monitoring, Infrastructure monitoring and, if needed, on the deep application monitoring level.
- Cost allocation and resource allocation should be analyzed based on collected data for all resources and logical groups of resources.
Stage 2: Cost optimization of Microsoft Azure cloud resources
- Unutilized resources must be removed. Even if they do not consume money, a large amount of resources in a subscription makes it difficult to analyze the overall picture and analyze Microsoft Azure cost.
- If an instance of a cloud service is rarely used and, most of the time, remains in idle state, you can configure it to automatically shut down and turn on. Or consider using serverless or PaaS hosting instead, where the pricing depends on the actual number of calls to the resource (for example, Azure Function instead of a VM service, or Azure Container Instance instead of an AKS or Azure AppService).
- In the case that a cloud service is in constant use, but its load is unpredictable and varying widely, then automatic scaling must be configured.
- In the case that a cloud service is used continuously and the workload changes predictably(e.g., increasing during working hours on weekdays and minimizing the rest of the time), it is possible to configure schedule-based scaling. If a resource is used continuously without significant changes in load, the following improvements are possible:
- Detailed monitoring will allow you to accurately select the pricing tier of the resource when it fully meets the performance requirements and set of necessary properties.
- For some of the services, if they are used for a long time (a year or more), e.g., for Azure VM, it is possible to move away from the pay-as-you-go model in favor of the reserved model with a significantly lower final cost.
- Utilization of the license and subscription benefits (for instance, the Azure Hybrid benefit).
Stage 3: Cost optimization of Microsoft Azure subscription as a whole
- Choose the right region (or regions) that meets your business requirements and has the lowest resource costs. Maximize traffic inside Azure Datacenters and minimize data transfer outside them.
- Use the benefits of existing licenses and discount programs such as Visual Studio subscriptions, dev/test pay-as-you-go, and others.
- Choose the right level of support for production and non-production Azure subscriptions.
Now, let’s look at how to implement these stages for specific Microsoft Azure services.
Resource organization and monitoring
Before doing anything, you need to know the current status of your cloud solution. This means having a clear picture of what services are used, what they are used for, who created them, and who owns them. In Microsoft Azure, there is a Resource Group for logical grouping of resources and it is also possible to add metadata to each resource using tags. If these grouping elements are missing, you should at least add tags. Tagging resources will help you secure Azure cost analysis by tag.
Next, you should use the core Microsoft Azure monitoring services that allow you to get insight into Azure Subscription, namely Azure Cost Management and Azure Advisor.
The Azure Cost Management service allows you to identify the most expensive cloud resources or groups of resources, visualize the distribution of cost per resource, and identify trends. The dashboards of this service will allow you to drill down and identify the most likely candidates for optimizing the cost of cloud resources.
The Azure Advisor service can provide the most obvious and quickest way to implement recommendations regarding security, performance, and cost optimization. For example, Azure Advisor may recommend changing the size of the VM if its resources are underutilized or activating the automatic shutdown of VM.
In order to better understand the infrastructure or, more specifically, to identify the trend in the use of virtual machine resources and databases, as well as to check the actual use of PaaS services, you should configure and apply the Azure Monitor.
Microsoft Azure cost optimization for Virtual Machines
Now, let’s consider how the recommendations from Stage 2 can be applied to optimize cloud services for IaaS resources – Azure Virtual Machines.
All VM instances have a built-in automatic shutdown feature that allows you to disable virtual machines at specific times.
In order to automate the activation of virtual machines or implement more complex logic to start and stop them (for example, on non-working days or when certain business conditions occur), you can apply the service Azure Automation.
For those cases where computing resources are required irregularly and rarely (e.g., dev, tests, batch jobs, VM Scale sets, etc.), instead of using the usual virtual machines with the pay-as-you-go pricing model, you can use Azure Spot VMs. However, in this case, you must remember that the virtual machine can be deallocated (the process depends on the VM eviction policy) if the maximum VM price on the spot market rises above the current spot price you set.
For those cases where long-term computing resources are required, it is possible to use Reserved VM Instances with a one or three-year reservation.
Microsoft Azure cost optimization for managed services
The peculiarity of PaaS service pricing tiers is that often different levels have a different set of features and limitations. However, the recommendations described in Step 2 can also be used for PaaS. For example, the Azure SQL service has different pricing methods. For the vCore model, the number of cores can be adjusted while, for the traditional Basic / Standard / Premium model, sublevel variations are possible within each level. The same can be applied to the optimization of Cosmos DB.
The correct price level can be selected and set once if the load on the database is almost constant. Or, you can choose to automate switching between price levels using the Azure Automation service. If the database load is unpredictable, you can apply the Serverless pricing model.
Sometimes, it is possible that Azure SQL database instances are used independently and unevenly by many clients. In this case, in order to use allocated resources more efficiently rather than using a set of separate independent databases, it is possible to combine them into an Elastic Database Pool. In doing so, computing and storage resources become allocated to the entire database group and are used more efficiently.
When it comes to data storage in Azure Blob Storage, it is possible to configure Lifecycle management, built into Azure Blob service, to optimize costs. This allows you to configure the movement of files from levels optimized for high availability (Hot) to levels optimized for storing large volumes of files at a lower cost and availability (Cold and Archive).
Ready to optimize your Microsoft Azure cost?
In this article we’ve covered the general algorithm for optimizing the cost of cloud resources and looked at some specific techniques for saving on Microsoft Azure services.
Generally, the optimization of cloud architectures, especially hybrid architectures, is a complex but necessary process. The result of such optimization will directly impact your business by reducing infrastructure operating costs.
Talk to our experts and they will help you create and implement a cloud resource cost optimization plan that works for your business. We’ll walk you through all the steps and, most importantly, save you money!
Don’t hesitate — contact us today at firstname.lastname@example.org.