Maximizing Savings: Cost Optimization for Azure’s Most-Used Services
Published Apr 06 2023 05:37 AM 5,789 Views

 

We all understand the importance of cost optimization in cloud infrastructure. Azure offers numerous tools and strategies to assess, manage, and reduce costs. In this blog post, I will share insights and tips on cost optimization in Azure. 
 

Based on our experience, we have identified several commonly used Azure services that contribute significantly to monthly costs. For each service, I will suggest cost-saving measures that can be easily implemented. However, before implementing these techniques, it is crucial to reevaluate your technical architecture to optimize performance and efficiency. This may involve considering alternative services or architectures, such as serverless computing, containers, or microservices, which can help lower costs. For more detailed information on implementing Financial Optimization (FinOps) in Azure, you can explore this TechCommunity blog.  

 

RohitTurambekar_1-1680625017587.png

 

Once you have optimized your technical architecture, here are a list of common Azure services  

and their cost optimization techniques.

   

  1. Azure Subscriptions 

Azure Dev test subscription is a unique offer for active Visual Studio subscribers who want to use Azure for development and testing purposes.  Some of the benefits of this offer are: 

  1. You can get discounted rates for Azure services like virtual machines, app services, and storage 
  2. Multiple subscriptions can be created without any additional cost 
  3. Your own licenses for Microsoft software like Windows Server, SQL Server, and SharePoint Server can be used on Azure VMs 
  4. Exclusive features and tools like Visual Studio Code Spaces and Azure DevTest Labs are available for dev/test scenarios. 

Some of the pre-requisites, terms and conditions user should know while using Dev Test subscriptions are: 

  1. You need an active Visual Studio subscription to be eligible for this offer. 
  2. Use your Microsoft account linked to your Visual Studio subscription to create or access your Dev Test subscriptions. 
  3. The resources provided through this offer are for application development and testing purposes only. 
  4. These resources cannot be used for production workloads or any other purpose. 
  5. No uptime guarantees or technical support is included in this offer. 
  6. If you require technical support, you can purchase it separately. 

 2. Azure VM (virtual machines)  

     A.Right sizing & shutdowns 

  1. Auto shutdown and startup during off-hours - Azure Automation provides a feature to start or stop Azure Virtual Machines (VMs) during off-hours as per user-defined schedules. This feature is available for both Azure Resource Manager and classic VMs. 
  2. Resize SKU recommendations - Azure Advisor suggests resizing virtual machines or scale sets to a cheaper or more suitable SKU, or fewer instances of the same SKU, based on the retail rates. With the above recommendations and your application usage benchmark, you can resize the VMs for less cost without affecting performance. 
  3. Auto scale Azure resources when possible: Auto scale up and scale down instances as per usage pattern. This helps you achieve cost optimization, where costs scale linearly with demand. 

       B. Using cost controls 

There are different payment options for VMs depending on your workload requirements and budget. Some factors that affect the cost are SLA (service level agreements), region, OS (operating systems), and number of instances.  

The payment options are: 

  1. Pay as you go: pay by the second for flexible and unpredictable workloads that need high availability. 
  2. Reserved Virtual Machine Instances: pay in advance for one or three years for steady-state workloads and save money compared to pay as you go. 
  3. Savings plans: commit to a fixed hourly amount across compute services for one or three years and get discounts across regions. 
  4. Spot pricing: pay for unused compute capacity at low prices for interruptible and flexible workloads. 
  5. Dev-Test pricing: As pointed out in point #1, get discounted rates on Azure for development and testing environments that can be created and dropped on demand. 

       C. Windows VMs - Hybrid benefits 

Azure Hybrid Benefit can save costs by using your on-premises Windows Server licenses with Software Assurance for VMs in Azure. 

  1. To get started, check your eligibility and choose a deployment method for your Windows VMs. 
  2. You can deploy images from Azure Marketplace, upload a custom VM, or convert an existing VM. 
  3. Enable Azure Hybrid Benefit on your Windows VMs during or after deployment using Azure portal, PowerShell, CLI (command-line interfaces), or templates. 
  4. Limitations apply, such as limits on the number of virtual machines per license and restrictions on using third-party marketplace images. 

For more details, please refer to these documents: Azure Hybrid Benefit guide 

 

     3. Databases 

There are many types of databases on Azure, such as Azure SQL Database, Azure Cosmos DB, Azure Database for MySQL, Azure Database for PostgreSQL, and Azure Database for MariaDB.  

Each database has its own cost optimization methods.  

  • For Azure SQL Database 
  1. You can use elastic pools to share resources among multiple databases
  2. Use reserved capacity to prepay for compute resources at a discounted rate
  3. Like Windows VMs, you can use Hybrid Benefits to save the cost on Azure for SQL DBs 
  4. Use serverless compute tier which bills per second of usage and automatically scale ups and down based on demand
  5. However, you cannot reserve DTU-based (basic, standard, or premium) databases in SQL Database
  • Azure Cosmos DB  
  1. You can use auto scale provisioned throughput to adjust your request units (RUs) based on your workload patterns 
  2. Use reserved capacity to prepay for RUs at a discounted rate  
  3. Use time-to-live (TTL) feature to delete old data automatically
  4. Use effective partitioning to avoid hot partitions.
  5. Use caching solutions to reduce requests and RU consumption.
  6. Optimize development/testing cost by using the local emulator, the Azure Cosmos DB free tier, Azure free account

Refer to the Azure Cosmos DB documentation to see detailed steps to implement cost saving for the above-mentioned techniques. 

  • Azure Database for MySQL/PostgreSQL/MariaDB 
  1. You can use flexible server option to choose between burstable or general-purpose compute tiers based on your performance needs
  2. With Flexible server, use stop/start feature to pause your server when not in use   
  3. Save on compute costs by using reserved capacity to prepay for compute resources at a discounted rate. 
  4. Choose the right server size for your workload. 
  5. Use of Single-Server service supports 99.99% of availability, cutting the cost of passive hot standby due to its cloud native design. 
  6. For workloads with intermittent or unpredictable demand use Serverless mode. 
  1. Azure App services 
  1. Consider cost savings by using the App Service Premium v3 plan over the Premium v2 plan. The App Service Premium (v3) Plan has a 20% discount versus comparable Pv2. 
  2. With Pv3 plan, you can use Reservation if you are expecting stable usage over one to three years. 
  3. Also, with the Pv3 plan, the Savings plan can be used to save money. 
  4. Consider Basic or Free tier for non-production usage. 
  5. If your application has small, isolated workloads, consider using Azure Functions instead of Azure App Services. 
  1. Azure Storage accounts 
  1. Choose the storage tier that meets your requirements which minimizes the cost. 
  2. Use lifecycle management policies to automatically transition data to lower-cost storage tiers or delete it when it's no longer needed. 
  3. Use data compression and deduplication to reduce storage costs and improve data transfer performance. 
  4. Use the soft delete feature to retain deleted data and avoid costly data recovery. 
  1. Azure Storage Disks 
  1. Premium Disks (P30 and minimum 1 TiB onwards) can be reserved (one or three years) at a discounted price. 
  2. Use bursting for P20 and lower disks for workloads, such as batch jobs, workloads, which handle traffic spikes, and to improve OS boot time. 
  3. Use disk snapshots to create point-in-time backups of disks and reduce backup storage costs. 
  4. Use Azure Backup to back up your disks to Azure Storage, which can be more cost-effective. 
  5. Monitor disk usage and optimize it by deleting unused disks or resizing disks. 
  1. AKS (Azure Kubernetes Service) 
  1. AKS (Azure Kubernetes Service) provides various cost optimization options for different environments. 
  2. Use cluster pre-set configuration to choose the right VM SKU, number of nodes, number of availability zones, etc. for different environments while highlighting the impact on cost. 
  3. Set resource requests and limits for your workloads to manage the compute resources within an AKS cluster. 
  4. Use Vertical Pod Autoscaler (currently in preview) to automatically set resource requests and limits on containers per workload, based on past usage. 
  5. Completely turn off your cluster by using cluster start/stop for AKS clusters that do not have to be running all the time. 
  6. AKS offers a free tier for Dev/Test workloads or POC (proof of concept) without charge for control plane, providing a fully managed Kubernetes control plane at no cost. 
  7. Azure Spot virtual machines offer deep discounts (up to 90%) for unutilized capacity in Azure. Add a secondary Spot node pool to the cluster to use Spot VMs in AKS. 
  8. Azure Reserved Virtual Machine subscription allows you to save up to 72% on pay-as-you-go prices for consistent and long-term workloads. 
  9. AKS supports ephemeral OS disks that are free and can replace persistent disks for certain types of workloads to help save costs. However, ephemeral OS disks may not be suitable for all workloads and may not offer the same level of reliability and data durability as persistent disks. 
  10. Using Azure Blob storage and the CSI driver in AKS can help save costs on expensive persistent storage solutions while still meeting your unstructured data storage needs. 

You can refer to Azure Well-Architected Framework for more detailed guidance on cost optimization for AKS. 

  1. Azure Log analytics 
  1. Consider using the Commitment Tiers pricing model to the Log Analytics workspace. Commitment Tiers enable saving as much as 30% compared to Pay-As-You-Go pricing but Commitment Tiers start at 100 GB/day. 
  2. Set up data retention policies to delete old data you no longer need and keep data ingestion and storage under control. 
  3. Only ingest the data you need and filter it by source or type to reduce data ingestion and storage costs. 
  4. Instead of ingesting all data, use sampling to ingest a subset of data and reduce costs while still providing useful insights. 
  5. Compress data before ingesting it into Log Analytics to reduce storage costs by up to 50%. 
  6. Use Azure Data Explorer - Storing logs in Azure Data Explorer reduces costs while retaining your ability to query your data and it is especially useful as your data grows. 
  1. Azure Functions 
  1. Use the serverless consumption plan to scale automatically based on incoming requests and pay only for the compute resources utilized. 
  2. Consider Savings plan when using Premium Plan for Functions. 
  3. Reduce execution time and resource usage by optimizing your function code. 
  4. Use caching to reduce requests to external services and improve performance, reducing costs. 
  5. Reduce function executions and unnecessary processing with efficient triggers. 
  1. Azure Monitor 
  1. Use data sampling to reduce data ingestion and storage costs while still providing valuable insights.  
  2. Set up data retention policies to delete old data you no longer need and keep data ingestion and storage under control. 
  3. Optimize queries to reduce data processing costs and improve query performance. 
  4. Use log profiles to selectively ingest logs and metrics based on custom filters to reduce ingestion costs. 
  5. Use alerts judiciously to avoid unnecessary alerts and reduce alerting costs. 
  1. Azure Cognitive Search 
  1. Choose the right service tier that meets your requirements and budget. 
  2. Create resources in the same region to minimize or cut bandwidth charges. 
  3. Optimize search index size by removing unnecessary fields and compressing text data. 
  4. Use Azure Blob Storage to store and index data to save costs. 
  5. Utilize features such as indexer scheduling, query performance optimization, and autoscaling to further optimize costs. 

 

Optimizing your cloud costs is a crucial part of your overall cloud strategy, and the above most used Azure services listed in this blog are commonly used services to focus on when seeking cost savings. By implementing the cost-saving measures we've discussed above, you can reduce your Azure bill while maintaining elevated performance and reliability. 

 

 

 

 

 

 

Co-Authors
Version history
Last update:
‎May 06 2023 07:07 AM
Updated by: