SQL Database
  • 24 Dec 2024
  • 6 Minutes to read
  • Contributors
  • Dark
    Light

SQL Database

  • Dark
    Light

Article summary

In this page we will analyze some of the factors affecting your decisions around SQL Azure database

Factors that affect cost


  • How much compute/memory has my database got (eg vCores, DTU)

  • Which service level & compute tier have you picked

  • Which replication options have you chosen

  • Storage size

  • Backup retention

  • Redundancy

Things to Think about


Service Tier

In this case you will be choosing between vCore based and DTU based compute.

DTU

vCore

Concept

bundle together CPU, Memory and IO into a simpler model called DTU

Similar to a virtual machine model where you scale CPU, memory and storage

Aim

Simpler workloads

Aimed at users who need granular control of the database performance characteristics

Configuration knobs

Simple, mainly DTU to dial up or down

More flexible with choices to focus on scaling specific performance areas such as memory optimized

Tiers

Basic, Standard, Premium

General Purpose, Business Critical, Hyperscale

Choose when

Simpler workloads where you want predictability

Fine-grained control and scalability

Compute Tier

In this area you are choosing between Serverless and Provisioned compute. It assumes you chose the vCore service tier.  

Provisioned

Serverless

Allocation

Pre-allocated size

Auto-scale, inflate or deflate depending on use

Billing cycle

Per hour

Per second

Available on

DTU based

vCore based

vCore based only

Cost model

Fixed

Variable

Choose when

Constant, high usage

Mission critical workloads

Long running queries

Intermittent and burstable workloads

Backup Redundancy

When choosing the redundancy requirements for my backups there is a trade off between resilience and cost.  The below table summarises this.

Redundancy Option

What do I get

Storage Cost

Data Transfer Cost

Best For

Locally Redundant Storage (LRS)

LRS keeps three copies of your data within a single Azure data center in the same region.

Lowest

No

Cost-sensitive applications with minimal resilience needs

Zone-Redundant Storage (ZRS)

ZRS replicates data across three availability zones within the same Azure region, providing protection from data center-level failures within a region

Moderate

No

Critical applications needing zone-level resilience

Geo-Redundant Storage (GRS)

GRS stores data in the primary region and maintains three additional copies in a paired secondary region, ensuring data durability even if an entire region fails.

High

Cross-region egress

Applications with strong disaster recovery requirements

Read-Access Geo-Redundant Storage (RA-GRS)

Similar to GRS, but with an added benefit of read access to backups in the secondary region. This allows read operations to continue in the secondary region during a primary region outage.

Highest

Cross-region egress

Mission-critical applications needing read access in outages

When to choose what

  • LRS is the most cost-effective but lacks regional resilience.

  • ZRS provides zone-level redundancy, balancing cost with higher resilience.

  • GRS and RA-GRS are best for disaster recovery across regions but come with higher costs due to cross-region storage and transfer fees.

Replication

Replication Option

Secondary Database Cost

Data Transfer Cost

Best For

Active Geo-Replication

Fully provisioned secondary replicas

Cross-region egress charges

Mission-critical workloads needing high availability and read scaling across regions

Auto-Failover Groups

Fully provisioned secondary replicas

Cross-region egress charges

Disaster recovery for multiple databases, ensuring continuity across regions

SQL Data Sync

Based on sync frequency and compute usage

Cross-region egress charges, if applicable

Periodic data synchronization across multiple databases or hybrid cloud setups

Key Points:

  • Use Active Geo-Replication or Auto-Failover Groups only for critical applications and leverage SQL Data Sync for lower-cost periodic syncing

  • Only enable replication for databases that require high availability across regions, as each replica adds significant cost.

  • For SQL Data Sync, set an appropriate sync interval based on business needs to minimize costs.

Replicate vs Backup/Restore

Backup and Restore is cheaper than replication because replication will have active resources to support replication such as a secondary database.  In this case you need to consider your RTO and RPO requirements to map these to the capabilities of replication and backup & restore.

You are likely to need backup and restore in all production scenarios but the higher the business continuity, availability and recovery requirements the more you need higher redundancy for your backups and the more likely you are to need replication so you have active stand by’s ready to go.

This is a trade off decision between cost and resilience.

One of the key things to also consider with replication is that having read replica’s in other data centres may benefit you a lot in terms of application performance if you can do local reads in a geo-distributed application.  This will reduce bandwidth and the improved performance may also benefit the overall cost of your application.

Backup Restore

Replication

Availability

Periodic snapshots, no real-time failover

Real-time failover, minimal downtime

Data Loss

Possible loss up to the last backup point

Very minimal

Recovery duration

Much longer

Very quick

Cost

Cheapest

Much higher cost

Choose when

Non-critical apps

Mission-critical apps

Other

Backup history

Load balancing for read-heavy applications

Defender for SQL

If you want to increase the security for your database then you will consider Defender for SQL.  This is an optional feature and there is an additional cost for this.

Common Optimizations


  • Service Tier

In SQL Azure database there are a number of service tiers.  Reviewing the performance and usage of your database and ensuring it is on the appropriate service tier is a good idea.  You may wish to plan to move your database to other models if a bad decision was made initially upon deployment.

We have seen many times where business critical databases have been setup in test environments which are wasting lots of money.

  • vCores / DTU

One of the most common optimizations will be to review the allocated DTU or vCores and configuration of your database to ensure its inline with how it is being used.  It is often relatively easy to increase and decrease the vCores or DTU if there is a good saving.

  • Query / Index optimization

One of the first optimizations you should look at are any performance tuning in the database objects.  There is a direct correlation between database performance and cost with an Azure SQL Database.  If you have a poor index for example then your poor performing queries will increase the load on the system which will cause you to reach scaling points sooner.

When looking to optimize cost, one of the first places to check is to ensure that your recommendations offered by Azure for SQL indexes and query optimizations are reviewed.

  • Replication / backup

Ensure you review your back and replication requirements against your application non-functional requirements.  You might have over provisioned some of the settings if you have not carefully reviewed them to check they are inline with your needs.

Also challenge the requirements.  It is easy for a project to say they want a gold plated redundancy and availability solution without considering the costs of achieving this.  Make sure you have validated the business value of this solution is inline with the costs.

  • Hybrid License Benefit

If you are using the vCore model for SQL then you may be able to leverage the hybrid licensing benefits to reduce costs.

How can Turbo360 helps in Azure SQL Database cost optimization?


Visibility

With Turbo360 the graphs will help you to easily visualize the SQL database costs in various dimensions.  You could look at the databases you use, costs summarized by tags, resource groups or maybe meters and sub meters across your environment as shown below.

Understanding your databases holistically across your environment is good, but also being able to allocate different databases to be cost managed within the scope of other resources which make up that application is hugely valuable too.

Rightsizing

In Turbo360, we will help you to identify databases that are over-provisioned and offer alternative SKUs that could be used to downsize the database if you can reduce cost.

Idle Databases

Turbo360 will identify SQL databases that look like they are not used and flag them up as once we can potentially remove.  Reducing waste is a good way to reduce costs.

Reservations

Resources that could benefit from a reservation will be identified.  You can also easily see which resources have utilized a reservation.

You can also see if there are reservations which could be used by your area which could have some space on them.

Turbo360 will help you to maximize the use of reservations.

Scheduled Scale up / Down

With the Turbo360 scheduler feature it is possible to configure a schedule where your database will be scaled up and down at various times.  A great example of this is if your database is only used during office hours, then we can scale it up during the daytime and then out of hours we can reduce the vcores or DTU in the evening and at weekends.

Related reading:


Was this article helpful?

What's Next
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence