DEV Community

Cover image for 10 Ways to Optimize your Azure cost
Sabari Rohith
Sabari Rohith

Posted on • Originally published at serverless360.com

10 Ways to Optimize your Azure cost

``In modern times, building and publishing an application has become very easy with Cloud-based deployment. Users don’t need to worry about infrastructure-related challenges like availability, reliability, scalability, etc. The cloud providers are responsible for keeping the deployment flow simple and intact.

Providing many advantages and coherence, the high cost incurred for such benefits is the downside. If the resources created in Cloud are not adequately audited or kept track of, it will quickly bring up the cost to double or triple the allocated budget. Some cases even drained a year’s tech budget in a month.

This article will help you understand some of the Azure Cost Optimization best practices.

1. Understanding the Resources by Tagging and Grouping

Azure Resource Groups are containers that hold related resources for Azure solutions. Creating resources under proper and more petite Resource Groups will help the users understand the purpose of the resources, which also helps in cleaning up the resources related to a new solution.

Many users need help creating proper Resource Groups before adding resources. As this is a one-time process, you can only do a little with the existing resources that are not grouped during the creation. For such scenarios, Azure Tags will be the right solution. Here is a guide from Microsoft for naming and tagging resources.

Once the resources are correctly grouped, it is easy to understand how the cost is distributed across the solutions. Visualizing and getting insights based on filters like Resource Groups, Types, Regions, and Tags are available at each Subscription level in the Azure Portal. For a better experience at the scope of multiple Subscriptions, try out Serverless360 Cost Analyzer, which is available for a 15-day trial.

Image description

2. Monitor the Cost and Act on Unintentional Spikes

Once you understand how the resources are distributed across multiple solutions and the cost it incurs, the next step is understanding the daily spent rate of your Azure subscriptions.

You can calculate the daily spent rate by taking the average day-wise cost for the last 7 days. Cost spikes due to yearly renewals like App Service certificates should be excluded so that you can arrive at the exact rate.

You can create budgets in the Azure portal or other third-party tools at a Subscription level. It would help if you had tools that support monitoring the cost at multiple Subscription levels. Serverless360 calculates the daily spent rate automatically while configuring cost monitoring.

Once the monitor is set up, you will be alerted whenever something goes off the chart. You can immediately check which resource contributed to the raise and act on it. If the raise is valid and the resources are created or scaled intentionally, you must calculate the daily spend rate again and monitor it. There are tools available to alert if the cost trend changes automatically.

Image description

3. Smart start/ stop or Deallocate Nonproduction Resources

Close to 70% of a month, the resources contributing to the nonproduction environments will run for no reason. Most resources can be stopped, scaled down, or deallocated during off-business hours or weekends, which can be achieved using 3rd party tools like Serverless360.

Image description

4. Identify and Remove the Idle Resources

While grouping the resources using Resource Groups and Tags, you could have identified the resources that serve no purpose and can be deleted immediately. For example, most of the time, disks associated with the VMs will be left idle while deleting the VMs; you can delete those disks.

You can find the unidentified idle resources by analyzing the consumption metrics like CPU and Memory percentage. You can remove the resources with zero consumption.

5. Reservations

Reservation is one big area where you can save up to 80% on the cost spent on resources. Microsoft Azure discounts resources based on usage commitment declared for 1 to 3 years. Reservation is not just about discounts; you can get a high-performing machine at a shallow price point. You can find the details about the reservations here.

6. Savings Plan

Savings plans are, just like reservations, a recent addition. You need to commit to the fixed hourly spent for 1 to 3 years and get up to 65% discount on it.

For Reservations, you need to select the VM sizes upfront for 3 years, which might be challenging for growing businesses as changing the size of the VMs in reservations comes with a hard limit of only up to $50K per year. Saving plans expect the hourly cost to be committed, and you can create VMs of any size within the committed limit.

The Savings Plan is supported for computing resources like Reservations. You can find the details about the Savings plans here.

7. Spot Instances

Spot instances are another offering by Microsoft Azure, where you can purchase the unused capacity of the VMs at a significant discount. These VMs are suggested for interruptible workloads, and you can get up to a 90% discount.

You can use Spot instances for Azure DevOps pipeline build agents, interruptible batch jobs, etc. You can find the details about the spot instances here.

8. Right-sizing

Provisioning servers in Azure is effortless. Within a few clicks, you can create a machine costing 1000s of dollars, leaving the engineering users to provision more than the required capacity to be on the safer side.

Though the environments will be stable and reliable by hosting in a giant machine, the cost comes as the downside. You can easily consume a significant chunk of the budget allocated by provisioning a few servers. It is always recommended to evaluate resource utilization and right-size them continuously. Right-sizing comes as a feature in many 3rd party tools.

9. Choosing the Right Services

There are many Serverless resources available in Azure. Instead of paying for the total capacity of a server, we can pay just for the capacity we use. Most of the time, it is better to go with Serverless resources as it automatically saves the cost during the system’s idle time.

Azure Functions running in a consumption plan are a suitable replacement for many background tasks running in resources like VMs, and Cloud Service Web/Worker roles.

Similarly, many other services come in a Serverless plan. Consider using Serverless resources in the possible areas to save cost.

10. Setup Policies and Follow Best Practices

It is common to have technical brainstorming sessions, handover meetings, and retrospection meetings for engineering-related activities. Plan the same kind of meeting regularly to discuss cloud cost optimization.

It would help if you defined Access policies to restrict resource creation and modification, and they should be delegated to team owners. Only some team members should be allowed to deploy resources as it comes with a cost.

For obtaining the best overview, you should subscribe to a 3rd party tool for managing the Azure cost. It is as essential as an APM tool for an application, thereby ensuring that all the Azure cost optimization best practices are followed.

Key Takeaways from Azure Cost Optimization Best Practices

Following the above 10 best practices immensely helps to optimize the Azure cost and have it under full control. But, in real-time, there is this challenge where the person who wants to understand the costs might not have the knowledge to break down the cost data into something meaningful, and the application teams do not have the access or tools to analyze their Azure spend.

Here is where Serverless360 Cost Analyser enables organizations to tackle this problem from both sides. The application teams can build cost analysis, budgeting, and optimization focused on making sure they are efficiently running their resources. Then they can work with the cost owner to build views which allows them to demonstrate they are being efficient.

This creates an all-around better experience where the application teams can be responsible for their costs, and the cost owner can focus on governance across teams. Cost Analyzer will help break up those silos which lead to zero transparency, inefficiency, and out-of-control costs.

Optimize Azure cost now for free!

Top comments (0)