Last year, I moved to a new project in my company. After some months, we deployed new services to Azure, but something was off. The cost was too high for the small number of services. I volunteered to investigate.
The problem
We had these services in Azure: Container Apps, App Services, and Azure Database. I went to check one by one. After reading some metrics I realized a lot of things that could be optimized. I will break them down below.
App Service
Starting with App Service, we were using a tier which was way higher than we needed. The average CPU and Memory usage was 4%, and memory 40%, so I started downgrading it a few tiers (from Premium v3 P1V3 to Basic B2).
Container App
Then it was time to check the container app. We were already using the lowest tier, so we couldn't do any tier downgrade, but, the resource allocation was customizable. After monitoring for a few days, I noticed it peaked at 0.2 CPU cores and memory at 1.8GB. So I reduced the memory allocation from 56gb to 4gb, and CPUs from 8 to 1.
Azure Database
Next was the database, and here I could make two changes. First, the compute size. Average CPU was under 10% and memory under 35%, the same story as the App Service, so I reduced it from Standard_B2s to Standard_B1ms.
Second, the uptime. Our application is only used during business hours, so I automated the server to shut down at 7 pm and start at 7 pm. On weekends it never starts.
Results
I made the mentioned changes and waited a month. Always analyzing the logs and metrics, checking if the optimization was too harsh and the services were still running smoothly. After that month, the changes paid off. the monthly cost was reduced by 55%. From $491 to $219. This was a research environment, so the absolute numbers are small but the same approach works at any scale.
Top comments (0)