Running a SQL Managed Instance can be cost effective, no matter if you are just validating the service, developing, or running your production. In this article we will demonstrate how a SQL Managed Instance first time user, or experienced users that run one or multiple non-production environments, can try out or operate SQL Managed Instance for just 100$.
Note: Prices for Azure services vary per region. In this article we will use East US region as a reference.
Introduction to Azure SQL Managed Instance PaaS
Azure SQL Managed Instance is part of Azure SQL family and together with Azure SQL Database is classified as PaaS (Platform-as-a-service) offering. Third close “relative” in the family is Azure SQL on Virtual Machines which is classified as IaaS (Infrastructure-as-a-service). To learn more about Azure SQL portfolio and differences between available offerings, the official “What is Azure SQL” documentation page can be handy.
Running database on PaaS offering comes with numerous benefits and moves multiple management tasks out of your way, ensuring that you can put focus on application and product development. Some of the main values of the PaaS include:
- No hardware purchases or management.
- Continuously improving performance by adopting latest and well-tested hardware generations.
- Automated maintenance of physical and logical infrastructure powering your database.
- Automated upgrades of SQL Server.
- Built-in high availability with SLA (service level agreements) guarantees.
- Automated backups (short and long term).
- Seamless integration with other Microsoft cloud services like Power BI, Machine Learning, Data Lake Storage, IoT, etc.
As we can see, a lot of management tasks are provided out of the box, and you can spend zero-time maintaining them.
Price structure of Azure SQL Managed Instance
The focus of this article will be on General Purpose service tier. Let us drill down on what you are charged for:
- SQL license
- Compute (vCores)
- Data storage
- Backup storage
Prices vary per region, and 4-vCores SQL Managed Instance with 32GB of data, running on Standard-series hardware with General Purpose service tier and SQL license included costs ~740$ in East US region. For someone who is just getting started with the service, builds a proof of concept, or wants to run dev/test environment, this can be quite expensive.
You can easily determine the costs of your instance by using the Azure Calculator. Here is the screenshot of it.
The above-mentioned price represents the full SQL Managed Instance price. Let's deep dive into how to run and validate SQL Managed Instance for lower price.
How can I run SQL Managed Instance for 100$?
Each of the above-mentioned charges can be eliminated or reduced. Let's go step by step through this.
Optimize SQL License costs
In Azure SQL Managed Instance you get fully managed SQL Server with evergreen version of SQL Server that is regularly updated with latest and greatest version. The SQL license is issued for each managed instance and is being charged. This charge corresponds to the number of vCores provisioned for instance compute power. There are two ways to eliminate license costs.
Azure Hybrid Benefit
Besides bringing your licenses to Azure and enabling the discount, the advantage of Azure Hybrid Benefit is 180 days of dual-use rights to apply to current deployment (on-premises or third-party cloud) and in Azure to allow for data migration.
Azure Dev/Test pricing gives customers access to select Azure services for nonproduction workloads at discounted pricing under the Pay-As-You-Go, Microsoft Customer Agreement, or Enterprise Agreement. This means that your instance is charged for the compute, storage, and backup storage, but not charged for SQL License.
How do you sign up for Azure Dev/Test pricing? Here are the options:
- Visual Studio subscribers sign up for Pay-As-You-Go Dev/Test.
- Organizations with Visual Studio subscriptions and Enterprise Agreements sign up for Enterprise Dev/Test using the Azure Enterprise portal.
- Organizations with Visual Studio subscriptions and Microsoft Customer Agreements sign up for Azure Plan for Dev/Test.
With one or another option leveraged, your SQL Managed Instance costs are reduced from ~740 to ~445$. Still quite expensive, but much better than from the start. Here is the screenshot of Azure Calculator for SQL Managed Instance with dev/test pricing applied. You can also see the option for applying Azure Hybrid Benefit.
Optimize compute costs
We made it to the main part – the compute. Compute costs scale with the number of vCores configured for your SQL Managed Instance. We suggest starting with 4 vCores of General Purpose SQL Managed instance, especially if you are in the process of getting familiar with the service. With all tips applied for the backup storage, data storage, and license costs we came to the cost of ~445$. This is the cost of one SQL Managed Instance running 24/7 for the entire month.
But if you are evaluating, developing your project, or running your non-production environment, you do not need the instance running 24/7. This is where stop-start capability comes in handy and saves the day.
Typically, industries correlated with IT (information technology) operate on a 5 working day basis, with 9AM to 5PM working hours. This translates into 40 hours a week. If we take worst case scenario with 4 weekends in a month without holidays and non-working days, we come to 23 working days.
Now let’s do the simple math: 23 days x 8 working hours represents 184 working hours. If we apply that value in the cost calculator, we can see that compute costs are reduced to ~112$.
And how to leverage the stop-start capability for SQL Managed Instance? There are two ways to achieve this. Either you can manually stop and start the instance once you are starting your working hours and finishing the day. Or you can create a predefined schedule to do it for you. To learn more about feature capabilities, you can check the official documentation page for Stop and start an instance.
Here, we are sharing an example of creating a schedule using Azure Portal, but same can be achieved through PowerShell that executes API call. Since instance start operation typically takes 20 minutes, the schedule of start command will be set for 07:40 AM, while stop operation that typically takes 5 minutes to execute will be scheduled for 04:55 PM.
Optimize data storage costs
Data storage is used for storing your active data. In the case of General Purpose instance, it is locally replicated (LRS) and there is no option for changing the replication. Data storage is charged in increments of 32GB, and it is charged for reserved storage, not the used. First 32GB are free, while each additional 32GB increment is charged 8$:
- 32 GB of reserved storage have 0 cost
- 64 GB will be charged 8$
- 96 GB will be charged 16$
So, if you are just starting with SQL Managed Instance, go with 32GB of reserved storage. You can adjust it anytime and scaling storage in General Purpose service tier is an online operation.
Optimize backup storage costs
Azure SQL Managed Instance creates:
- Full backups every week.
- Differential backups every 12 to 24 hours.
- Transaction log backups every 10 minutes.
These backups represent short-term backups and can be kept for 1 to 35 days. In addition to short-term backups, you can configure long-term backups (weekly, monthly, and yearly) that can be kept for up to 10 years.
Further, backup data is stored in a storage that is replicated, ensuring the highest durability. Backup storage can be replicated in one of the following ways:
- Locally redundant storage (LRS),
- Zone-redundant storage (ZRS),
- Geo-redundant storage (GRS),
- Geo-zone-redundant storage (GZRS).
Backup storage is charged 0.1$/GB/month. But backup storage is free up to the amount of reserved data storage. What that means is that if your instance has 32GB of reserved data storage, your backups for up to 32GB are free of charge.
The more data you have, the size of the backups increases. Do not worry, backups taken go through the compression process to minimize its growth. But to reduce backup costs to 0 you should (if applicable for your scenario):
- Select LRS as desired replication,
- Reduce retention of short-term backups to 7 days or less for each database,
- Keep long-term retention backups turned off.
By applying these tips, your backup costs would be 0$ and SQL Managed Instance charges will stay as they are.
In this article we’ve shown that validating SQL Managed Instance or running non-production environments does not have to be expensive. Backup storage costs can be eliminated through available configuration options. Data storage of 32GB comes free of charge. By using dev/test pricing you will eliminate the cost of SQL license. And finally with the ability to stop your instance when not in use and start it once you need it again, you will save on the compute costs and pay only for the hours used.
Call to action: If you have ideas that you would like to share, feel free to leave comments to this blogpost or contact us using https://aka.ms/contactSQLMI link.