

# SQL Server
<a name="sql-server"></a>

Customers have been running Microsoft workloads on AWS for over 15 years, longer than any other cloud provider. This is largely because AWS has the most experience with Microsoft applications in the cloud and offers the best platform for Windows Server and Microsoft SQL Server in the following areas:
+ Higher performance and reliability
+ Greater security and identity services
+ More migration support
+ The broadest and deepest capabilities
+ Lower total cost of ownership (TCO)
+ Flexible licensing options

AWS supports everything necessary to build and run Windows applications that rely on SQL Server, including Active Directory, .NET, SQL Server, Windows desktop as a service, and all supported versions of Windows Server. With proven expertise, AWS can help you easily lift and shift, refactor, or even modernize your Windows workloads.

**Topics**
+ [Choose a high availability and disaster recovery solution](sql-server-hadr.md)
+ [Understand SQL Server licensing](sql-server-licensing.md)
+ [Select the right EC2 instance for SQL Server workloads](right-ec2-instance.md)
+ [Consolidate instances](consolidate-instances.md)
+ [Compare SQL Server editions](sql-server-editions.md)
+ [Evaluate SQL Server Developer edition](sql-server-dev.md)
+ [Evaluate SQL Server on Linux](sql-server-linux.md)
+ [Optimize SQL Server backup strategies](sql-server-backup.md)
+ [Modernize SQL Server databases](modernize-sql-server.md)
+ [Optimize storage for SQL Server](storage-sql-server.md)
+ [Optimize SQL Server licensing by using Compute Optimizer](sql-server-compute-optimizer.md)
+ [Optimize SQL Server sizing by using Compute Optimizer](sql-server-sizing-compute-optimizer.md)
+ [Review Trusted Advisor recommendations for SQL Server workloads](sql-server-trusted-advisor.md)

# Choose a high availability and disaster recovery solution
<a name="sql-server-hadr"></a>

## Overview
<a name="sql-server-hadr-overview"></a>

We recommend that you design an architecture for your SQL Server deployment on AWS that meets your business needs while also meeting your [disaster recovery (DR) objectives](https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/disaster-recovery-dr-objectives.html), including your recovery time objective (RTO) and recovery point objective (RPO). The following solutions can help you design the right architecture for SQL Server on Amazon Elastic Compute Cloud (Amazon EC2) while also optimizing costs for your SQL Server workloads.
+ **SQL Server Always On availability groups **–** **SQL Server Always On availability groups provide high availability and disaster recovery (HA/DR) solutions for SQL Server databases. An availability group consists of a set of user databases that fail over together. Always On availability groups also provide redundancy at the database level, but don't require shared storage—each replica has its own local storage. You can deploy this feature as an HA/DR solution. For more information, see [What is an Always On availability group?](https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server?view=sql-server-ver16) in the Microsoft documentation.
+ **SQL Server Always On failover cluster instances (FCI)** –** **SQL Server Always On FCIs use Windows Server Failover Clustering (WSFC) to provide HA at the SQL Server instance level. FCIs require shared storage to host databases. You can use either shared block storage or shared file storage. For example, you can use Amazon FSx for Windows File Server or Amazon FSx for NetApp ONTAP as a shared storage solution with multiple Availability Zones. For more information, see [Always On Failover Cluster Instances (SQL Server)](https://learn.microsoft.com/en-us/sql/sql-server/failover-clusters/windows/always-on-failover-cluster-instances-sql-server?view=sql-server-ver16) in the Microsoft documentation.
+ **SIOS DataKeeper** –** **SIOS DataKeeper can help you meet both HA and DR requirements by enabling a SQL Server FCI that spans both Availability Zones and AWS Regions. SIOS DataKeeper creates a clustered virtual SAN by using local Amazon Elastic Block Store (Amazon EBS) volumes and uses synchronous replication between Availability Zones for HA, while using asynchronous replication between Regions and for disaster recovery. For more information, see [High Availability Protection for Windows Applications](https://us.sios.com/products/windows/) in the SIOS documentation.
+ **Distributed availability groups** –** **Distributed availability groups are a special type of availability group that spans across two separate Always On availability groups. An availability group can reside across two separate Regions (for example, `us-east-1` and `us-west-1`). You can think of a distributed availability group as an availability group of availability groups because the underlying Always On availability groups are configured on two different WSFC clusters. SQL Server Enterprise edition is required to deploy distributed availability groups. For more information, see [Distributed availability groups](https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/distributed-availability-groups?view=sql-server-ver16) in the Microsoft documentation.
+ **Log shipping** –** **You can implement log shipping to protect your databases across multiple Regions, in the rare event a Region is impacted and becomes unavailable. Depending on the transaction and log shipping frequency, you can achieve RPO and RTO within minutes. For more information, see [About Log Shipping (SQL Server)](https://learn.microsoft.com/en-us/sql/database-engine/log-shipping/about-log-shipping-sql-server?view=sql-server-ver16) in the Microsoft documentation.
+ **AWS Elastic Disaster Recovery** – Elastic Disaster Recovery is a software as a service (SaaS) application that manages the replication of servers from any infrastructure to AWS for DR purposes. You can also use Elastic Disaster Recovery to replicate SQL Server across Regions. Elastic Disaster Recovery is an agent-based solution that replicates entire virtual machines, including the operating system, all installed applications, and all databases into a staging area. For more information, see [What is Elastic Disaster Recovery?](https://docs.aws.amazon.com/drs/latest/userguide/what-is-drs.html) in the Elastic Disaster Recovery documentation.
+ **AWS Database Migration Service (AWS DMS)** –** **AWS DMS supports live migration of data to and from AWS, including a different Region. You can use this feature to set up a separate SQL Server instance in a different Region to serve as a disaster recovery database. For more information, see [What is AWS Database Migration Service?](https://docs.aws.amazon.com/dms/latest/userguide/Welcome.html) in the AWS DMS documentation.

## SQL Server Always On availability groups
<a name="sql-server-always-on"></a>

If you're using SQL Server Enterprise edition just for a high availability [Always On availability group](https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server?view=sql-server-ver16), then you can downgrade to SQL Server Standard edition by taking advantage of basic availability groups. You can reduce costs from 65–75 percent by using basic availability groups instead of Always On availability groups.

**Note**  
For additional information on cost differences between different SQL Server editions, see the [Compare SQL Server editions](sql-server-editions.md) section of this guide.

**Features**
+ Available in SQL Server Standard edition
+ Limit of two replicas (primary and secondary)
+ No read access on secondary replica
+ No integrity checks on secondary replicas

**Limitations**
+ Support for only one availability database per availability group
+ Basic availability groups can't be part of a distributed availability group

The following diagram shows an example architecture for a Windows Server Failover Cluster solution.



![\[Windows Server Failover Cluster architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/wfc_arch.png)


## SQL Server Always On failover cluster instances
<a name="sql-server-always-on-failover"></a>

You can use failover cluster instances (FCIs) to ensure continuous database operations while minimizing downtime and reducing the risk of data loss. FCIs offer a reliable solution if you're seeking high availability for your SQL Server database without a read replica configuration.

Unlike availability groups, FCIs can provide a dependable failover solution without requiring SQL Server Enterprise edition. Instead, FCIs require only SQL Server Standard edition licensing. You can use FCIs to reduce SQL Server licensing costs by 65–75 percent.

**Note**  
For additional information on cost differences between SQL Server editions, see the [Compare SQL Server editions](sql-server-editions.md) section of this guide.

Consider the following:
+ Amazon FSx for Windows File Server offers a powerful solution for meeting your SQL Server FCI shared storage requirements. You can use FSx for Windows File Server to avoid the need to purchase a license for a storage replication solution and manage shared storage on your own. This can result in significant cost savings of 30-40 percent. For more information, see the [Simplify your Microsoft SQL Server high availability deployments using Amazon FSx for Windows File Server](https://aws.amazon.com/blogs/storage/simplify-your-microsoft-sql-server-high-availability-deployments-using-amazon-fsx-for-windows-file-server/) post on the AWS Storage Blog.
+ With the [Software Assurance benefits summary](https://download.microsoft.com/download/0/0/3/0039F316-45CF-4083-AA6E-C35DA9D25C1B/SA_InteractiveBenefitsChart.pdf) (downloadable PDF) and the Bring Your Own License (BYOL) model, you can take advantage of passive failover benefits, as long as the secondary server is passive. This results in cost savings for SQL licensing because you don't have to provide licenses to the passive node of the cluster.

The following diagram shows an example architecture for a SQL Server FCI by using FSx for Windows File Server.



![\[FSx for Windows File Server architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/fsx_arch.png)


## SIOS DataKeeper
<a name="sql-server-sios-datakeeper"></a>

We recommend that you consider shared storage requirements if you're planning to deploy SQL Server FCIs on AWS. Traditional on-premises installations typically use a storage area network (SAN) to meet shared storage requirements, but this isn't a viable option on AWS. Amazon FSx for Windows File Server is the recommended storage solution for SQL Server FCI on AWS, but it has limitations that prevent adding cluster servers in different AWS Regions.

You can use [SIOS DataKeeper](https://aws.amazon.com/blogs/architecture/field-notes-implementing-ha-and-dr-for-microsoft-sql-server-using-always-on-failover-cluster-instance-and-sios-datakeeper/) to create a SQL Server FCI that covers both Availability Zones and Regions while reducing costs by 58–71 percent. SIOS DataKeeper can help you achieve the high availability benefits of FCI. This makes SIOS DataKeeper a cost-effective and dependable solution for organizations.

Consider the following additional benefits of using SIOS DataKeeper:
+ SIOS DataKeeper creates a clustered virtual SAN by using local EBS volumes and uses synchronous replication between Availability Zones for high availability. For disaster recovery, SIOS DataKeeper uses asynchronous replication between Regions.
+ SIOS DataKeeper provides enterprise-class clustering features by using SQL Server Standard edition. This reduces SQL Server licensing costs between 65–75 percent compared to implementing high availability with SQL Server Always On availability groups that use SQL Server Enterprise edition. With SIOS DataKeeper, you can create a highly available, flexible, and cost-effective SQL Server environment that meets your organization's needs.

**Note**  
For additional information on cost differences between SQL Server editions, see the [Compare SQL Server editions](sql-server-editions.md) section of this guide.

The following diagram shows an example architecture for a SQL Server FCI using a clustered virtual SAN solution.



![\[SQL Server FCI using a clustered virtual SAN solution.\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/clustered_vsan_arch.png)


## Always On availability groups
<a name="sql-server-alwayson-avail-groups"></a>

You can use Always On availability groups for both high availability and disaster recovery purposes. You can achieve high availability by deploying SQL Server across two Availability Zones in one Region. You can achieve disaster recovery by extending availability groups across Regions.

The following diagram shows an example architecture for a solution based on Always On availability groups. The replicas in Region 1 of the diagram are using a Synchronous Commit, which provides an automatic failover of the availability group. The replica in Region 2 is using an Asynchronous Commit, which will require a manual failover of the availability group.



![\[Always On availability groups architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/alwayson_ag_arch.png)


## Distributed availability groups
<a name="sql-server-distributed-avail-groups"></a>

For mission-critical SQL Server deployments where you can't compromise on reliability or disaster recovery, we recommend a multi-Region approach. Distributing your availability groups across multiple Regions is the most resilient solution for maintaining business continuity and minimizing downtime.

This architecture takes full advantage of the capabilities of Amazon FSx for Windows File Server, including shared storage, synchronous block-level replication, and SQL Server FCIs. These capabilities make it possible for you to create a highly available SQL Server environment that spans multiple Availability Zones. By replicating this setup in another Region, you get a fully redundant system that can handle even the most severe disruptions. What sets this solution apart is the level of flexibility and security it provides. The domain-independent architecture of distributed availability groups enables underlying Windows cluster servers to join different Active Directory domains, while certificate-based authentication ensures maximum protection for your SQL Server environments and provides high RTO and RPO requirements for a multi-Region DR strategy. For information about building a multi-Region architecture, see [Field Notes: Building a Multi-Region Architecture for SQL Server using FCI and Distributed Availability Groups](https://aws.amazon.com/blogs/architecture/field-notes-building-a-multi-region-architecture-for-sql-server-using-fci-and-distributed-availability-groups/) in the AWS Architecture Blog.

The following diagram shows an example architecture for a multi-Region solution using distributed availability groups.



![\[Multi-Region architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/multi_region_arch.png)


## Log shipping
<a name="sql-server-log-shipping"></a>

Log shipping is a proven, reliable, and cost-effective method to safeguard your databases across Regions in the event of an unexpected outage. Organizations have been using log shipping to protect their data for decades.

If you implement log shipping on AWS, you can achieve RPO and RTO in minutes, depending on the frequency of transactions and log shipping jobs. In the unlikely event that a Region becomes inaccessible, log shipping keeps your data secure and recoverable.

Consider the following additional benefits of using log shipping:
+ Reduce costs and meet your business requirements by using log shipping for disaster recovery resilience across Regions. Log shipping reduces your TCO because you only need SQL Server Standard edition or SQL Server Web edition licenses.
+ Remove licensing costs from a disaster recovery/passive server by using log shipping with active [Software Assurance](https://download.microsoft.com/download/0/0/3/0039F316-45CF-4083-AA6E-C35DA9D25C1B/SA_InteractiveBenefitsChart.pdf). Only the primary/active SQL Server needs to be licensed when you use log shipping with Software Assurance.
+ Reduce SQL Server licensing costs by 65–75 percent by removing the need for SQL Server Enterprise edition to set up distributed availability groups between the Regions. You can do this by using SQL Server Standard edition and SQL Server FCIs combined with log shipping to meet your disaster recovery requirements.

**Note**  
For additional information on cost differences between SQL Server editions, see the [Compare SQL Server editions](sql-server-editions.md) section of this guide.

For more information, see [Extend SQL Server DR using log shipping for SQL Server FCI with Amazon FSx for Windows configuration](https://aws.amazon.com/blogs/architecture/extend-sql-server-dr-using-log-shipping-for-sql-server-fci-with-amazon-fsx-for-windows-configuration/) in the AWS Architecture Blog.

The following diagram shows an example architecture for a log shipping solution.



![\[Log shipping architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/log_shipping_arch.png)


## AWS Database Migration Service
<a name="sql-server-aws-dms"></a>

You can use AWS Database Migration Service (AWS DMS) to design an HA/DR solution based on your application needs. AWS DMS enables you to easily copy data to a secondary SQL Server database in the same Region (HA) or across Regions (DR). This approach is technically sound, and allows you to maximize your investment in AWS infrastructure while optimizing your resource usage.

AWS DMS is a cost-effective service. You are charged only for the CPU resources used during the transfer process and any additional log storage. This means that you can benefit from this solution without incurring significant additional costs. You can use AWS DMS to ensure your data is available and accessible, while minimizing costs associated with licensing and resource usage.

The following diagram shows an example architecture for a solution based on AWS DMS.



![\[AWS DMS architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/aws_dms_arch.png)


## AWS Elastic Disaster Recovery
<a name="sql-server-aws-edr"></a>

Some organizations must ensure that all critical business applications have a disaster recovery plan in place. In the past, many of these organizations invested heavily in traditional disaster recovery solutions, which require you to pre-build and maintain an entire duplicate infrastructure. This approach is costly, time-consuming, and difficult to scale.

Now, you can use AWS Elastic Disaster Recovery to eliminate the need for pre-building a disaster recovery infrastructure. Disaster recovery machines are not started in Elastic Disaster Recovery until necessary, so you only pay for what you use when you need it. This means that you can significantly reduce your software licensing and high-performance compute costs.

Additionally, the staging area for the disaster recovery solution contains low-cost Amazon Elastic Block Store (Amazon EBS) volumes. EBS volumes further reduce the cost of provisioning duplicate resources. This allows you to reduce your overall disaster recovery costs while still maintaining a robust and reliable disaster recovery solution that meets your business requirements. You can use Elastic Disaster Recovery to focus on your core business activities, while AWS takes care of the underlying infrastructure for your disaster recovery solution.

For SQL Server, you can use Elastic Disaster Recovery as a cost-effective disaster recovery option. The licensing for the passive node in a fault-tolerant, highly-available SQL Server architecture is covered if you use active Software Assurance. However, you're still paying compute costs for the passive server to be online. With Elastic Disaster Recovery, the primary server can replicate to the DR environment without the need to maintain active Software Assurance and without having to pay for disaster recovery compute costs. This combination of savings can reduce your SQL Server disaster recovery costs by 50 percent or more.

The following diagram shows an example architecture for a solution based on Elastic Disaster Recovery.



![\[Elastic Disaster Recovery architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/aws_drs_arch.png)


For more information, see [How to set up high availability for SQL Server at DR site that was restored using AWS Elastic Disaster Recovery](https://aws.amazon.com/blogs/modernizing-with-aws/set-up-high-availability-for-sql-server-at-dr-site-using-aws-elastic-disaster-recovery/) on the Microsoft Workloads on AWS Blog.

## Cost comparison
<a name="sql-server-cost-comparison"></a>

The following table compares the costs of the HA/DR solutions covered in this section. The following assumptions are made for the purposes of this comparison:
+ **Instance type** – r5d.xlarge
+ **License type** – License included for both Windows and SQL Server
+ **Region** – `us-east-1`


****  

| Solution | High availability | Disaster recovery | Enterprise edition | Standard edition | Cost | 
| --- | --- | --- | --- | --- | --- | 
| Log shipping | No | Yes | Yes | Yes | SQL Server Enterprise edition: \$132,674.8 (2 nodes)SQL Server Standard edition: \$114,804.4 (2 nodes) | 
| Always On availability groups | Yes | Yes | Yes | Yes, but basic availability groups (2 nodes) | SQL Server Enterprise edition: \$132,674.8 (2 nodes)SQL Server Standard edition: \$114,804.4 (2 nodes) | 
| Always On FCIs | Yes | No | Yes | Yes (2 nodes) | SQL Server Standard edition: \$114,804.4 | 
| Distributed availability groups | Yes | Yes | Yes | No | SQL Server Enterprise edition: \$165,349.6 (4 nodes) | 
| Elastic Disaster Recovery | No | Yes | Yes | Yes | Approx. \$1107.48/month for replication of 1 instance and 1 TB of storage**Note**: Elastic Disaster Recovery is billed hourly, per replicating server. The cost is the same, regardless of the number of disks, size of storage, number of drill or recovery launches, or the Region that you're replicating. | 
| SIOS Data Keeper | Yes | Yes | Yes | Yes | Always On availability groups with Software Assurance (2 nodes, 24 cores): \$1213,4802-node SQL Server cluster running on SQL Server Standard edition with SIOS DataKeeper and Software Assurance: \$161,530 (2 nodes) | 
| AWS DMS | No | Yes | Yes | Yes | \$1745.38/month for r5.xlarge instance and 1 TB of storage | 

## Cost optimization recommendations
<a name="sql-server-opt-rec"></a>

We recommend that you take the following next steps to choose an HA/DR solution that meets your organization's requirements:
+ Review the [Select the right EC2 instance for SQL Server workloads](right-ec2-instance.md) section of this guide.
+ Determine the IOPS and throughput requirements of your workloads by running performance counters during peak workloads:
  + IOPS = disk reads/sec \$1 disk writes/sec
  + Throughput = disk read bytes/sec \$1 disk write bytes/sec
+ Use the following storage volume types for better performance and cost savings:
  + NVMe instance storage for `tempdb` and buffer pool extension
  + io2 volumes for database files
+ Use [AWS Trusted Advisor](https://docs.aws.amazon.com/awssupport/latest/user/trusted-advisor-check-reference.html) for recommendations on cost optimization for SQL Server on Amazon EC2. You don't need to install an agent for Trusted Advisor to do SQL Server optimization checks. Trusted Advisor inspects your Amazon EC2 SQL Server license-included instance configurations, such as virtual CPUs (vCPUs), version, and edition. Then, Trusted Advisor makes recommendations based on best practices.
+ Use AWS Compute Optimizer for both Amazon EC2 instance and Amazon EBS right sizing recommendations.
+ Use [AWS Pricing Calculator](https://calculator.aws/#/) to design your HA/DR strategy for cost estimations.
+ To determine if downgrading from SQL Server Enterprise edition to SQL Server Standard edition is a possible option, use the [sys dm\$1db\$1persisted\$1sku\$1features](https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-db-persisted-sku-features-transact-sql?view=sql-server-ver16) dynamic management view to identify edition-specific features that are active in the current database.
**Note**  
Side-by-side migrations are necessary for SQL Server edition changes when using license-included EC2 instances.
+ Perform semi-yearly or yearly disaster recovery drills to better architect a design that could recover the database with defined RTO and RPO. This can also help you identify any architecture weaknesses.

## Additional resources
<a name="sql-server-resources"></a>
+ [Simplify your Microsoft SQL Server high availability deployments using Amazon FSx for Windows File Server](https://aws.amazon.com/blogs/storage/simplify-your-microsoft-sql-server-high-availability-deployments-using-amazon-fsx-for-windows-file-server) (AWS Storage Blog)
+ [Field Notes: Building a Multi-Region Architecture for SQL Server using FCI and Distributed Availability Groups](https://aws.amazon.com/blogs/architecture/field-notes-building-a-multi-region-architecture-for-sql-server-using-fci-and-distributed-availability-groups/) (AWS Architecture Blog)
+ [Architect a disaster recovery for SQL Server on AWS: Part 1](https://aws.amazon.com/blogs/database/part-1-architect-a-disaster-recovery-for-sql-server-on-aws/) (AWS Database Blog)
+ [Microsoft SQL high availability with Amazon FSx for Windows](https://www.youtube.com/watch?v=8dsRkVLy0Nc) (YouTube)
+ [Maximizing Microsoft SQL Server Performance with Amazon EBS](https://aws.amazon.com/blogs/storage/maximizing-microsoft-sql-server-performance-with-amazon-ebs/) (AWS Storage Blog)
+ [Comparing your on-premises storage patterns with AWS Storage services](https://aws.amazon.com/blogs/storage/comparing-your-on-premises-storage-patterns-with-aws-storage-services/) (AWS Storage Blog)
+ [Planning to replace a data center NAS with Amazon FSx File Gateway](https://aws.amazon.com/blogs/storage/planning-to-replace-a-data-center-nas-with-amazon-fsx-file-gateway/) (AWS Storage Blog)
+ [Optimizing cost for your high availability SQL Server deployments on AWS](https://aws.amazon.com/blogs/storage/optimizing-cost-for-your-high-availability-sql-server-deployments-on-aws/) (AWS Storage Blog)
+ [How to set up disaster recovery for SQL Server Always On Availability Groups using AWS Elastic Disaster Recovery](https://aws.amazon.com/blogs/modernizing-with-aws/how-to-set-up-disaster-recovery-for-sql-server-always-on-availability-groups-using-aws-elastic-disaster-recovery/) (Microsoft Workloads on AWS)
+ [How to set up high availability for SQL Server at DR site that was restored using AWS Elastic Disaster Recovery](https://aws.amazon.com/blogs/modernizing-with-aws/set-up-high-availability-for-sql-server-at-dr-site-using-aws-elastic-disaster-recovery/) (Microsoft Workloads on AWS)

# Understand SQL Server licensing
<a name="sql-server-licensing"></a>

## Overview
<a name="sql-server-licensing-overview"></a>

As more and more businesses move their workloads to the cloud, optimizing costs on cloud platforms has become a top priority. Licensing is one of the most significant costs associated with running Microsoft workloads on AWS. This section explains how to optimize costs on AWS by optimizing Microsoft licensing for SQL Server.

## AWS licensing options
<a name="sql-server-aws-licensing-options"></a>

AWS offers a range of flexible cost optimization choices for licensing. These licensing options are designed to help you reduce costs, maintain compliance, and meet your business needs.



![\[Review licensing options, such as purchasing or bringing licenses.\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/aws_licensing_options.png)


AWS categorizes licenses into three main types:

1. **License included** – This licensing option enables you to purchase and use licenses on demand, paying only for what you use. The license-included option is ideal for scenarios where you require flexibility in your licensing usage and want to avoid upfront costs. You can choose from a range of Windows Server, SQL Server, and other Microsoft products.

1. **Bring Your Own License (BYOL) products with license mobility** – This licensing option is designed for scenarios where you already have existing licenses and want to use them in the cloud. AWS allows customers to bring their own licenses to the cloud through Microsoft's [License Mobility](https://www.microsoft.com/en-us/licensing/licensing-programs/software-assurance-license-mobility) program. You can bring products that have License Mobility, such as SQL Server with Software Assurance (SA), to either shared or dedicated tenancy to reduce your AWS instance costs.

1. **BYOL products without license mobility** – For Microsoft products that don't have License Mobility, such as Windows Server, AWS offers dedicated options to use these products in the cloud. Additionally, dedicated hosts offer an opportunity to license at the physical core level. This can save you 50 percent or more on the licenses required to run your workloads. Dedicated hosts are a great option for stable and predictable workloads running most of the time.

## Cost impact of bringing licenses
<a name="sql-server-cost-bringing-licenses"></a>

Bringing licenses can have a significant impact on the cost of running Microsoft workloads on AWS. If you bring your own licenses, you aren't required to pay additional licensing costs for the instances running in the cloud. This can lead to significant cost savings.

The following comparison shows the on-demand monthly cost of running a single c5.xlarge instance 24/7:
+ Windows Server \$1 SQL Server Enterprise edition: \$11353/month (License included)
+ Windows Server \$1 SQL Server Standard edition: \$1609/month (License included)
+ Windows Server only: \$1259/month (License included)
+ Compute only (Linux): \$1127/month

Ultimately, bringing your own licenses can have a significant impact on the cost of running Microsoft workloads on AWS. If you use your existing licenses, you can reduce licensing costs and save money on your overall AWS bill.

## License optimization
<a name="sql-server-license-optimization"></a>

An AWS Optimization and Licensing Assessment (AWS OLA) can help you optimize your licensing by reducing compute and licensing costs. AWS OLA is designed to evaluate your licensing requirements for workloads running on AWS or for workloads that are planned for migration. AWS OLA provides recommendations on optimizing license usage.

One of the key strategies for optimizing licensing usage is [right sizing instances](rightsize.md). Right sizing involves selecting the right instance type for your workload based on its CPU, memory, and storage requirements. By choosing the appropriate instance size, you can ensure that you're using resources in a cost-efficient manner. This can lead to significant cost savings.

With Microsoft software licensing, the number of cores that the software runs on is a critical factor in determining licensing costs. For example, Windows Server and SQL Server licenses are typically licensed on the number of cores. By right sizing instances, you can lower the number of cores that the Microsoft software runs on and, in turn, reduce both the cost of the instance and the number of licenses required.

## Cost optimization recommendations
<a name="sql-server-lic-opt-rec"></a>

Optimizing licenses is a key component of cost optimization on AWS. By implementing the right strategies, you can reduce licensing costs, maintain compliance, and achieve the best possible value from your licensing investment. This section outlines several strategies for license optimization.

### Bring your eligible Windows Server licenses
<a name="sql-server-rec-byol-windows"></a>

Bringing your own Windows Server licenses is one of the most effective strategies for license optimization. This strategy enables you to take advantage of your existing investments to reduce your AWS spending.

For example, you can deploy Windows Server 2019 and earlier versions on [Amazon EC2 Dedicated Hosts](https://aws.amazon.com/ec2/dedicated-hosts/) if you purchased the licenses before 1/10/2019 or purchased the licenses as true-ups under active Enterprise Agreements signed before that date. This rule is based on a change that Microsoft made in 2019 to its licensing terms and conditions for products without License Mobility, such as Windows Server, when deployed on [Listed Providers](https://www.microsoft.com/licensing/docs/view/Listed-Providers) (for example, Alibaba, AWS, or Google Cloud). Under the new terms, you can't bring your own Windows Server licenses to AWS but must instead use license-included instances. However, if you purchased perpetual licenses prior to that date, then you can still deploy those Windows Server licenses on Amazon EC2 Dedicated Hosts.

### Physical-level licenses
<a name="sql-server-rec-physical"></a>

Licensing at the physical core level enables you to license just the physical cores of a host, so that you can then deploy a maximum number of instances without impacting the number of licenses required. This is typically done by using Windows Server Datacenter and SQL Server Enterprise edition.

As an example, consider an R5 dedicated host with 48 cores, which translates to 96 vCPUs. If you use Windows Server Datacenter edition, you only need 48 licenses. This enables you to deploy a combination of instances with up to 96 vCPUs, as the following diagram shows.

![\[Physical-level licenses\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/r5_dh_licenses.png)


This approach can be especially cost-effective if you have enough workloads to maximize the number of instances that you can run on a host. By licensing at the physical core level, you can avoid additional licensing costs for each instance and achieve the best possible value for your licensing investment.

### License at the physical core level of SQL Server
<a name="sql-server-rec-physical-core"></a>

In shared tenancy, SQL Server licensing is based on the number of vCPUs allocated to the instance. In contrast, with dedicated hosts, you can license SQL Server Enterprise edition at the physical core level or at the vCPU level.

As with the previous example of the R5 dedicated host, if you license SQL Server Enterprise edition at the physical core level, then you only need 48 SQL Server Enterprise edition licenses to license the hosts. In contrast, in shared tenancy, where the only option is to license by vCPU, you must have 96 SQL Server Enterprise edition licenses for the same workload. Therefore, dedicated hosts can save you up to 50 percent on SQL Server licensing costs compared to shared tenancy. This is in addition to saving on instance costs by bringing eligible Windows licenses.

### Consolidate SQL Server instances
<a name="sql-server-rec-consolidate-instances"></a>

[SQL Server consolidation](consolidate-instances.md) is the process of combining multiple SQL Server instances onto one server. SQL Server requires a minimum of four core licenses per instance, even if the instance only has two vCPUs. This means that running SQL Server on servers with less than four cores can cause you to over-license these instances and use more licenses than necessary.

![\[SQL Server consolidation\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/sql_server_consolidation.png)


For example, consolidating two instances with two vCPUs each into a single instance with four vCPUs can reduce the licensing requirement by 50 percent. This is because only four core licenses are required instead of eight.

For more information about consolidation, see the [SQL Server consolidation](consolidate-instances.md) section of this guide.

### Downgrade SQL Server editions
<a name="sql-server-rec-downgrade-editions"></a>

[Changing SQL Server editions](sql-server-editions.md) can be a key strategy for optimizing licensing usage and reducing costs. The Enterprise edition of SQL Server is considerably more expensive than the Standard edition, so the downgrading can result in significant cost savings.

Transparent Data Encryption (TDE) and Always On availability groups are two popular features in SQL Server Enterprise edition. There are, however, cost-effective alternatives to these features that you can consider if you don't require the full feature set of SQL Server Enterprise edition. For example, you could get TDE in SQL Server Standard edition starting with SQL Server 2019. In place of Always On availability groups, you could use failover clustering with shared storage on FSx for Windows File Server for high availability with SQL Server Standard edition.

By downgrading from SQL Server Enterprise edition to SQL Server Standard edition, you can significantly reduce your licensing costs. For more information, see the [Optimizing cost for your high availability SQL Server deployments on AWS](https://aws.amazon.com/blogs/storage/optimizing-cost-for-your-high-availability-sql-server-deployments-on-aws/) post on the AWS Storage Blog.

In addition to reducing licensing costs, downgrading SQL Server editions can help reduce your Software Assurance spending and help you avoid future true-ups. If you return unused licenses to the shelf, you can avoid additional licensing costs and achieve the best possible value from your licensing investment.

It's important to evaluate your SQL Server workloads carefully and determine which features are critical for your business needs. For more information, see [Assessing your environment](https://docs.aws.amazon.com/prescriptive-guidance/latest/evaluate-downgrading-sql-server-edition/assess-environment.html) in AWS Prescriptive Guidance, and determine whether your Microsoft SQL Server database uses SQL Server Enterprise edition-specific features.

If you choose the right edition of SQL Server and use alternatives to SQL Server Enterprise edition features, you can achieve significant cost savings while maintaining compliance and meeting your business needs. For more information about downgrading options, see the [Compare SQL Server editions](sql-server-editions.md) section of this guide.

### Use SQL Server Developer edition in non-production environments
<a name="sql-server-rec-dev-edition"></a>

In non-production environments, you can deploy licensable editions of SQL Server, such as Enterprise or Standard edition, by using MSDN subscriptions in on-premises environments. However, the MSDN subscription doesn't have License Mobility. So, if you migrate to AWS, you can't bring those licenses over. You must use SQL Server Developer edition instead.

SQL Server Developer edition is a fully-featured edition of SQL Server that's available for free. This edition is available for SQL Server versions 2016 and later. You can download it from the Microsoft website. SQL Server Developer edition is intended to be used in all non-production environments, such as development, testing, and staging, as long as it's not connecting to live production data.

If you use SQL Server Developer edition in non-production environments, you can avoid additional licensing costs. For more information, see the [Evaluate SQL Server Developer edition](sql-server-dev.md) section of this guide.

### Optimize CPU for SQL Server workloads
<a name="sql-server-rec-cpu-sql"></a>

In some cases, you could be required to choose an instance type with more CPUs than are required for your workload due to other factors such as RAM or networking limits. However, AWS provides a solution to help you optimize your licensing costs in these situations.

You can, like most customers who bring SQL Server core licenses, disable hyperthreading or turn off CPUs on the EC2 instance to limit the number of available CPUs to the host. This option enables you to take advantage of other instance capabilities, such as RAM, while still saving on the cost of purchasing extra licenses.

For example, if you deploy an r5.4xlarge instance because your workload requires 128 GB of memory but you only need eight cores of SQL Server, then you can disable hyperthreading of an instance with just eight active CPUs. By doing this, you can save 50 percent on required SQL Server licenses, as you only need to license the eight cores that are actively being used.


****  

| Instance type | Total vCPUs | Active vCPU with Optimize CPUs feature | SQL Server license savings | 
| --- | --- | --- | --- | 
| r5.4xlarge | 16 | 8 | 50% | 
| r5.12xlarge | 48 | 8 | 83% | 

The Optimize CPU feature can be configured during the Amazon EC2 launch configuration or by modifying an existing instance. It can also be applied to both BYOL and license-included Amazon EC2 instances. This flexibility helps you to rightsize your CPU to your workload’s needs, while also reducing Windows Server and SQL Server licenses. For license-included Amazon EC2 instances, reducing CPUs provides an instant savings on licensing costs.

If you rightsize your instances, you can ensure that you're using the most cost-effective instance types for your workloads. As AWS introduces new instance types, it's important to evaluate whether these new instances can satisfy workload requirements with fewer cores.

## Additional resources
<a name="additional-resources"></a>
+ [Amazon Web Services and Microsoft: Frequently Asked Questions](https://aws.amazon.com/windows/faq/) (AWS documentation)

# Select the right EC2 instance for SQL Server workloads
<a name="right-ec2-instance"></a>

**Important**  
Before you read this section, we recommend that you first read the [Understand SQL Server licensing](sql-server-licensing.md) and [Select the right instance type for Windows workloads](right-size-selection.md) sections of this guide.

## Overview
<a name="right-ec2-instance-overview"></a>

Microsoft SQL Server has been running on Amazon Elastic Compute Cloud (Amazon EC2) instances for over 15 years. AWS has taken that experience and used it to help develop Amazon EC2 instances to fit SQL Server workloads running from minimal specifications all the way to high performance, multi-Region clusters.

Choosing the correct EC2 instance for SQL Server is largely dependent on your workload. Understanding how SQL Server is licensed, how it uses memory, and how SQL Server features align with Amazon EC2 offerings can help guide you to the best EC2 instance for your application.

This section addresses a variety of SQL Server workloads and how they can be paired with certain EC2 instances to keep your licensing and compute costs to a minimum.

## Cost comparison
<a name="right-ec2-instance-cost-comparison"></a>

Amazon EC2 enables you to Bring Your Own License (BYOL) or pay as you go with Windows Server and SQL Server licensing. For pay-as-you-go licensing, the licensing costs for the Windows Server and SQL Server licenses are baked into the hourly cost of the EC2 instance. For example, you can have different AMIs with different prices. The price of the AMI is contingent on the SQL Server edition that the AMI runs on.

Windows Server and SQL Server pricing isn't itemized. You won't find itemized pricing on tools like the [AWS Pricing Calculator](https://calculator.aws/). If you select different combinations of license-included offerings, the licensing costs can be deduced, as the following table shows.


****  

| EC2 instance | AMI | Compute price | Windows license price | SQL license price | Total price | 
| --- | --- | --- | --- | --- | --- | 
| r5.xlarge | Linux (compute pricing) | \$1183.96 | - | - | \$1183.96 | 
| r5.xlarge | Linux \$1 SQL Developer | \$1183.96 | \$10 | \$10 | \$1183.96 | 
| r5.xlarge | Windows Server (LI) | \$1183.96 | \$1134.32 | - | \$1318.28 | 
| r5.xlarge | Windows \$1 SQL Developer | \$1183.96 | \$1134.32 | \$10 | \$1318.28 | 
| r5.xlarge | Windows \$1 SQL Web (LI) | \$1183.96 | \$1134.32 | \$149.64 | \$1367.92 | 
| r5.xlarge | Windows \$1 SQL Standard (LI) | \$1183.96 | \$1134.32 | \$1350.4 | \$1668.68 | 
| r5.xlarge | Windows \$1 SQL Enterprise (LI) | \$1183.96 | \$1134.32 | \$11095 | \$11413.28 | 

**Note**  
Pricing in the preceding table is based on the on-demand pricing in the `us-east-1` Region.

The most cost-effective method for running SQL Server is to stay at a lower-level edition until you need a feature from a higher-level edition. For more information, see the [Compare SQL Server editions](sql-server-editions.md) section of this guide. Upgrading from SQL Server Web edition to SQL Server Standard edition is over seven times the SQL Server licensing cost and over three times the cost of moving from Standard edition to Enterprise edition. The disparity in licensing costs is a major factor to consider and is explored in the rest of this section.

## Cost optimization scenario
<a name="right-ec2-instance-opt-scenario"></a>

Consider an example scenario where an analytics company tracking delivery vehicles is seeking to improve its SQL Server performance. After a MACO expert reviews the company's performance bottlenecks, the company transitions from x1e.2xlarge instances to x2iedn.xlarge instances. Although the instance size is smaller, the enhancements to the x2 instances improve SQL Server performance and optimization by using buffer pool extensions. This allowed the company to downgrade from SQL Server Enterprise edition to SQL Server Standard edition and reduce its SQL Server licensing from 8 vCPUs to 4 vCPUs.

Before optimization:


****  

| Server | EC2 instance | SQL Server edition | Monthly cost | 
| --- | --- | --- | --- | 
| ProdDB1 | x1e.2xlarge | Enterprise | \$13,918.64 | 
| ProdDB2 | x1e.2xlarge | Enterprise | \$13,918.64 | 
| Total |   |   | \$17,837.28 | 

After optimization:


****  

| Server | EC2 instance | SQL Server edition | Monthly cost | 
| --- | --- | --- | --- | 
| ProdDB1 | x2iedn.xlarge | Standard | \$11,215.00 | 
| ProdDB2 | x2iedn.xlarge | Standard | \$11,215.00 | 
| Total |   |   | \$12,430.00 | 

The combined changes from x1e.2xlarge instances to x2iedn.xlarge instances enabled the example customer to save \$15,407 per month on their production database servers. This reduced the total cost of the workload by 69 percent.

**Note**  
Pricing in the preceding table is based on the on-demand pricing in the `us-east-1` Region.

## Cost optimization recommendations
<a name="right-ec2-instance-opt-rec"></a>

### Memory optimized instances
<a name="right-ec2-instance-memory-opt"></a>

One of the most important aspects of SQL Server is understanding its reliance on memory. SQL Server attempts to use all available RAM not being used by the operating system (up to 2 TB for a default installation). It does this for performance reasons. Working with data in memory is much more performant than having to constantly pull data from disk, make changes, and then write it back to the disk. Instead, SQL Server attempts to load as much data from the attached databases as possible and keeps that data in RAM. Changes made to the data happen in memory and are hardened to disk at a later time.

**Note**  
For a detailed explanation of how SQL Server writes changes, see [Writing Pages](https://learn.microsoft.com/en-us/sql/relational-databases/writing-pages?view=sql-server-ver16) in the Microsoft documentation.

Since SQL Server performs better with larger amounts of RAM, we typically recommend starting with [Amazon EC2 memory optimized](https://aws.amazon.com/ec2/instance-types/#Memory_Optimized) instance types. Memory optimized instances are versatile and offer a variety of different options. The R family has a 1-to-8 vCPU-to-RAM ratio and has options for Intel processors, AMD processors, enhanced networking, enhanced EBS performance, instance storage, and enhanced processor speed. For memory-heavy workloads, there's also an X family that combines many of the same options and extends the vCPU-to-RAM ratio to 1-to-32. Due to the versatility of memory optimized instances, you can apply them to SQL Server workloads of all shapes and sizes.

### Workloads below minimal resources (less than 4 vCPUs)
<a name="min-resources-4"></a>

Although some use cases work well with burstable (T3) instances, we recommend that you generally avoid using burstable instances for SQL Server workloads. The licensing for SQL Server is based on the number of vCPUs assigned to an instance. If SQL Server is idle the majority of the day and is acquiring burst credits, you pay for SQL licenses which you aren't fully utilizing. In addition, SQL Server has a minimum license requirement of 4 cores per server. This means if you have a SQL Server workload that doesn't require 4 vCPUs worth of compute power, you're paying SQL Server licensing which you aren't using. In these scenarios, it would be best to [consolidate multiple SQL Server instances](consolidate-instances.md) onto a larger server.

### Workloads using minimal resources (less than 64 GB RAM)
<a name="min-resources-64"></a>

Many SQL Server workloads under 64 GB RAM don't prioritize high performance or high availability. For these types of workloads, SQL Server Web edition might be a good fit if the application is covered under Microsoft's licensing restrictions.

**Important**  
SQL Server Web edition has a restricted use case based on Microsoft's licensing terms. SQL Server Web edition may be used only to support public and internet accessible webpages, websites, web applications, and web services. It may not be used to support line-of-business applications (for example, customer relationship management, enterprise resource management, and other similar applications).

SQL Server Web edition scales up to 32 vCPUs and 64 GB RAM and is 86 percent less expensive than SQL Server Standard edition. For low resource workloads, using an AMD memory optimized instance like the r6a, which has a 10 percent less expensive compute price than its Intel counterpart, is also a good way to keep compute and SQL licensing costs to a minimum.

### Workloads with average resources (less than 128 GB RAM)
<a name="avg-resources-128"></a>

SQL Server Standard edition is used on the majority of SQL Server workloads up to 128 GB RAM. SQL Server Standard edition is 65–75 percent less expensive than SQL Server Enterprise edition and can scale up to 48 vCPUs and 128 GB RAM. Since the 128 GB RAM limitation is typically hit before the 48 vCPU limitation, it's the focus of most customers who want to avoid upgrading to SQL Server Enterprise edition.

SQL Server has a feature called the [buffer pool extension](https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/buffer-pool-extension?view=sql-server-ver16). This feature enables SQL Server to use a portion of a disk to act as an extension of RAM. The buffer pool extension works well when combined with ultra-fast storage, like the NVMe SSDs used in [Amazon EC2 instance storage](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html). Amazon EC2 instances containing instance storage are denoted with a "d" in the instance name (for example, r5d, r6id, and x2iedn).

Buffer pool extensions are not a replacement for normal RAM. However, if you require more than 128 GB of RAM, you can use buffer pool extensions with EC2 instances like the r6id.4xlarge and x2iedn.xlarge to delay an upgrade to Enterprise edition licensing.

### High performance workloads (more than 128 GB RAM)
<a name="high-per-workloads-128"></a>

SQL Server workloads requiring high performance are challenging for cost optimization because of their reliance on a lot of resources. However, understanding the differences in EC2 instances can prevent you from making the wrong choice.

The following table shows a variety of memory optimized EC2 instances and their performance limits.


****  

|   | r5b | r6idn | r7iz | x2iedn | x2iezn | 
| --- | --- | --- | --- | --- | --- | 
| Processor | 3.1 GHz2nd Generation Intel Xeon Processor | 3.5 GHz3rd Generation Intel Xeon Processor | 3.9 GHz4th Generation Intel Xeon Scalable Processor | 3.5 GHz3rd Generation Intel Xeon Processor | 4.5 GHz2nd Generation Intel Xeon Processor | 
| CPU:RAM ratio | 1:8 | 1:8 | 1:8 | 1:32 | 1:32 | 
| Max vCPU | 96 | 128 | 128 | 128 | 48 | 
| Max RAM | 768 GB | 1,024 GB | 1,024 GB | 4,096 GB | 1,536 GB | 
| Instance storage | – | NVMe SSD(4x 1900 GB) | – | NVMe SSD(2x 1900 GB) | – | 
| io2 Block Express | Supported | Supported | Supported | Supported | – | 
| Max EBS IOPS | 260,000 | 350,000 | 160,000 | 260,000 | 80,000 | 
| Max EBS throughput | 60 Gbps | 80 Gbps | 40 Gbps | 80 Gbps | 19 Gbps | 
| Max network bandwidth | 25 Gbps | 200 Gbps | 50 Gbps | 100 Gbps | 100 Gbps | 

Each instance is used for a different purpose. Understanding your SQL Server workload can help you choose the instance type that's best for you.

Details on attributes:
+ **r5b** – The "b" attribute in r5b means this instance type is focused on high EBS performance. In the fifth generation of memory optimized instances, the r5b was the preferred choice. It was the first instance type to utilize io2 Block Express volumes and reach maximum storage IOPS of 260,000. The r5b instance type is still a cost-effective alternative for high EBS performance needs.
+ **r6idn** – The sixth generation of memory optimized instances offered considerable improvements over the previous generation. The EBS performance enhancements from the r5b are taken a step further with the r6idn, bumping up the maximum IOPS to 350,000. The r6idn also has an instance store volume for tempdb and buffer pool extensions to further increase SQL Server performance.
+ **x2iedn** – The x2iedn is similar to the r6idn. It offers similar levels of enhanced EBS, enhanced networking, and NVMe SSD instance storage, but with a 1:32 vCPU-to-RAM ratio for high memory workloads and low CPU quantity (lower SQL Server licensing costs).
+ **x2iezn** – The "z" attribute in x2iezn indicates this instance type is focused on high processor performance. The Cascade Lake processor has an all-core turbo frequency up to 4.5 GHz. We recommend that you use this EC2 instance, coupled with a 1:32 vCPU-to-RAM ratio, in a scenario where you want to keep vCPU quantity low. This, in turn, can keep SQL Server licensing costs low.
+ **r7iz** – The "z" attribute in r7iz indicates this instance type is focused on high processor performance. The Sapphire rapids processor has an all-core turbo frequency up to 3.9 GHz. Like the x2iezn instances, the r7iz prioritizes high frequency processor performance but with a 1:8 vCPU-to-RAM ratio.

## Additional resources
<a name="right-ec2-instance-resources"></a>
+ [General purpose Amazon EC2 instances](https://aws.amazon.com/ec2/instance-types/) (AWS documentation)
+ [Comparison tool](https://instances.vantage.sh/) (Vantage)
+ [Licensing – SQL Server](https://aws.amazon.com/windows/faq/#licensing-sql) (AWS documentation)

# Consolidate instances
<a name="consolidate-instances"></a>

This section focuses on the cost optimization technique of combining multiple SQL Server instances onto the same server to minimize licensing costs and maximize resource utilization.

## Overview
<a name="consolidate-instances-overview"></a>

Creating an instance is part of the process for installing the SQL Server Database Engine. The SQL Server instance is a complete install, containing its own server files, security logins, and system databases (master, model, msdb, and tempdb). Because an instance has all its own files and services, you can install multiple SQL Server instances on the same operating system without the instances interfering with each other. However, since the instances are all installed on the same server, they all share the same hardware resources, such as compute, memory, and networking.

It's typical to use only a single SQL Server instance per server in production environments so that a "busy" instance doesn't overuse the shared hardware resources. Giving each SQL Server instance its own operating system, with its own resources, is a better boundary than relying on resource governance. This is especially true for high performance SQL Server workloads that require large amounts of RAM and CPU resources.

However, not all SQL Server workloads use a large amount of resources. For example, some organizations assign each of their customers their own dedicated SQL Server instance for compliance or security purposes. For smaller clients or clients that aren't typically active, that means running the SQL Server instances with minimal resources.

As noted in the [Microsoft SQL Server 2019: Licensing guide](https://download.microsoft.com/download/e/2/9/e29a9331-965d-4faa-bd2e-7c1db7cd8348/SQL_Server_2019_Licensing_guide.pdf), each server running SQL Server must account for a minimum of four CPU licenses. This means that even if you run a server with only two vCPUs, you must still license SQL Server for four vCPUs. Based on [Microsoft's public SQL Server pricing](https://www.microsoft.com/en-us/sql-server/sql-server-2022-pricing) that's a difference of \$13,945 if you use SQL Server Standard edition. For organizations running multiple servers with single SQL Server instances using minimal resources, the combined cost of having to license unused resources can be substantial.

## Cost optimization scenario
<a name="consolidate-instances-cost-opt-scenario"></a>

This section explores an example scenario that compares the difference between running four Windows Server servers, each with a single SQL Server instance, to a single larger Windows Server server running multiple SQL Server instances simultaneously.

If each SQL Server instance only needs two vCPUs and 8 GB RAM, the total cost per server is \$17,890 for the SQL Server license in addition to an hourly compute cost of \$10.096.


****  

| EC2 instance | vCPUs | RAM | Price | vCPUs to license | Total SQL Server licensing cost | 
| --- | --- | --- | --- | --- | --- | 
| m6i.large | 2 | 8 | 0.096 | 4 | \$17,890 | 

Expanding this out to four servers, the total cost is \$131,560 for the SQL Server license with an hourly compute cost of \$10.384.


****  

| EC2 instance | vCPUs | RAM | Price | vCPUs to license | Total SQL Server licensing cost | 
| --- | --- | --- | --- | --- | --- | 
| 4x m6i.large | 2 | 32 | 0.384 | 16 | \$131,560 | 

If you combine all four SQL Server instances onto a single EC2 instance, the total amount of compute resources and compute stays the same. However, by removing unnecessary SQL Server licensing costs, you can reduce the total cost to run the workload by \$115,780.


****  

| EC2 instance | vCPUs | RAM | Price | vCPUs to license | Total SQL Server licensing cost | 
| --- | --- | --- | --- | --- | --- | 
| m6i.2xlarge | 8 | 32 | 0.384 | 8 | \$115,780 | 

**Note**  
In the preceding tables, compute costs show hourly on-demand pricing for Amazon EC2 servers running Windows Server in the `us-east-1` Region. The SQL Server Standard Edition licensing costs are referring to [Microsoft's public SQL Server pricing](https://www.microsoft.com/en-us/sql-server/sql-server-2022-pricing).

## Cost optimization recommendations
<a name="consolidate-instances-cost-opt-rec"></a>

If you're considering consolidating SQL Server instances, the biggest concern is the resource consumption for each of the instances that you want to consolidate. It's important to get performance metrics over long periods to get a better understanding of the workload patterns on each server. Some common tools for resource consumption monitoring are [Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-metrics-basic-detailed.html), [Windows Performance Monitor](https://techcommunity.microsoft.com/blog/askperf/windows-performance-monitor-overview/375481) (perfmon), and the [native monitoring tools](https://learn.microsoft.com/en-us/sql/relational-databases/performance/performance-monitoring-and-tuning-tools?view=sql-server-ver16) of SQL Server.

We recommend that you consider the following questions when analyzing whether your SQL Server workloads could be combined to use the same server resources without them interfering with one another:
+ What resources (CPU, memory, and network bandwidth) are consumed during your steady state?
+ What resources (CPU, memory, and network bandwidth) are consumed during spikes?
+ How often do spikes take place? Are spikes consistent?
+ Do the resource spikes of one server coincide with the resource spikes of another server?
+ What are the storage IOPS and throughput used by SQL Server?

If you wish to move forward with a plan to combine SQL Server instances, see the [Run multiple instances of SQL Server on one Amazon EC2 instance](https://aws.amazon.com/blogs/mt/run-multiple-instances-sql-server-on-one-amazon-ec2-instance/) post on the AWS Cloud Operations & Migrations Blog. This post provides instructions on how to make the configuration changes in SQL Server to add additional instances. Before you get started, consider the minor differences when multiple instances are installed on the same server:
+ The default SQL Server database instance is named `MSSQLSERVER` and uses port 1433.
+ Each additional instance installed on the same server is a "named" database instance.
+ Each named instance has a unique instance name and a unique port.
+ The [SQL Server Browser](https://learn.microsoft.com/en-us/sql/tools/configuration-manager/sql-server-browser-service?view=sql-server-ver16) must run to coordinate traffic to the named instances.
+ Each instance can use separate locations for database data files and separate logins.
+ The SQL Server [max server memory settings](https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/server-memory-server-configuration-options?view=sql-server-ver16) must be configured according to the performance needs of each instance, with their combined total also leaving enough memory for the underlying operating system.
+ You can use the SQL Server [native backup and restore](https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/back-up-and-restore-of-sql-server-databases?view=sql-server-ver16) capabilities or [AWS DMS](https://aws.amazon.com/blogs/database/consolidate-data-from-identical-sql-server-databases-into-a-single-amazon-rds-for-sql-server-database-using-aws-dms/) for migration or consolidation.

## Additional resources
<a name="consolidate-instances-resources"></a>
+ [SQL Server Licensing Datasheet](https://download.microsoft.com/download/0/5/c/05c60185-ebdd-4472-895a-3d8e8da55682/SQL_Server_2019_Licensing_Datasheet.pdf) (AWS Cloud Operations & Migrations Blog)
+ [SQL Server Multiple instance setup blog post](https://aws.amazon.com/blogs/mt/run-multiple-instances-sql-server-on-one-amazon-ec2-instance/) (AWS Cloud Operations & Migrations Blog)

# Compare SQL Server editions
<a name="sql-server-editions"></a>

## Overview
<a name="sql-server-editions-overview"></a>

Microsoft SQL Server licensing is one of the largest expenses for a Windows workload environment. Licensing costs for SQL Server can easily extend beyond the compute costs to run the workload. If you choose the wrong edition, you could pay for features that you aren't using or don't even need. This section compares the following SQL Server editions, including their features and relative costs:
+ **Enterprise** – SQL Server Enterprise edition provides data center capabilities with high performance, unlimited virtualization, and several business intelligence (BI) tools.
+ **Standard** – SQL Server Standard edition provides basic data management and business intelligence for smaller organizations and departments.
+ **Web** – SQL Server Web edition is suitable for companies that are web hosters or web value added providers (VAPs). This edition offers a low total cost of ownership, and it provides scalability and manageability capabilities for small to large scale web properties. 
**Important**  
You can use SQL Server Web edition to support only public and internet accessible webpages, websites, web applications, and web services. You can't use SQL Server Web edition to support line-of-business applications (such as customer relationship management or enterprise resource management applications).
+ **Developer** – SQL Server Developer edition includes all the functionality of Enterprise edition, but it's intended for development purposes only.
+ **Express** – SQL Server Express edition is a free database and can be used for learning or for building desktop applications. You can update Express edition to other editions.

**Note**  
SQL Server Evaluation edition is available for a 180-day trial period.

## Cost impact
<a name="sql-server-editions-cost-impact"></a>

You can purchase SQL Server licenses from a Microsoft reseller and bring them to AWS with Software Assurance. Alternatively, you can use SQL Server licenses with a pay-as-you-go model that has license-included Amazon EC2 AMIs.

If you purchase SQL Server licenses from Microsoft resellers, the core licenses are sold in packs of two and you must license a minimum of four cores per server. The following table shows a cost comparison between Enterprise and Standard editions.


****  

| Version | SQL Server Enterprise edition (2 cores pack) | SQL Server Standard edition (2 cores pack) | Savings | 
| --- | --- | --- | --- | 
| 2022 | \$115,123 | \$13,945 | 74% | 
| 2019 | \$113,748 | \$13,586 | 74% | 

**Note**  
Pricing in the preceding table is based on Microsoft's public pricing for [SQL Server 2022](https://www.microsoft.com/en-us/sql-server/sql-server-2022-pricing) and [SQL Server 2019](https://www.microsoft.com/en-us/sql-server/sql-server-2019-pricing).

The following cost comparison shows hosting different editions of SQL Server with license-included Amazon EC2 AMIs. In this comparison, SQL Server is hosted on r6i.xlarge (4 vCPU) in the `us-east-1` Region.


****  

| Instance | Compute cost | Windows license cost | SQL Server license cost | Total | 
| --- | --- | --- | --- | --- | 
| R6i.xlarge (Linux) | \$1183.96 | – | – | \$1183.96 | 
| R6i.xlarge \$1 Windows | \$1183.96 | \$1134.32 | – | \$1318.28 | 
| R6i.xlarge \$1 SQL Server Web edition | \$1183.96 | \$1134.32 | \$149.35 | \$1367.63 | 
| R6i.xlarge \$1 SQL Server Standard edition | \$1183.96 | \$1134.32 | \$1350.4 | \$1668.68 | 
| R6i.xlarge \$1 SQL Enterprise edition | \$1183.96 | \$1134.32 | \$11,095 | \$11,413.28 | 

You can save up to 95 percent on SQL Server licensing costs by selecting the right SQL Server edition for your workload. The following table compares the cost of SQL Server licenses on r6i.xlarge instances.


****  

| Edition | % savings | 
| --- | --- | 
| Standard compared to Enterprise | 68% | 
| Web compared to Standard | 86% | 
| Web compared to Enterprise | 95% | 

In most scenarios, organizations switch from Enterprise to Standard edition, but there are some cases where switching from Standard or Enterprise edition down to Web edition is possible.

## Cost optimization recommendations
<a name="sql-server-editions-opt-rec"></a>

You can choose the best edition for your workload based on scaling limits, high availability, performance, and security. The following table shows features that are supported across SQL Server editions. This can help you decide which edition to use. This comparison applies to [SQL Server 2016 SP1 and later versions](https://learn.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2022?view=sql-server-ver16).

### Scaling limits
<a name="sql-server-editions-opt-rec-scaling"></a>

The following table compares the scaling limits of the different SQL Server editions.


****  

| Feature | Enterprise edition | Standard edition | Web edition | Express edition | 
| --- | --- | --- | --- | --- | 
| Maximum compute capacity used by a single instance of SQL Server Database Engine, SQL Server Analysis Services (SSAS), or SQL Server Reporting Services (SSRS) | Operating system maximum | Limited to lesser of 4 sockets or 24 cores | Limited to lesser of 4 sockets or 16 cores | Limited to lesser of 4 sockets or 4 cores | 
| Maximum memory for buffer pool per instance of SQL Server Database Engine | Operating system maximum | 128 GB | 64 GB | 1410 MB | 
| Maximum capacity for buffer pool extension per instance of SQL Server Database Engine | 32 times max memory configured | 4 times max memory configured | N/A | N/A | 
| Maximum relational database size | 524 PB | 524 PB | 524 PB | 10 GB | 
| Maximum memory for Columnstore caches or memory optimized data | Operating system maximum | 32 GB | 16 GB | 352 MB | 

If your application requires fewer than 16 cores (32 vCPUs) and 64 GB of RAM, then you can start evaluating from SQL Server Web edition. If your workload requires more than 64 GB of memory or other high availability options, then you must upgrade to SQL Server Standard edition.

You can use SQL Server Web edition to support public and internet accessible webpages, websites, web applications, and web services, but you can't use SQL Server Web edition to support line of business applications. For more information about use cases for SQL Server Web edition, contact [Microsoft Licensing Support](https://www.microsoft.com/licensing/docs/view/Licensing-Use-Rights) or your Microsoft reseller.

You can use SQL Server Standard edition for workloads up to 24 cores (48 vCPUs) and 128 GB memory. However, you can use [buffer pool extensions](https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/buffer-pool-extension?view=sql-server-ver16) to enable SQL Server Standard edition to utilize [local instance storage](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html), like those present in r6id EC2 instances. This extends memory up to the size of four times the maximum memory configuration. This combination of features can delay a server from having to upgrade to Enterprise edition when memory requirements start to rise.

You can identify memory utilization by finding the databases pages in the buffer pool and [page life expectancy](https://learn.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-node?view=sql-server-ver16) counters. Page life expectancy tells you how long the page is in memory before being flushed back to disk. This counter default value is 300. If pages are residing in memory for hours or days, then there is a chance of reducing allocated memory.

### High availability
<a name="sql-server-editions-opt-rec-avail"></a>

The following table compares the high availability capabilities of the different SQL Server editions.


****  

| Feature | Enterprise edition | Standard edition | Web edition | Express edition | 
| --- | --- | --- | --- | --- | 
| Server core support 1 | Yes | Yes | Yes | Yes | 
| Log shipping | Yes | Yes | Yes | No | 
| Database mirroring | Yes | FULL safety mode | Only as witness | Only as witness | 
| Backup compression | Yes | Yes | No | No | 
| Always On failover cluster instances | 16 nodes | 2 nodes | No | No | 
| Always On availability groups | Up to 8 secondary replicas, including 2 synchronous secondary replicas | No | No | No | 
| Basic availability groups | No | 2 nodes | No | No | 
| Online page and file restore | Yes | No | No | No | 
| Online indexing | Yes | No | No | No | 
| Online schema change | Yes | No | No | No | 
| Fast recovery | Yes | No | No | No | 
| Mirrored backups | Yes | No | No | No | 
| Hot add memory and CPU | Yes | No | No | No | 
| Encrypted backup | Yes | Yes | No | No | 
| Hybrid backup to Microsoft Azure (backup to URL) | Yes | Yes | No | No | 
| Failover server for disaster recovery | Yes | Yes | No | No | 
| Failover servers for high availability | Yes | Yes | No | No | 

### Other common features
<a name="sql-server-editions-opt-rec-features"></a>

The following table compares the most common features of the different SQL Server editions. For an extensive list of features, see [Editions and supported features of SQL Server 2019](https://learn.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2019?view=sql-server-ver16) in the Microsoft documentation.


****  

| Feature | Enterprise edition | Standard edition | Web edition | Express edition | 
| --- | --- | --- | --- | --- | 
| (Performance) Resource governor | Yes | No | No | No | 
| (Security) Transparent Database Encryption (TDE) | Yes | Yes | No | No | 
| (Security) Extensible key management (EKM) | Yes | No | No | No | 
| (Replication) Oracle publication | Yes | No | No | No | 
| (Replication) Peer to peer transactional replication | Yes | No | No | No | 
| Change data capture | Yes | Yes | No | No | 

### SQL Server Developer edition
<a name="sql-server-editions-opt-rec-developer"></a>

All non-production workloads, such as development, QA, testing, staging, and UAT environments, can use SQL Server Developer edition to save 100 percent on SQL Server licensing costs. After you [download SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-downloads), you can install SQL Server Developer edition on EC2 instances by using shared tenancy. Dedicated infrastructure isn't required for SQL Server Developer edition. For more information, see this guide's recommendation for [SQL Server Developer edition](sql-server-dev.md).

### Switching editions
<a name="sql-server-editions-opt-rec-switching"></a>

For existing workloads, switching from one edition to another edition requires extensive testing. It's a best practice to check workloads running on Enterprise or Standard editions to see if edition-specific features are used and if there are any alternative solutions for those features. For example, if you want to see if your databases are using any Enterprise-level features, you can run [dynamic management views (DMV)](https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-db-persisted-sku-features-transact-sql?view=azuresqldb-current) on all databases as the following example command shows.

`SELECT feature_name FROM sys.dm_db_persisted_sku_features; GO`

There are some Enterprise edition features that can't be captured in T-SQL, such as online re-indexing as part of SQL maintenance jobs. These must be manually verified.

### Migration considerations
<a name="sql-server-editions-opt-rec-migration"></a>

How you license SQL Server will determine your options for switching editions. AMIs, including SQL Server AMIs, have the licensing cost included in the price of the EC2 instance—the licensing cost is bound to the AMI. You can use [AWS billing codes](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/billing-info-fields.html) to verify the SQL Server version included in your AMI. For AWS license-included instances, changing the SQL Server edition inside the operating system won't change the billing associated with the AMI. You must migrate your databases to a new EC2 instance with an AMI running the new edition of SQL Server.

If you're bringing your own license, then you have more flexibility. It's usually still recommended to migrate to another EC2 instance that's running the new version. This allows for easy failback if something doesn't go as planned. However, if you must use the existing server, you can still do a side-by-side installation of SQL Server and migrate the databases between instances. For more detailed steps about side-by-side edition downgrades, see [Edition Upgrade and Downgrade in SQL Server](https://www.mssqltips.com/sqlservertip/6686/edition-upgrade-and-downgrade-in-sql-server/) on the MSSQLTips website.

## Additional resources
<a name="sql-server-editions-resources"></a>
+ [Editions and supported features of SQL Server 2022](https://learn.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2022?view=sql-server-ver16) (Microsoft Learn)
+ [sys.dm\$1db\$1persisted\$1sku\$1features (Transact-SQL)](https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-db-persisted-sku-features-transact-sql?view=azuresqldb-current) (Microsoft Learn)
+ [Which Version of SQL Server Should You Use?](https://www.brentozar.com/archive/2019/01/which-version-of-sql-server-should-you-use/) (Brent Ozar Unlimited)
+ [AWS Pricing Calculator](https://calculator.aws/#/estimate?id=e138c18348afd3853a4874681c660bc1947ec5ca) (AWS)

# Evaluate SQL Server Developer edition
<a name="sql-server-dev"></a>

## Overview
<a name="sql-server-dev-overview"></a>

[SQL Server Developer edition](https://www.microsoft.com/en-us/sql-server/sql-server-downloads) is a free edition of SQL Server that contains all the features of the Enterprise edition and can be used in any non-production environment. In the cloud, where Microsoft Developer Network (MSDN) licensing can't be used, SQL Server Developer edition is a good way to save on costs without having to provide licenses for development and testing workloads. This is especially true for teams that run large development and testing environments and seek to reduce unnecessary costs.

A production environment is defined as an environment that's accessed by the end users of an application (such as an internet website) and is used for more than gathering feedback or acceptance testing of that application. Other scenarios that constitute production environments include:
+ Environments that connect to a production database
+ Environments that support disaster recovery or backup for a production environment
+ Environments that are used for production at least some of the time, such as a server that is rotated into production during peak periods of activity

For more licensing information, see [Amazon Web Services and Microsoft: Frequently Asked Questions](https://aws.amazon.com/windows/faq/) in the AWS documentation.

## Cost impact
<a name="sql-server-dev-cost-impact"></a>

If you use SQL Server Developer edition for non-production workloads, you can save 100 percent of your current SQL Server licensing costs for development and testing environments.


****  

| SQL Server version | SQL Server Enterprise edition (2 cores pack) | SQL Server Standard edition (2 cores pack) | SQL Server Developer edition | 
| --- | --- | --- | --- | 
| 2022 | \$115,123 | \$13,945 | Free | 
| 2019 | \$113,748 | \$13,586 | Free | 

**Note**  
Pricing in the preceding table is based on Microsoft's public pricing for [SQL Server 2022](https://www.microsoft.com/en-us/sql-server/sql-server-2022-pricing) and [SQL Server 2019](https://www.microsoft.com/en-us/sql-server/sql-server-2019-pricing).

The following table compares the cost of different SQL Server editions running with 4 vCPUs and using on-demand pricing in the `us-east-2` Region. This applies to scenarios that rely on license-included instances from AWS.


****  

| EC2 instance | AMI | Compute price | Windows license price | SQL Server license price | Total price | 
| --- | --- | --- | --- | --- | --- | 
| r5.xlarge | Linux (compute pricing) | \$1183.96 | – | – | \$1183.96 | 
| r5.xlarge | Linux \$1 SQL Server Developer edition | \$1183.96 | \$10 | \$10 | \$1183.96 | 
| r5.xlarge | Windows Server (LI) | \$1183.96 | \$1134.32 | – | \$1318.28 | 
| r5.xlarge | Windows \$1 SQL Server Developer edition | \$1183.96 | \$1134.32 | \$10 | \$1318.28 | 
| r5.xlarge | Windows \$1 SQL Server Web edition (LI) | \$1183.96 | \$1134.32 | \$149.64 | \$1367.92 | 
| r5.xlarge | Windows \$1 SQL Server Standard edition (LI) | \$1183.96 | \$1134.32 | \$1350.4 | \$1668.68 | 
| r5.xlarge | Windows \$1 SQL Server Enterprise edition (LI) | \$1183.96 | \$1134.32 | \$11095 | \$11413.28 | 

### Cost optimization scenario
<a name="sql-server-dev-opt-scenario"></a>

After a data integrity company made a new acquisition, it wanted to migrate the newly acquired workload from its current location on a managed hosting provider to consolidate with its other workloads in the AWS Cloud. Initial pricing showed that the company's SQL Server workload would cost 60 percent more running on AWS than on the current managed service provider. A MACO SME evaluated the estimation and found that the customer was actually paying for SQL Server licenses at the managed hosting provider for their development and testing environments. By switching the non-production workloads to SQL Server Developer edition during the migration, the company reduced their SQL Server licensing by 40 percent.

### SQL Server license included on Amazon EC2
<a name="sql-server-dev-opt-scenario-li"></a>

If you have SQL Server on EC2 instances that use [license-included AMIs](https://docs.aws.amazon.com/sql-server-ec2/latest/userguide/sql-server-on-ec2-amis.html), it's not possible to do a direct conversion from Enterprise edition to Developer edition. The licensing costs for license-included instances are bound to the AMI. Even if SQL Server is uninstalled from within the operating system, the EC2 instance is still charged for licensing costs.

To convert to Developer edition, you must [download SQL Server Developer edition](https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe), install it on a new EC2 instance, and then migrate your databases. You can migrate SQL Server databases between EC2 instances by using a variety of methods. For more information, see [SQL Server database migration methods](https://docs.aws.amazon.com/prescriptive-guidance/latest/migration-sql-server/methods.html) in the *Migrating Microsoft SQL Server databases to the AWS Cloud* guide. You can also use the [Automated SQL Server Developer solution](https://aws.amazon.com/blogs/modernizing-with-aws/automating-sql-server-developer-deployments/) to prep the new instance that you plan to migrate to.

### SQL Server BYOL on Amazon EC2
<a name="sql-server-dev-opt-scenario-byol"></a>

If you have SQL Server instances that use a BYOL, you can choose from the following in-place conversion or side-by-side downgrade options:
+ Download [SQL Server Developer edition](https://www.microsoft.com/en-us/sql-server/sql-server-downloads) from the Microsoft website. For manual or automated installation instructions, see the [Automating SQL Server Developer deployments](https://aws.amazon.com/blogs/modernizing-with-aws/automating-sql-server-developer-deployments/) post on the AWS Blog.
+ Use [SQL Server native backup and restore](https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/back-up-and-restore-of-sql-server-databases?view=sql-server-ver16) to migrate databases or detach/attach databases from one SQL instance to another.
+ Use an [automation tool](https://github.com/aws-samples/ssm-automation-deploy-sql-developer) for bulk deployments.

**Note**  
SQL Server Developer edition is for non-production environments only.

## Additional resources
<a name="additional-resources"></a>
+ [Automating SQL Server Developer deployments for deploying SQL Server Developer Edition on EC2](https://aws.amazon.com/blogs/modernizing-with-aws/automating-sql-server-developer-deployments/) (AWS Blog)
+ [SQL 2022 pricing](https://www.microsoft.com/en-us/sql-server/sql-server-2022-pricing) (Microsoft)
+ [SQL 2019 pricing](https://www.microsoft.com/en-us/sql-server/sql-server-2019-pricing) (Microsoft)
+ [Licensing options](https://docs.aws.amazon.com/sql-server-ec2/latest/userguide/sql-server-on-ec2-licensing-options.html) (SQL Server on Amazon EC2)
+ [AWS Pricing Calculator](https://calculator.aws/#/addService/ec2-enhancement) (SQL Server on Amazon EC2 documentation)
+ [Microsoft SQL Server 2019 Licensing guide](https://download.microsoft.com/download/e/2/9/e29a9331-965d-4faa-bd2e-7c1db7cd8348/SQL_Server_2019_Licensing_guide.pdf) (download from Microsoft)
+ [SQL Server 2022 Developer edition](https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe) (download from Microsoft)

# Evaluate SQL Server on Linux
<a name="sql-server-linux"></a>

## Overview
<a name="sql-server-linux-overview"></a>

Since SQL Server 2017, it's been possible to install SQL Server on Linux operating systems. SQL Server on Linux is enterprise ready and offers flexibility, high performance, security features, reduced TCO, HA/DR features, and a great user experience. You can switch from SQL Server on Windows Server to SQL Server on Linux to save on Windows Server licensing costs.

For Linux, SQL Server is available to deploy on Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), Ubuntu, and Amazon Linux 2. The SQL Server database engine runs the same way on both Windows Server and Linux, but there are some fundamental changes to certain tasks when using Linux. One key difference between running SQL Server Always On applications on Linux and Windows is related to failover clustering. If you deploy Always On availability groups on a Windows Server host, you can take advantage of [Windows Server Failover Clustering (WSFC)](https://learn.microsoft.com/en-us/sql/sql-server/failover-clusters/windows/windows-server-failover-clustering-wsfc-with-sql-server?view=sql-server-ver16) and Active Directory as built-in features that support failover clustering. However, neither WSFC nor Active Directory are available to support failover clustering on Linux. If you want to launch failover clustering for SQL Server on Linux, you can use [AWS Launch Wizard](https://aws.amazon.com/launchwizard/) to simplify cluster setup and SQL installation on Linux instances by using [ClusterLabs Pacemaker](https://aws.amazon.com/blogs/opensource/deploying-a-highly-available-microsoft-sql-server-on-linux-on-aws/).

SQL Server on Windows and Linux share a common code base. That is, the SQL Server core engine hasn't been changed, at all, to run on Linux. SQL Server introduced a Platform Abstraction Layer (SQLPAL), as shown in the following diagram.

![\[The Sequel Server Platform Abstraction Layer (SQLPAL)\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/sql_pal.png)


SQLPAL is responsible for abstraction of calls and communication between SQL Server and the underlying operating system. The host extension is simply a native Linux application. Low-level operating system functions are native calls to optimize the I/O, memory, and CPU usage. When the host extension starts, it loads and initializes SQLPAL, which then brings up SQL Server. SQLPAL launches isolated software processes that provide the required translation for the rest of the code. Adding this new layer to the SQL Server architecture means that the same enterprise-level core features and benefits that have made SQL Server so powerful on Windows are available regardless of operating system.

## Cost impact
<a name="sql-server-linux-cost-impact"></a>

For r5.2xlarge instances, the Windows Server licensing cost reduction is about \$1268 in each scenario. The reduction is a higher percentage of the total server cost compared to using less expensive SQL Server editions. The following table shows the costs savings.


****  

| Instance | Edition | Monthly cost of SQL Server on Windows | Monthly cost of SQL Server on Linux | Savings | 
| --- | --- | --- | --- | --- | 
| r5.2xlarge | Web | \$1735 | \$1466 | 37% | 
| r5.2xlarge | Standard | \$11,337 | \$11,068 | 20% | 
| r5.2xlarge | Enterprise | \$12,826 | \$12,558 | 10% | 

**Note**  
The price estimation in the preceding table is based on on-demand pricing in the `us-east-1` Region and can be viewed directly in the [AWS Pricing Calculator](https://calculator.aws/#/estimate?id=fd37122637710aa7ba46d1949e8b6a15f68d3c0f).

Consider an example scenario where an ISV customer in the SMB segment is looking to save costs on their development environment. They're already using SQL Server Developer edition on a set of Windows servers. By switching from Windows with SQL Server Developer edition to Linux with SQL Server Developer edition, the ISV customer can save 33 percent on their development workload. The following table shows the following estimated costs for this scenario.


****  

| Estimate | Monthly cost | 
| --- | --- | 
| [Windows \$1 SQL Server](https://calculator.aws/#/estimate?id=da0a0f5f58ddf91aa3398af3a78691cfa2204673) | \$19,307.72 | 
| [Linux \$1 SQL Server](https://calculator.aws/#/estimate?id=131966c579020eaec957f441c67e9aa0bfd32411) | \$16,218.36 | 
| Estimated cost savings | \$13,089.36 (33%) | 

In another example scenario, a company migrates license-included SQL Server EC2 instances from Windows to Linux. The company saves a total of \$1300,000 per year on Windows Server licensing costs—roughly 20 percent of their total AWS bill.

## Cost optimization recommendations
<a name="sql-server-linux-optrec"></a>

We recommend that you consider the following:
+ SQL Server on Linux is supported starting with SQL Server 2017.
+ To help make the switch, you can use the [Windows to Linux replatforming assistant for Microsoft SQL Server Databases](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/replatform-sql-server.html). The replatforming assistant is a scripting tool that can help you move existing SQL Server workloads from Windows to Linux operating systems by checking for common incompatibilities, exporting the databases from the Windows host, and then importing the databases into an EC2 instance running Microsoft SQL Server 2017 on Ubuntu 16.04.
+ You can also use the [backup and restore](https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/back-up-and-restore-of-sql-server-databases?view=sql-server-ver16) capabilities in SQL Server to switch from SQL Server on Windows to Linux.
+ You can easily and quickly deploy to SQL Server on Linux or Ubuntu by using the [AWS Launch Wizard](https://docs.aws.amazon.com/launchwizard/latest/userguide/what-is-launch-wizard.html). The Launch Wizard can deploy SQL Server on Linux or Ubuntu in both standalone and high availability scenarios based on your application needs. For more information, see the [Deploying to SQL Server Always on Linux with AWS Launch Wizard](https://aws.amazon.com/blogs/modernizing-with-aws/deploy-microsoft-sql-server-always-on-to-linux-with-aws-launch-wizard/) post in the Microsoft Workloads on AWS blog.

The following diagram shows an architecture for a solution that uses the Windows to Linux replatforming assistant for Microsoft SQL Server Databases.

![\[Windows to Linux replatforming assistant architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/replatforming_assistant.png)


## Additional resources
<a name="sql-server-linux-resources"></a>
+ [Overview of SQL Server on Linux](https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-overview?view=sql-server-ver16) (Microsoft Learn)
+ [Installation guide for SQL Server on Linux](https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-setup?view=sql-server-ver16) (Microsoft Learn)
+ [Deploying to SQL Server Always on Linux with AWS Launch Wizard](https://aws.amazon.com/blogs/modernizing-with-aws/deploy-microsoft-sql-server-always-on-to-linux-with-aws-launch-wizard) (Microsoft Workloads on AWS Blog)
+ [Highly Available SQL Server on Linux](https://aws.amazon.com/blogs/opensource/deploying-a-highly-available-microsoft-sql-server-on-linux-on-aws/) (AWS Open Source Blog)

# Optimize SQL Server backup strategies
<a name="sql-server-backup"></a>

## Overview
<a name="sql-server-backup-overview"></a>

Most organizations are looking for the right solution to safeguard their data on SQL Server on [Amazon EC2](https://docs.aws.amazon.com/prescriptive-guidance/latest/migration-sql-server/ec2-sql.html) to meet their current requirements for recovery point objective (RPO), the maximum acceptable amount of time since the last backup, and recovery time objective (RTO), the maximum acceptable delay between the interruption of service and restoration of service. If you're running SQL Server on EC2 instances, you have multiple options for creating backups of your data and restoring your data. Backup strategies for safeguarding data for SQL Server on Amazon EC2 include the following:
+ Server-level backup using Windows [Volume Shadow Copy Service](https://learn.microsoft.com/en-us/windows-server/storage/file-server/volume-shadow-copy-service) (VSS)-enabled Amazon Elastic Block Store (Amazon EBS) snapshots or [AWS Backup](https://aws.amazon.com/backup/)
+ Database-level backup using [native backup and restore](https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/back-up-and-restore-of-sql-server-databases) in SQL Server

You have the following storage options for [database-level native backup](https://docs.aws.amazon.com/prescriptive-guidance/latest/sql-server-managing-on-aws/database-level-backup.html):
+ A local backup with an [Amazon EBS volume](https://docs.aws.amazon.com/prescriptive-guidance/latest/sql-server-managing-on-aws/database-level-backup.html#ebs-volumes)
+ A network file system backup with [Amazon FSx for Windows File Server](https://docs.aws.amazon.com/prescriptive-guidance/latest/sql-server-managing-on-aws/database-level-backup.html#amazon-fsx) or Amazon FSx for NetApp ONTAP
+ A network backup to Amazon Simple Storage Service (Amazon S3) using [AWS Storage Gateway](https://docs.aws.amazon.com/prescriptive-guidance/latest/sql-server-managing-on-aws/database-level-backup.html#storage-gateway)
+ Direct backup to Amazon S3 for SQL Server 2022

This section does the following:
+ Highlights features to help you save on storage space
+ Compares the costs between different backend storage options
+ Provides links to in-depth documentation to help implement these recommendations

## Server-level backup using VSS-enabled snapshots
<a name="sql-server-backup-vss"></a>

A VSS-enabled snapshots architecture uses the AWS Systems Manager [Run Command](https://docs.aws.amazon.com/systems-manager/latest/userguide/run-command.html) to install the VSS agent on your SQL Server instances. You can also use the Run Command to invoke the entire workflow of flushing operating system and application buffers to the disk, pausing I/O operations, taking a point-in-time snapshot of the EBS volumes, and then resuming I/O.

This Run Command creates automated snapshots of all EBS volumes attached to a target instance. You also have the option to exclude the root volume, because user database files are usually stored on other volumes. In case you stripe multiple EBS volumes to create a single file system for SQL Server files, Amazon EBS also supports crash-consistent multivolume snapshots using a single API command. For more information about application-consistent [VSS-enabled EBS snapshots](https://aws.amazon.com/blogs/mt/take-microsoft-vss-enabled-snapshots-using-amazon-ec2-systems-manager/), see [Create a VSS application-consistent snapshot](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/application-consistent-snapshots.html) in the Amazon EC2 documentation.

The following diagram shows an architecture for server-level backup using VSS-enabled snapshots.



![\[VSS-enabled snapshots architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/snapshots_backup_arch.png)


Consider the following benefits of using VSS-enabled snapshots:
+ The first snapshot of a DB instance contains the data for the full DB instance. Subsequent snapshots of the same DB instance are [incremental](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-snapshots.html#how_snapshots_work), which means that only the data that has changed after your most recent snapshot is saved.
+ EBS snapshots provide point-in-time recovery.
+ You can [restore to a new SQL Server EC2 instance from a snapshot](https://docs.aws.amazon.com/prescriptive-guidance/latest/backup-recovery/restore.html).
+ If an instance is encrypted using Amazon EBS or if a database is encrypted in the instance using TDE, that instance or database is automatically restored with the same encryption.
+ You can copy your [automated cross-Region backups](https://docs.aws.amazon.com/ebs/latest/userguide/event-policy.html).
+ When you restore an EBS volume from a snapshot it becomes immediately available for applications to access it. This means that you can immediately bring SQL Server online after restoring one or more of its underlying EBS volumes from snapshots.
+ By default, restored volumes fetch underlying blocks from Amazon S3 the first time an application tries to read them. This means that there can be a lag in performance after an EBS volume is restored from a snapshot. The volume eventually catches up with the nominal performance. However, you can avoid that lag by using [fast snapshot-restore (FSR)](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-fast-snapshot-restore.html) snapshots.
+ You can use [lifecycle management for EBS snapshots](https://aws.amazon.com/blogs/aws/new-lifecycle-management-for-amazon-ebs-snapshots/).

Consider the following limitations of using VSS-enabled snapshots:
+ You can't perform cross-Region point-in-time recovery with an encrypted snapshot for a SQL Server instance.
+ You can't create an encrypted snapshot of an unencrypted instance.
+ You can't restore an individual database because the snapshot is taken at the EBS volume level.
+ You can't restore the instance to itself.
+ A snapshot of the DB instance must be encrypted by using the same AWS Key Management Service (AWS KMS) key as the DB instance.
+ Storage I/O is suspended for a fraction of a second (approximately 10 milliseconds) during the snapshot backup process.

## SQL Server backup using AWS Backup
<a name="sql-server-backup-aws-backup"></a>

You can use [AWS Backup](https://aws.amazon.com/backup/) to centralize and automate data protection across AWS services. AWS Backup offers a cost-effective, fully managed, policy-based solution that simplifies data protection at scale. AWS Backup also helps you support your regulatory compliance obligations and meet your business continuity goals. Together with AWS Organizations, AWS Backup enables you to centrally deploy data protection (backup) policies to configure, manage, and govern your backup activity across your organization's AWS accounts and resources.

The following diagram shows the architecture of a backup and restore solution for SQL Server on EC2 by using AWS Backup.

![\[AWS Backup architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/aws_backup_arch.png)


Consider the following benefits of backing up SQL Server by using AWS Backup:
+ You can automate backup scheduling, retention management, and lifecycle management.
+ You can centralize your backup strategy across your organization, spanning multiple accounts and AWS Regions.
+ You can centralize monitoring your backup activity and alerting across AWS services.
+ You can implement cross-Region backups for disaster recovery planning.
+ The solution supports cross-account backups.
+ You can perform secure backups with secondary backup encryption.
+ All backups support encryption by using AWS KMS encryption keys.
+ The solution works with TDE.
+ You can restore to a specific recovery point from the AWS Backup console.
+ You can back up an entire SQL Server instance, which includes all SQL Server databases.

## Database-level backup
<a name="sql-server-backup-database"></a>

These approaches use native Microsoft SQL Server backup functionality. You can take backups of individual databases on the SQL Server instance and restore an individual database.

Each of these options for native SQL Server backup and restore also support the following:
+ Compression and multiple-file backup
+ Full, differential, and T-log backups
+ TDE-encrypted databases

### SQL Server native backup and restore to Amazon S3
<a name="sql-server-backup-native-s3"></a>

SQL Server on Amazon EC2 supports native backup and restore for SQL Server databases. You can take a backup of your SQL Server database and then restore the backup file to an existing database or to a new SQL Server EC2 instance, Amazon RDS for SQL Server, or an on-premises server.

Storage Gateway is a hybrid cloud storage service that provides on-premises applications with access to virtually unlimited cloud storage. You can use Storage Gateway to back up your Microsoft SQL Server databases directly to Amazon S3, reducing your on-premises storage footprint and using Amazon S3 for durable, scalable, and cost-effective storage.

The following diagram shows the architecture of a native backup and restore solution that uses Storage Gateway and Amazon S3.

![\[Storage Gateway and Amazon S3 architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/storage_gateway_backup_arch.png)


Consider the following benefits of using native SQL Server backup with Storage Gateway:
+ You can map a storage gateway as a Server Message Block (SMB) file share on the EC2 instance and send the backup to Amazon S3.
+ The backup goes directly to the S3 bucket or through the Storage Gateway file cache.
+ Multiple-file backups are supported.

Consider the following limitations of native backup using Storage Gateway:
+ You must set up backup and restore for each individual database.
+ You must manage the [Amazon S3 lifecycle policy](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html) for the backup files.

For more information about how to set up Storage Gateway, see the [Store SQL Server backups in Amazon S3 using AWS Storage Gateway](https://aws.amazon.com/blogs/database/storing-sql-server-backups-in-amazon-s3-using-aws-storage-gateway/) post on the AWS Blog.

### SQL Server native backup to EBS volumes
<a name="sql-server-backup-native-ebs"></a>

You can take a native backup of your SQL Server database and store the file in an Amazon EBS volume. Amazon EBS is a highly performant block storage service. EBS volumes are elastic, which supports encryption. They can be detached and attached to an EC2 instance. You can back up SQL Server on an EC2 instance on the same EBS volume type or on a different EBS volume type. One advantage of backing up to a different EBS volume is cost savings.

The following diagram shows the architecture of a native backup to an EBS volume.



![\[Amazon EBS volume architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/ebs_backup_arch.png)


Consider the following benefits of using SQL Server native backup to EBS volumes:
+ You can take backups of individual databases on a SQL Server EC2 instance and restore an individual database instead of having to restore the complete instance.
+ Multiple-file backups are supported.
+ You can schedule backup jobs by using SQL Server Agent and the SQL Server job engine.
+ You can get performance benefits through your hardware choices. For example, you can use st1 storage volumes to achieve higher throughput.

Consider the following limitations of using native backup to EBS volumes:
+ You must manually move backups to Amazon S3 from the EBS volume.
+ For large backups, you must manage disk space on Amazon EC2.
+ On the EC2 instance, Amazon EBS throughput can be a bottleneck.
+ Additional storage is required to store backups on Amazon EBS.

### SQL Server native backup to Amazon FSx for Windows File Server
<a name="sql-server-backup-native-fsx"></a>

[Amazon FSx for Windows File Server](https://aws.amazon.com/fsx/windows/) is a fully managed native Windows file system that offers up to 64 TB of storage designed to deliver fast, predictable, and consistent performance. AWS introduced [native support for Multi-AZ file system deployments](https://aws.amazon.com/blogs/aws/amazon-fsx-for-windows-file-server-update-new-enterprise-ready-features/) on FSx for Windows File Server. Native support makes it easier to deploy Windows file storage on AWS with high availability and redundancy across multiple Availability Zones. AWS also introduced support for [SMB Continuously Available (CA) file shares](https://aws.amazon.com/about-aws/whats-new/2019/11/amazon-fsx-for-windows-file-server-adds-support-for-high-availability-microsoft-sql-server-deployments/). You can use FSx for Windows File Server as backup storage for a SQL Server database.

The following diagram shows the architecture of a native SQL Server backup to FSx for Windows File Server.

![\[FSx for Windows File Server backup architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/fsx_backup_arch.png)


Consider the following benefits of using native SQL Server backup to FSx for Windows File Server:
+ You can back up your SQL Server database to an Amazon FSx file share.
+ You can take backups of individual databases on a SQL Server instance and restore an individual database instead of having to restore the complete instance.
+ Multi-part backups are supported.
+ You can schedule backup jobs by using SQL Server Agent and the job engine.
+ The instances have higher network bandwidth compared to Amazon EBS.

Consider the following limitations of using native SQL Server backup to FSx for Windows File Server:
+ You must manually move backups to Amazon S3 from Amazon FSx by using AWS Backup or AWS DataSync.
+ Large backups might require additional overhead for disk space management on Amazon FSx.
+ EC2 instance network throughput can be a bottleneck.
+ Additional storage is required to store backups on FSx for Windows File Server.

### SQL Server backup to Amazon FSx for NetApp ONTAP
<a name="sql-server-backup-fsx-netapp"></a>

Snapshots with FSx for ONTAP are always crash consistent, but they require you to quiesce (or pause the I/O of) your database in order to create an application-consistent snapshot. You can use NetApp SnapCenter (an orchestration tool with plug-ins for specific applications, including SQL Server) with FSx for ONTAP to create application-consistent snapshots and protect, replicate, and clone your databases at no additional cost.

#### NetApp SnapCenter
<a name="sql-server-backup-netapp-snapcenter"></a>

NetApp SnapCenter is a unified platform for application-consistent data protection. SnapCenter refers to snapshots as backups. This guide adopts that same naming convention. SnapCenter provides a single pane of glass for managing application-consistent backups, restores, and clones. You add a SnapCenter plug-in for your specific database application to create application-consistent backups. The SnapCenter plug-in for SQL Server provides the following functionality that simplifies your data protection workflow.
+ Backup and restore options with granularity for full and log backups
+ In-place restore and restore to an alternate location

For more information about SnapCenter, see the [Protect your SQL Server workloads using NetApp SnapCenter with Amazon FSx for NetApp ONTAP](https://aws.amazon.com/blogs/storage/using-netapp-snapcenter-with-amazon-fsx-for-netapp-ontap-to-protect-your-sql-server-workloads/) post on the AWS Storage Blog.

### Cost optimization for backups
<a name="sql-server-backup-cost-opt"></a>

The following options can help you reduce the cost of storing SQL Server backups on AWS.
+ Enable [SQL Server compression](https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/backup-compression-sql-server?view=sql-server-ver16) during the creation of the backup file and send the smallest possible file to the storage. For example, a 3:1 compression ratio indicates that you are saving about 66 percent on disk space. To query on these columns, you can use the following Transact-SQL statement: `SELECT backup_size/compressed_backup_size FROM msdb..backupset;` .
+ For backups going to S3 buckets, enable the [Amazon S3 Intelligent-Tiering](https://aws.amazon.com/s3/storage-classes/intelligent-tiering/) storage class to reduce storage costs by 30 percent. 
+ For backups going to FSx for Windows File Server or FSx for ONTAP, use a single Availability Zone for 50 percent cost savings (as compared to using multiple Availability Zones). For pricing information, see [Amazon FSx for Windows File Server Pricing](https://aws.amazon.com/fsx/windows/pricing/) and [Amazon FSx for NetApp ONTAP Pricing](https://aws.amazon.com/fsx/netapp-ontap/pricing/).
+ The most efficient option for SQL Server 2022 is direct backup to Amazon S3. You can save additional costs by avoiding Storage Gateway.

### Benchmark test results for backups
<a name="sql-server-backup-benchmark"></a>

This section compares the following options from a cost and performance point of view for a sample 1 TB database, based on the results of performance benchmark testing on the backup solutions covered in this guide.
+ **EC2 instance specification **– r5d.8xlarge with Windows Server 2019 and SQL Server 2019 Developer edition
+ **Database specification** – 1 TB in size with TDE disabled

The tests were performed with an r5d.8xlarge instance and 1 TB SQL Server database as the source. The source system was configured according to best practices, and the source database contained four data files (250 GB each) and one log file (50 GB) spread across separate gp3 volumes. The SQL Server native `BACKUP` command includes writing to 10 backup files, using compression to optimize backup performance and reduce the amount of data sent across the network and written to the target. In all test cases, storage performance was the bottleneck.

There is an almost endless variety of possible configurations for these types of test. This test focused on optimizing for performance, cost, scalability, and real-world use cases. The following table shows the performance metrics that were captured for the backup target options.


****  

| Backup options | Level | Run duration (Appx) | Backup rate | Cost USD per month\$1 | 
| --- | --- | --- | --- | --- | 
| Native backup to local EBS st1 HDD, 2 TB | Database | 00:30:46 min | 554.7 Mbps | \$192.16 | 
| Native backup to local EBS SSD gp3, 2 TB | Database | 00:22:00 min | 512 Mbps | \$1193.84 | 
| Native backup to FSx for Windows File Server HDD, 2 TB @512 Mbps throughput | Database | 00:20:58 min | 814.0 Mbps | [\$11,146](https://calculator.aws/#/estimate?id=e13d8a385d25b2d4f1320c5b1156b953355b7c13) | 
| Native backup to FSx for Windows File Server SSD, 2 TB @512 Mbps throughput | Database | 00:20:00 min | 814.0 Mbps | [\$11,326](https://calculator.aws/#/estimate?id=e13d8a385d25b2d4f1320c5b1156b953355b7c13) | 
| Native backup to S3 File Gateway m6i.4xlarge (16 vCPU, 64 GB) with 2 TB gp3 | Database | 00:23:20 min | 731.5 Mbps | \$1470.42 | 
| EBS VSS snapshot | EBS volume | 00:00:02 sec00:00:53 sec | N/A snapshot | [\$151](https://calculator.aws/#/estimate?id=e13d8a385d25b2d4f1320c5b1156b953355b7c13) | 
| AWS Backup (AMI backup) | AMI | 00:00:04 sec00:08:00 min | N/A snapshot | [\$175](https://calculator.aws/#/estimate?id=e13d8a385d25b2d4f1320c5b1156b953355b7c13) | 
| Native SQL Server backup directly to Amazon S3 (SQL Server 2022) | Database | 00:12:00 min | 731.5 Mbps | [First 50 TB / Month, \$10.023 per GB \$123.55 per month](https://calculator.aws/#/estimate?id=e13d8a385d25b2d4f1320c5b1156b953355b7c13) | 
| Native backup to FSx for ONTAP (using SnapCenter) | Database | – | – | [\$1440.20](https://calculator.aws/#/estimate?id=8c9a0b2c296f9839f3ca16bdc2dcd9a6f52f1faf) | 

The preceding table assumes the following:
+ Data transfer and Amazon S3 costs are not included.
+ Storage price is included in instance pricing.
+ The costs are based in the `us-east-1` Region.
+ Throughput and IOPS grow by 10 percent with multiple backups that have an overall rate of change of 10 percent over the month.

The test results show that the fastest option is a native SQL Server database backup to FSx for Windows File Server. A backup to Storage Gateway and locally attached EBS volumes is the more cost-efficient option but has slower performance. For server-level backups (AMI), we recommend using AWS Backup for optimal performance, cost, and manageability.

## Cost optimization recommendations
<a name="sql-server-backup-opt-rec"></a>

Understanding the possible solutions for backing up SQL Server on Amazon EC2 is key to safeguarding your data, ensuring that you meet your backup needs, and putting a plan in place to recover from critical events. The different ways to back up and restore your SQL Server instances and databases explored in this section can help you devise a backup and restore strategy that protects your data and meets your organization's requirements.

This section covers the following backup options:
+ Compression
+ Amazon S3 Intelligent-Tiering
+ Single Availability Zone
+ Backup to URL

The guidance provided for each of these options is high level. If you wish to implement any of these recommendations in your organization, we recommend that you reach out to your account team. The team can then engage with a Microsoft Specialist SA to lead the conversation. You can also reach out by emailing optimize-microsoft@amazon.com.

In summary, we recommend the following:
+ If you're using SQL Server 2022, then backing up to Amazon S3 is the most cost-efficient option.
+ If you're using SQL Server 2019 and earlier SQL Server editions, consider backing up to Storage Gateway backed by Amazon S3 as the most cost-efficient option.

### Compression
<a name="sql-server-backup-opt-rec-compression"></a>

The goal of compression is to have less storage consumed by each backup, which is beneficial for various storage options. You must enable compression for a SQL Server backup at the level of the [SQL Server instance](https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/view-or-configure-the-backup-compression-default-server-configuration-option?view=sql-server-ver16). The following example shows how to add the compression keyword with a backup database:

`BACKUP DATABASE <database_name> TO DISK WITH COMPRESSION (ALGORITHM = QAT_DEFLATE)`

### Amazon S3 Intelligent-Tiering
<a name="sql-server-backup-opt-rec-tiering"></a>

For backups going to Amazon S3 buckets, you can enable [Amazon S3 Intelligent-Tiering](https://aws.amazon.com/s3/storage-classes/intelligent-tiering/) as your Amazon S3 File Gateway [storage class](https://docs.aws.amazon.com/filegateway/latest/files3/storage-classes.html#ia-file-gateway). This can reduce storage costs by up to 30 percent. You then mount S3 File Gateway to your SQL servers by using an SMB file share that can be integrated with your [Active Directory domain](https://docs.aws.amazon.com/filegateway/latest/files3/CreatingAnSMBFileShare.html#configure-SMB-settings). This provides you with access control for your share, the ability to leverage existing service accounts, and access to Amazon S3 using a common Microsoft focused file protocol. For accounts that might not have direct connectivity to a domain controller, you can use the [Active Directory Connector](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/directory_ad_connector.html) to facilitate communication with Active Directory on-premises or in the cloud. To configure the Active Directory settings on the gateway, you must specify the Active Directory Connector IPs for the domain controller to proxy requests to Active Directory.

The following diagram shows an architecture for a solution based on S3 Intelligent-Tiering.

![\[S3 Intelligent-Tiering architecture\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/ad_connector_arch.png)


By default, the backup files written to the S3 bucket use the Standard tier. To convert the backup files from the Standard tier to S3 Intelligent-Tiering, you must [create a lifecycle rule](https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-transition-general-considerations.html). You can also use the [AWS Management Console](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-intelligent-tiering.html#enable-auto-archiving-int-tiering) to enable S3 Intelligent-Tiering. For more information, see [Getting Started Using Amazon S3 Intelligent-Tiering](https://aws.amazon.com/getting-started/hands-on/getting-started-using-amazon-s3-intelligent-tiering/) in the AWS documentation.

### Single Availability Zone
<a name="sql-server-backup-opt-rec-singleAZ"></a>

To create a Single Availability Zone file system, choose the Single-AZ option when you [create an FSx for Windows File Server file system](https://docs.aws.amazon.com/fsx/latest/WindowsGuide/getting-started.html). Amazon FSx also takes highly durable backups (stored in Amazon S3) of your file system daily using the Windows Volume Shadow Copy Service, and allows you to take additional backups at any point. Keep in mind some of the issues with using a Single Availability Zone. For example, the SMB file share becomes inaccessible if an affected Availability Zone where the file system is provisioned goes down for hours at a time. If you require access to the data, you must restore it from backups in an available Availability Zone within the source Region. For more information, see the [Use a single Availability Zone](storage-fsx-single-az.md) section of this guide.

### Backup to URL
<a name="sql-server-backup-opt-rec-url"></a>

For SQL Server 2022, the [backup to URL](https://www.microsoft.com/en-us/sql-server/blog/2022/09/29/backup-and-restore-to-url-for-s3-compatible-object-storage/) feature allows direct backup to Amazon S3. This is the ideal backup approach for SQL Server 2022 running in AWS as you get the full feature set of Amazon S3 at the storage layer and remove the cost of the AWS Storage Gateway appliance needed in prior versions to facilitate this functionality. There are two primary costs to consider when implementing this feature: data transfer costs and the S3 storage class chosen. If you want the native disaster recovery capabilities of Amazon S3, then you must factor in that [cross-Region Replication](https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication.html#crr-scenario) incurs cross-Region [data egress costs](https://aws.amazon.com/s3/pricing/?p=pm&c=s3&z=4). To learn more about how to configure this option, see the [Backup SQL Server databases to Amazon S3](https://aws.amazon.com/blogs/modernizing-with-aws/backup-sql-server-to-amazon-s3/) post on the Microsoft Workloads on AWS blog.

## Additional resources
<a name="sql-server-backup-resources"></a>
+ [Backup and restore options for SQL Server on Amazon EC2](https://docs.aws.amazon.com/prescriptive-guidance/latest/sql-server-managing-on-aws/welcome.html) (AWS Prescriptive Guidance)
+ [Point-in-time recovery and continuous backup for Amazon RDS with AWS Backup](https://aws.amazon.com/blogs/storage/point-in-time-recovery-and-continuous-backup-for-amazon-rds-with-aws-backup/) (AWS Storage Blog)
+ [Protect your SQL Server workloads using NetApp SnapCenter with Amazon FSx for NetApp ONTAP](https://aws.amazon.com/blogs/storage/using-netapp-snapcenter-with-amazon-fsx-for-netapp-ontap-to-protect-your-sql-server-workloads/) (AWS Storage Blog)
+ [Getting Started Using Amazon S3 Intelligent-Tiering](https://aws.amazon.com/getting-started/hands-on/getting-started-using-amazon-s3-intelligent-tiering/) (AWS Getting Started Resource Center)
+ [Backup and Restore Strategies for Amazon RDS for SQL Server](https://aws.amazon.com/blogs/database/backup-and-restore-strategies-for-amazon-rds-for-sql-server/) (AWS Database Blog)
+ [Migrate an on-premises Microsoft SQL Server database to Amazon EC2](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/migrate-an-on-premises-microsoft-sql-server-database-to-amazon-ec2.html) (AWS Prescriptive Guidance)
+ [Best Practices for Deploying Microsoft SQL Server on Amazon EC2](https://docs.aws.amazon.com/whitepapers/latest/best-practices-for-deploying-microsoft-sql-server/best-practices-for-deploying-microsoft-sql-server.html) (AWS Whitepaper)

# Modernize SQL Server databases
<a name="modernize-sql-server"></a>

## Overview
<a name="modernize-sql-server-overview"></a>

If you're starting on a journey toward modernizing legacy databases for scalability, performance, and cost optimization, you may be facing challenges with commercial databases like SQL Server. Commercial databases are expensive, lock customers in, and offer punitive licensing terms. This section provides a high-level overview of the options for migrating and modernizing from SQL Server to open-source databases and information about choosing the best option for your workload.

You can refactor your SQL Server databases to open-source databases like Amazon Aurora PostgreSQL to save on Windows and SQL Server licensing costs. Cloud-native modern databases like Aurora merge the flexibility and low cost of open-source databases with the robust, enterprise-grade features of commercial databases. If you have variable workloads or multi-tenant workloads, you can also migrate to [Aurora serverless V2](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-v2.html). This can reduce costs by to 90 percent, depending on workload characteristics. Additionally, AWS offers capabilities like [Babelfish for Aurora PostgreSQL](https://aws.amazon.com/rds/aurora/babelfish/), tools like [AWS Schema Conversion Tool (AWS SCT)](https://aws.amazon.com/dms/schema-conversion-tool/), and services like [AWS Database Migration Service (AWS DMS)](https://aws.amazon.com/dms/) to simplify the migration and modernization of SQL Server databases on AWS.

## Database offerings
<a name="modernize-sql-server-database"></a>

Migrating from SQL Server on Windows to open-source database like Amazon Aurora, Amazon RDS for MySQL, or Amazon RDS for PostgreSQL can offer significant cost savings without compromise on performance or features. Consider the following:
+ Switching from SQL Server Enterprise edition on Amazon EC2 to Amazon RDS for PostgreSQL or Amazon RDS for MySQL can result in cost savings up to 80 percent.
+ Switching from SQL Server Enterprise edition on Amazon EC2 to Amazon Aurora PostgreSQL-Compatible Edition or Amazon Aurora MySQL-Compatible Edition can result in cost savings up to 70 percent.

For traditional database workloads, Amazon RDS for PostgreSQL and Amazon RDS for MySQL address requirements and provide a cost-effective solution for relational databases. Aurora adds numerous availability and performance features previously limited to expensive commercial vendors. The resiliency features in Aurora are an added cost. However, in comparison to similar features by other commercial vendors, the resiliency costs of Aurora are still cheaper than what commercial software charges for the same type of features. Aurora architecture is optimized to deliver significant improvements in performance as compared to standard MySQL and PostgreSQL deployments.

Because Aurora is compatible with open-source PostgreSQL and MySQL databases, there is the additional benefit of portability. Whether the best option is Amazon RDS for PostgreSQL, Amazon RDS for MySQL, or Aurora comes down to understanding business requirements and mapping necessary features to the best option.

## Amazon RDS and Aurora comparison
<a name="modernize-sql-server-rds-aurora"></a>

The following table summarizes the key differences between Amazon RDS and Amazon Aurora.


****  

| Category | Amazon RDS for PostgreSQL or Amazon RDS for MySQL | Aurora PostgreSQL or Aurora MySQL | 
| --- | --- | --- | 
| Performance | Good performance | 3x or better performance | 
| Failover | Typically 60–120 seconds\$1 | Typically 30 seconds | 
| Scalability | Up to 5 read replicaLag in seconds | Up to 15 read replicasLag in milliseconds | 
| Storage | Up to 64 TB | Up to 128 TB | 
| Storage HA | Multi-AZ with one or two standby, each with database copy | 6 copies of data across 3 Availability Zones by default | 
| Backup | Daily snapshot and log backups | Continuous, asynchronous backup to Amazon S3 | 
| Innovations with Aurora | NA | 100 GBFast database cloning | 
|   | Auto-scaling read replicas |   | 
|   | Query plan management |   | 
|   | Aurora Serverless |   | 
|   | Cross-Region replicas with Global Database |   | 
|   | Cluster cache management\$1\$1 |   | 
|   | Parallel Query |   | 
|   | Database activity streams |   | 

\$1Large transactions can increase failover times

\$1\$1Available in Aurora PostgreSQL

The following table shows the estimated monthly cost of the different database services covered in this section.


****  

| Database service | Cost USD per month\$1 | AWS Pricing Calculator (requires AWS account) | 
| --- | --- | --- | 
| Amazon RDS for SQL Server Enterprise edition | \$13,750 | [Estimate](https://calculator.aws/#/estimate?id=16f190d818045bb99fb59659cecca80f92db4bbc) | 
| Amazon RDS for SQL Server Standard edition | \$12,318 | [Estimate](https://calculator.aws/#/estimate?id=5a5e9832ae80fd9ad9e8010c9a17f57d5a0415ca) | 
| SQL Server Enterprise edition on Amazon EC2 | \$12,835 | [Estimate](https://calculator.aws/#/estimate?id=0976f53e9b1b55d5475dc394c8caae9d5581183b) | 
| SQL Server Standard edition on Amazon EC2 | \$11,345 | [Estimate](https://calculator.aws/#/estimate?id=3cada8ab6d72b68a2eb3bc92927990c9f7e264ca) | 
| Amazon RDS for PostgreSQL | \$1742 | [Estimate](https://calculator.aws/#/estimate?id=bd825d40c79c0df8f0cf053d55ca39acc8a927fe) | 
| Amazon RDS for MySQL | \$1712 | [Estimate](https://calculator.aws/#/estimate?id=c0f61d7b67652e58df5bf6cb244e9455ff4a8558) | 
| Aurora PostgreSQL | \$11,032 | [Estimate](https://calculator.aws/#/estimate?id=a557d7d740e5d87c9764bd369de81a5873dad053) | 
| Aurora MySQL | \$11,031 | [Estimate](https://calculator.aws/#/estimate?id=5924d827c98beadda65368c8e64eb249c001afd6) | 

\$1 Storage price is included in instance pricing. Costs are based on the `us-east-1` Region. The throughput and IOPS are assumptions. The calculations are for r6i.2xlarge and r6g.2xlarge instances.

## Cost optimization recommendations
<a name="modernize-sql-server-opt-rec"></a>

Heterogenous database migrations typically require converting database schema from the source to the target database engine and migrating data from source to target database. The first step toward migration is to evaluate and convert SQL server schema and code objects to the target database engine.

You can use the [AWS Schema Conversion Tool (AWS SCT)](https://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/CHAP_Welcome.html) to evaluate and assess the database for compatibility with various target open-source database options like Amazon RDS for MySQL or Amazon RDS for PostgreSQL, Aurora MySQL, and PostgreSQL. You can also use the Babelfish Compass tool for assessing compatibility with Babelfish for Aurora PostgreSQL. This makes the AWS SCT and Compass powerful tools to understand the upfront work involved before deciding on a migration strategy. Should you decide to proceed, AWS SCT automates the changes required to the schema. The core philosophy behind Babelfish Compass is to allow the SQL database to move to Aurora with no, or very few, modifications. Compass will evaluate the existing SQL database to determine if this can be accomplished. This way, the outcome is known before any effort is spent on migrating data from SQL Server to Aurora.

AWS SCT automates conversion and migration of the database schema and code to the target database engine. You can use Babelfish for Aurora PostgreSQL to migrate your database and application from SQL Server to Aurora PostgreSQL with no or minimal schema changes. This can accelerate your migrations.

After the schema is migrated, you can use AWS DMS to migrate the data. AWS DMS can perform full data load and replicate changes to perform migration with minimal downtime.

This section explores the following tools in more detail:
+ AWS Schema Conversion Tool
+ Babelfish for Aurora PostgreSQL
+ Babelfish Compass
+ AWS Database Migration Service

### AWS Schema Conversion Tool
<a name="modernize-sql-server-opt-rec-schema"></a>

You can use AWS SCT to evaluate your existing SQL Server databases and assess compatibility with Amazon RDS or Aurora. To simplify the migration process, you can also use AWS SCT to convert the schema from one database engine to another in a heterogeneous database migration. You can use AWS SCT to evaluate your application and convert embedded application code for applications written C\$1, C\$1\$1, Java, and other languages. For more information, see [Converting application SQL using AWS SCT](https://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/CHAP_Converting.App.html) in the AWS SCT documentation.

AWS SCT is a free AWS tool that supports many database [sources](https://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/CHAP_Source.html). To use AWS SCT, you point it to the source database and then run an assessment. Then, [AWS SCT](https://aws.amazon.com/blogs/database/convert-database-schemas-and-application-sql-using-the-aws-schema-conversion-tool-cli/) evaluates the schema and generates the assessment report. Assessment reports include an executive summary, complexity and migration effort, suitable target database engines, and recommendations for conversion. To download AWS SCT, see [Installing, verifying, and updating AWS SCT](https://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/CHAP_Installing.html) in the AWS SCT documentation.

The following table shows an example Executive Summary generated by AWS SCT to show the complexity involved with changing the database to different target platforms.


|  |  |  | 
| --- |--- |--- |
| **Target platform** | **Auto or minimal changes** | **Complex actions** | 
|  | **Storage objects** | **Code objects** | **Conversion actions** | **Storage objects** | **Code objects** | 
| Amazon RDS for MySQL | 60 (98%) | 8 (35%) | 42 | 1 (2%) | 1 | 15 (65%) | 56 | 
| Amazon Aurora MySQL-Compatible Edition | 60 (98%) | 8 (35%) | 42 | 1 (2%) | 1 | 15 (65%) | 56 | 
| Amazon RDS for PostgreSQL | 60 (98%) | 12 (52%) | 54 | 1 (2%) | 1 | 11 (48%) | 26 | 
| Amazon Aurora PostgreSQL-Compatible Edition | 60 (98%) | 12 (52%) | 54 | 1 (2%) | 1 | 11 (48%) | 26 | 
| Amazon RDS for MariaDB | 60 (98%) | 7 (30%) | 42 | 1 (2%) | 1 | 16 (70%) | 58 | 
| Amazon Redshift | 61 (100%) | 9 (39%) | 124 | 0 (0%) | 0 | 14 (61%) | 25 | 
| AWS Glue | 0 (0%) | 17 (100%) | 0 | 0 (0%) | 0 | 0 (0%) | 0 | 
| Babelfish | 59 (97%) | 10 (45%) | 20 | 2 (3%) | 2 | 12 (55%) | 30 | 

An AWS SCT report also provides details on the schema elements that cannot be automatically converted. You can close the AWS SCT conversion gaps and optimize target schemas by referring to [AWS migration playbooks](https://aws.amazon.com/blogs/database/the-database-migration-playbook-has-landed/). There are many database migration playbooks to assist with heterogeneous migrations.

### Babelfish for Aurora PostgreSQL
<a name="modernize-sql-server-opt-rec-babelfish"></a>

Babelfish for Aurora PostgreSQL extends Aurora PostgreSQL with the ability to accept database connections from SQL Server clients. Babelfish enables applications that were originally built for SQL Server to work directly with Aurora PostgreSQL, with few code changes and without changing database drivers. Babelfish turns Aurora PostgreSQL bilingual so that Aurora PostgreSQL can work with both the T-SQL and PL/pgSQL languages. Babelfish minimizes the efforts to migrate from SQL Server to Aurora PostgreSQL. This accelerates migrations, minimizes risk, and reduces migration costs significantly. You can continue to use T-SQL post migrations, but there is also an [option of using PostgreSQL native tools](https://aws.amazon.com/blogs/database/category/database/amazon-aurora/babelfish-for-aurora-postgresql/) for development.

The following diagram illustrates how an application using T-SQL connects to the default port 1433 in SQL Server and uses the Babelfish translator to communicate with the Aurora PostgreSQL database, while an application using PL/pgSQL can directly and simultaneously connect to the Aurora PostgreSQL database using the default port 5432 in Aurora PostgreSQL.

![\[Babelfish for Aurora PostgreSQL.\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/images/babelfish_tsql.png)


Babelfish doesn't support certain SQL Server T-SQL features. For this reason, Amazon provides assessment tools to do a line-by-line analysis of your SQL statements and determine if any of them are unsupported by Babelfish.

There are two options for Babelfish assessments. AWS SCT can assess the compatibility of your SQL Server database with Babelfish. Another option is the Babelfish Compass tool, which is a recommended solution because the Compass tool is updated in line with new releases of Babelfish for Aurora PostgreSQL.

### Babelfish Compass
<a name="modernize-sql-server-opt-rec-babelfish-compass"></a>

[Babelfish Compass](https://github.com/babelfish-for-postgresql/babelfish_compass) is a free downloadable tool that aligns with the latest release of Babelfish for Aurora PostgreSQL. In contrast, AWS SCT will support newer Babelfish versions after some time. [Babelfish Compass](https://github.com/babelfish-for-postgresql/babelfish_compass/blob/main/README.md) is run against the SQL Server database schema. You can also extract the source SQL Server database schema by using tools like SQL Server Management Studio (SSMS). Then, you can run the schema through Babelfish Compass. This generates the report detailing the compatibility of SQL Server schema with Babelfish and if any changes are needed before migrating. The Babelfish Compass tool can also automate many of these changes and ultimately accelerate your migrations.

After the assessment and changes are completed, you can migrate the schema to Aurora PostgreSQL by using SQL Server native tools like SSMS or sqlcmd. For instructions, see the [Migrate from SQL Server to Amazon Aurora using Babelfish](https://aws.amazon.com/blogs/database/migrate-from-sql-server-to-amazon-aurora-using-babelfish/) post on the AWS Database Blog.

### AWS Database Migration Service
<a name="modernize-sql-server-opt-rec-database-migration"></a>

After the schema is migrated, you can use AWS Database Migration Service (AWS DMS) to migrate the data to AWS with minimal downtime. AWS DMS not only does a full data load, but also replicates changes from source to destination while the source system is up and running. After both source and target databases are in sync, the cutover activity can take place where the application is pointed to the target database completing the migration. AWS DMS currently only performs full data load with Babelfish for an Aurora PostgreSQL target and doesn't replicate changes. For more information, see [Using Babelfish as a target for AWS Database Migration Service](https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.Babelfish.html) in the AWS DMS documentation.

AWS DMS can do both homogeneous (across the same database engine) and heterogeneous (across different database engines) migrations. AWS DMS supports many source and destination database engines. For more information, see the [Migrating your SQL Server database to Amazon RDS for SQL Server using AWS DMS](https://aws.amazon.com/blogs/database/migrating-your-sql-server-database-to-amazon-rds-for-sql-server-using-aws-dms/) post in the AWS Database Blog.

## Additional resources
<a name="modernize-sql-server-resources"></a>
+ [Goodbye Microsoft SQL Server, Hello Babelfish](https://aws.amazon.com/blogs/aws/goodbye-microsoft-sql-server-hello-babelfish/) (AWS News Blog)
+ [Convert database schemas and application SQL using the AWS Schema Conversion Tool CLI](https://aws.amazon.com/blogs/database/convert-database-schemas-and-application-sql-using-the-aws-schema-conversion-tool-cli/) (AWS Database Blog)
+ [Migrate SQL Server to Amazon Aurora PostgreSQL using best practices and lessons learned from the field](https://aws.amazon.com/blogs/database/migrate-sql-server-to-amazon-aurora-postgresql-using-best-practices-and-lessons-learned-from-the-field/) (AWS Database Blog)
+ [Validate database objects post-migration from Microsoft SQL Server to Amazon RDS for PostgreSQL and Amazon Aurora PostgreSQL](https://aws.amazon.com/blogs/database/validate-database-objects-post-migration-from-microsoft-sql-server-to-amazon-rds-for-postgresql-and-amazon-aurora-postgresql/) (AWS Database Blog)

# Optimize storage for SQL Server
<a name="storage-sql-server"></a>

## Overview
<a name="storage-sql-server-overview"></a>

This section focuses on cost optimizations for Amazon Elastic Block Store (Amazon EBS) SSD storage for SQL Server on EC2 workloads.

You have a wide variety of storage options for deploying and running SQL Server workloads on AWS. Selecting the right storage should be based on purpose, architecture, durability, performance, capacity, and cost. AWS customers running SQL Server workloads usually utilize a combination of Amazon EBS, NVMe, Amazon FSx, and Amazon Simple Storage Service (Amazon S3) storage.

Amazon EBS is network attached storage connected to EC2 compute instances and utilized to store and process general operating system, application, database, and backup files. Amazon EBS solid state drive (SSD) storage includes General Purpose SSD (gp2 and gp3) and Provisioned IOPS SSD (io1, io2, and io2BX). Consider the following:
+ Some EC2 instances, like r5d, have local NVMe SSDs physically attached to the host instance. These volumes provide block-level storage that's commonly used for SQL Server tempdb or buffer pool extension.
+ Amazon FSx for Windows File Server is a fully managed file storage service, while Amazon FSx for NetApp ONTAP is fully managed shared storage built on NetApp's popular ONTAP file system. Amazon FSx is frequently used to run SQL Server workloads in a high availability, SQL Server Failover Clustered Instance (FCI) configuration. This solution hosts SQL Server data and log files, which reduces the EBS performance requirements on EC2 instances.
+ Amazon S3 is an object storage service offering industry-leading scalability, data availability, security, and performance. You can store SQL Server native backup files, AMIs, EBS snapshots, application logs, and more on Amazon S3.

## SSD storage types, performance, and cost for Amazon EBS
<a name="ssd-storage-types-performance-and-cost-for-amazon-ebs"></a>

SSD storage costs for Amazon EBS generally increase as durability and performance increase. The storage currently comes in five volume types, each with their [own unique performance metrics](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-volume-types.html). For a summary of the use cases and characteristics of SSD-backed volumes, see the table in the [Solid state drive (SSD) volumes](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-volume-types.html#vol-type-ssd) section of the Amazon EBS documentation.

You can use Amazon CloudWatch to monitor SSD performance, capture trending data, and set alarms when certain thresholds are met. If you're running SQL Server workloads on AWS, consider enabling [detailed monitoring](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-metrics-basic-detailed.html) and deploying [CloudWatch custom metrics](https://aws.amazon.com/blogs/database/monitor-your-microsoft-sql-server-using-custom-metrics-with-amazon-cloudwatch-and-aws-systems-manager/) to capture detailed volume performance metrics such as disk latency, IOPS, throughput, disk queue length, used vs. free capacity, and more. You can use these CloudWatch performance metrics to identify under-provisioned and over-provisioned storage and provide historic data points to accurately define storage requirements.

SSD storage costs for Amazon EBS also vary based on allocated capacity. The table below shows a comparison of the different volume types. All of the volume types have 1 TB of capacity and similar performance configurations.


****  

| Volume type | Max IOPS (16 KiB I/O) | Max throughput (128 KiB I/O) | Price per 1TB | Percent cost savings | 
| --- | --- | --- | --- | --- | 
| gp2 | 3,000 | 250 | \$1102.40 |   | 
| gp3 | 3,000 | 250 | \$186.92 | 15% | 
| io1 | 16,000 | 500 | \$11,168 |   | 
| io2 | 16,000 | 500 | \$11,168 |   | 
| gp3 | 16,000 | 500 | \$1146.92 | 87% | 
| io2bx | 16,000 | 4,000 | \$11,168 |   | 
| gp3 | 16,000 | 1,000 | \$1181.92 | 84% | 

**Note**  
The performance and cost metrics in the preceding table are per volume, based on an [estimate](https://calculator.aws/#/estimate?id=b637bb9c21ae8ad62f440e349dd2067de80e76b2) from the AWS Pricing Calculator. An AWS account is required to access the estimate in the AWS Pricing Calculator.

Amazon EBS SSD gp3 volumes provide excellent performance at a low cost. You can save up to 87 percent if you choose a gp3 volume over io1 or io2 volumes for workloads requiring less than 16,000 IOPS and 500 MiBps throughput.

io2 Block Express (io2BX) volumes offer increased performance over regular io2 volumes. At 16,000 IOPS, io1 or io2 volumes are only capable of 500 MiBps throughput, while io2BX volumes can be configured up to 4,000 MiBps throughput. Compared to io1 and io2 volumes, io2BX volumes provide more than four times the throughput between 16,000 to 64,000 IOPS, at the exact same price. Regular io2 volumes can be converted to io2BX volumes by attaching them to io2BX-supported EC2 instances. For a list of io2BX-supported EC2 instances, see [Provisioned IOPS SSD volumes](https://docs.aws.amazon.com/ebs/latest/userguide/provisioned-iops.html#io2-block-express) in the Amazon EBS documentation. Before deploying new storage, you can use the [AWS Pricing Calculator](https://calculator.aws/) to estimate your monthly cost and understand the impact on cost based on the trade-offs between durability, performance, and capacity.

## General SSD cost optimization for Amazon EBS
<a name="storage-sql-server-overview-ssd-ebs"></a>

We recommend that you evaluate what you're storing and ensure that you're using the right storage type and class. For example, Amazon S3 provides a great price point, built-in lifecycle policies, and replication options ideal for SQL Server backups. SQL Server 2022 has the ability to backup directly to Amazon S3, while previous versions of SQL Server rely on native local backups. If you're running older versions of SQL Server, consider backing up to Amazon EBS HDD volumes and then copying the backup to Amazon S3. This solution can save 53 percent as opposed to using gp3 volumes for backups.

The following table shows the price difference for 1 TB of storage on Amazon EBS gp3, Amazon EBS HDD st1, and Amazon S3.


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/storage-sql-server.html)

**Note**  
The cost metrics in the preceding table are based on an [estimate](https://calculator.aws/#/estimate?id=ba6032e10a5f8a82807c1e3b7d5a64ceb2cdcbde) in the AWS Pricing Calculator. An AWS account is required to access the estimate in the AWS Pricing Calculator.

We recommend that you consider the following:
+ Enable detailed monitoring and deploy CloudWatch custom metrics to accurately capture their storage performance requirements.
+ Upgrade Amazon EBS storage from gp2 to gp3 to reduce costs, increase flexibility, and improve performance.
+ Upgrade Amazon EBS storage from io1 to io2 for increased durability and performance flexibility.
+ Use io2BX instead of io1 or io2 when possible for increased durability and performance.
+ Consider a mix-and-match approach when choosing storage to help reduce capacity requirements and the cost of high-performance volumes. For example, you could use low-cost gp3 volumes for your root volume (operating system), SQL Server installation, system databases (excluding tempdb), and lower performing user databases. This could help reduce the capacity and cost of an io2 volume, which can be dedicated to high-performance user databases.
+ If you're hosting SQL Server databases on AWS, we recommend that you use multiple SQL Server data files per database. This allows the opportunity to distribute read/write workloads across multiple volumes, reducing performance and capacity requirements per volume and consequently reducing cost.
+ Even if production workloads require higher performing storage, such as io1 or io2/io2BX, consider gp3 volumes for non-production workloads to help reduce costs.
+ Track and trend storage utilization over time to easily identify usage spikes and unexpected costs.
+ Use [AWS Compute Optimizer](https://aws.amazon.com/compute-optimizer/) for recommendations on scaling EBS volumes up or down based on actual utilization.
+ Use the elasticity of AWS to adjust the performance and capacity needs of your SSD volumes for Amazon EBS. Unlike for on-premises environments, you don't need to overprovision storage performance and capacity for future workloads. You can migrate your existing SQL Server workloads onto AWS and adjust performance or capacity as needed, while keeping your databases online.

## Additional resources
<a name="storage-sql-server-resources"></a>
+ [Amazon EBS volume types](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-volume-types.html) (Amazon EBS documentation)
+ [Amazon Elastic Block Store (Amazon EBS)](https://docs.aws.amazon.com/ebs/latest/userguide/what-is-ebs.html) (Amazon EBS documentation)
+ [Provisioned IOPS SSD volumes](https://docs.aws.amazon.com/ebs/latest/userguide/provisioned-iops.html) (Amazon EBS documentation)
+ [SSD instance store volumes](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html) (Amazon EC2 documentation)
+ [Amazon CloudWatch metrics for Amazon EBS](https://docs.aws.amazon.com/ebs/latest/userguide/using_cloudwatch_ebs.html) (Amazon EBS documentation)
+ [Specifications for Amazon EC2 storage optimized instances](https://docs.aws.amazon.com/ec2/latest/instancetypes/so.html) (Amazon EC2 documentation)
+ [Protect your SQL Server workloads using NetApp SnapCenter with Amazon FSx for NetApp ONTAP](https://aws.amazon.com/blogs/storage/using-netapp-snapcenter-with-amazon-fsx-for-netapp-ontap-to-protect-your-sql-server-workloads/) (AWS Storage Blog)
+ [Amazon EC2 FAQ](https://aws.amazon.com/ec2/faqs/) (AWS product page)

# Optimize SQL Server licensing by using Compute Optimizer
<a name="sql-server-compute-optimizer"></a>

Guidance on how to optimize licenses for SQL Server by using AWS Compute Optimizer.

## Overview
<a name="sql-server-compute-optimizer-overview"></a>

[AWS Compute Optimizer](https://docs.aws.amazon.com/compute-optimizer/latest/ug/what-is-compute-optimizer.html) can recommend licensing optimization opportunities for Microsoft SQL Server workloads on Amazon Elastic Compute Cloud (Amazon EC2). Compute Optimizer can provide automated recommendations to reduce licensing costs. The recommendations from Compute Optimizer are listed next to each of your EC2 instances with Microsoft SQL Server licenses. The information that's provided includes recommended saving opportunities, EC2 instance On-Demand prices, and hourly bring your own license (BYOL) prices. This information can help you decide if you should downgrade your license edition.

Compute Optimizer automatically discovers your SQL Server instances on Amazon EC2 by inferred workload type. To view the licensing recommendations, you can select the SQL Server instances in Compute Optimizer and then authenticate with [Amazon CloudWatch Application Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-application-insights.html) by using your read-only database credentials. Compute Optimizer analyzes if you are using any SQL Server Enterprise edition features. If no Enterprise edition features are being used, Compute Optimizer recommends that you downgrade to Standard edition to reduce licensing costs.

You can also use Compute Optimizer to make sizing recommendations for your Amazon EC2 instances that run SQL Server workloads. For more information, see [Optimize SQL Server sizing by using Compute Optimizer](sql-server-sizing-compute-optimizer.md) in this guide.

## Cost optimization recommendations
<a name="sql-server-compute-optimizer-recommendations"></a>

The license recommendations in Compute Optimizer can help you evaluate the features you are using in Microsoft SQL Server and choose the most cost-effective edition for your workloads. SQL Server Enterprise edition is significantly more expensive than Standard edition. For more information, see [Compare SQL Server editions](sql-server-editions.md) in this guide and see [SQL Server 2022 pricing](https://www.microsoft.com/en-us/sql-server/sql-server-2022-pricing) on the Microsoft website. Investing the time to configure Compute Optimizer to evaluate your SQL Server fleet and provide recommendations can dramatically reduce your licensing costs.

The **License details** page provides the following information:
+ Use the table to compare your current license settings (such as edition, model, and number of instance cores) with Compute Optimizer recommendations.
+ Use the utilization graphs to review the number of Enterprise edition features that were used during the analysis period.

For more information, see [Viewing details of a commercial software license recommendation](https://docs.aws.amazon.com/compute-optimizer/latest/ug/view-license-recommendations.html#license-viewing-details) in the Compute Optimizer documentation.

## Configure Compute Optimizer
<a name="sql-server-compute-optimizer-configuration"></a>

Compute Optimizer analyzes commercial software licenses by using the `mssql_enterprise_features_used` metric. For more information about this metric, see [Metrics for commercial software licenses](https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#license-metrics-analyzed).

1. Make sure that you have the appropriate permissions to opt in to Compute Optimizer. For more information, see the following:
   + [Policy to opt in to Compute Optimizer](https://docs.aws.amazon.com/compute-optimizer/latest/ug/security-iam.html#opting-in-access)
   + [Policies to grant access to Compute Optimizer for standalone AWS accounts](https://docs.aws.amazon.com/compute-optimizer/latest/ug/security-iam.html#standalone-account-access)
   + [Policies to grant access to Compute Optimizer for a management account of an organization](https://docs.aws.amazon.com/compute-optimizer/latest/ug/security-iam.html#organization-account-access)

1. Attach the required instance roles and policy for CloudWatch Application Insights. For instructions, see [Policies to enable commercial software license recommendations](https://docs.aws.amazon.com/compute-optimizer/latest/ug/security-iam.html#license-access).

1. Enable CloudWatch Application Insights by using your Microsoft SQL Server database credentials. For instructions, see [Set up application for monitoring](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/appinsights-setting-up.html) in the CloudWatch documentation.
**Note**  
To generate recommendations for commercial software licenses, at least 30 consecutive hours of CloudWatch metric data is required. For more information, see [CloudWatch metric requirements](https://docs.aws.amazon.com/compute-optimizer/latest/ug/requirements.html#requirements-metrics).

1. Use the following SQL query to configure least-privilege access for CloudWatch Application Insights.

   ```
   GRANT VIEW SERVER STATE TO [LOGIN];
   GRANT VIEW ANY DEFINITION TO [LOGIN];
   ```

   This enables a new service, PrometheusSqlExporterSQL.

1. From the target AWS account or organization management account, opt in to Compute Optimizer. For instructions, see [Opting in your account](https://docs.aws.amazon.com/compute-optimizer/latest/ug/getting-started.html#account-opt-in).
**Note**  
After you opt in, findings and optimization recommendations can take up to 24 hours to be generated.

1. In the [Compute Optimizer console](https://console.aws.amazon.com/compute-optimizer/), choose **Licenses** in the navigation pane.

1. In the **Findings** column, search for any instances that have the **Insufficient metrics** finding. Compute Optimizer returns this finding if it detects that CloudWatch Application Insights isn't enabled or has insufficient permissions. For more information, see [Finding reasons](https://docs.aws.amazon.com/compute-optimizer/latest/ug/view-license-recommendations.html#license-finding-reasons). Do the following to resolve these findings:

   1. Choose the instance.

   1. Add a secret.

   1. Confirm the instance role and policy are attached.

   1. Choose **Enable license recommendations**.

1. In the **Findings** column, search for any instances that have the **Not optimized** finding. Compute Optimizer returns this finding if it detects that your Amazon EC2 infrastructure isn't using any of the Microsoft SQL Server license features that you're paying for. For more information, see [Finding reasons](https://docs.aws.amazon.com/compute-optimizer/latest/ug/view-license-recommendations.html#license-finding-reasons). Do the following to resolve these findings:

   1. Choose the instance.

   1. Compare the current license edition with the recommended edition.

   1. Review the current license utilization graph.

   1. If you want to downgrade the license, choose **Implement recommendation**.

   1. Review the requirements and follow the instructions to downgrade the license. If you want to automate the process, see [Downgrade SQL Server Enterprise edition using AWS Systems Manager Document to reduce cost](https://aws.amazon.com/blogs/mt/downgrade-sql-server-enterprise-edition-using-aws-systems-manager-document-to-reduce-cost/) (AWS Blog).

## Additional resources
<a name="sql-server-compute-optimizer-resources"></a>
+ [Reduce Microsoft SQL Server licensing costs with AWS Compute Optimizer](https://aws.amazon.com/blogs/modernizing-with-aws/reduce-microsoft-sql-server-licensing-costs-with-aws-compute-optimizer/) (AWS Blog)
+ [What is AWS Compute Optimizer?](https://docs.aws.amazon.com/compute-optimizer/index.html) (AWS documentation)
+ [Viewing commercial software license recommendations](https://docs.aws.amazon.com/compute-optimizer/latest/ug/view-license-recommendations.html) (AWS documentation)
+ [Downgrade your Microsoft SQL Server edition](https://docs.aws.amazon.com/sql-server-ec2/latest/userguide/downgrade-sql-server-on-ec2.html) (AWS documentation)
+ [Microsoft SQL Server on AWS](https://aws.amazon.com/sql/) (AWS)
+ [Microsoft Licensing on AWS](https://aws.amazon.com/windows/resources/licensing/) (AWS)
+ [Microsoft SQL Server 2019 Pricing](https://www.microsoft.com/en-us/sql-server/sql-server-2019-pricing) (Microsoft)
+ [Microsoft SQL Server 2022 Pricing](https://www.microsoft.com/en-us/sql-server/sql-server-2022-pricing) (Microsoft)

# Optimize SQL Server sizing by using Compute Optimizer
<a name="sql-server-sizing-compute-optimizer"></a>

## Overview
<a name="sql-server-sizing-compute-optimizer-overview"></a>

[AWS Compute Optimizer](https://docs.aws.amazon.com/compute-optimizer/latest/ug/what-is-compute-optimizer.html) helps database administrators (DBAs) discover Microsoft SQL Server workloads on Amazon Elastic Compute Cloud (Amazon EC2) and rightsize EC2 instances to reduce license costs by up to 25%. The [inferred workload type](https://docs.aws.amazon.com/compute-optimizer/latest/ug/inferred-workload-type.html) feature in Compute Optimizer uses machine learning (ML) and automatically detects the applications that might be running on your AWS resources. Compute Optimizer includes support for SQL Server as an inferred workload type. By using the inferred workload type feature, you can pinpoint cost-saving opportunities based on the specific workload running on your Amazon EC2 instances.

With this feature, you can categorize cost-saving opportunities by supported inferred workload types, such as SQL Server. Compute Optimizer can automatically discover SQL Server EC2 instances that are over-provisioned. You can switch to the EC2 console to downsize the instance, which helps reduce the licensing and infrastructure costs.

You can also use Compute Optimizer to make SQL Server licensing recommendations. For more information, see [Optimize SQL Server licensing by using Compute Optimizer](sql-server-compute-optimizer.md) in this guide.

## Configure Compute Optimizer
<a name="sql-server-sizing-compute-optimizer-configuration"></a>

For instructions for using Compute Optimizer with SQL Server inferred workloads, see [Optimizing performance and reducing licensing costs: Leveraging AWS Compute Optimizer for Amazon EC2 SQL Server instances](https://aws.amazon.com/blogs/modernizing-with-aws/optimizing-performance-and-reducing-licensing-costs-leveraging-aws-compute-optimizer-for-ec2-sql-server-instances/) (AWS Blog). You can opt in for standalone accounts, accounts that are a member of an organization, and management accounts of an organization. For standalone and member accounts, opting in enables Compute Optimizer for that account only. For an organization management account, you can choose whether to enable Compute Optimizer in that account only or for all member accounts of the organization.

The Compute Optimizer opt-in process automatically creates an AWS Identity and Access Management (IAM) service-linked role. For more information, see [Using service-linked roles for AWS Compute Optimizer](https://docs.aws.amazon.com/compute-optimizer/latest/ug/using-service-linked-roles.html).

Compute Optimizer analyzes your resources based on Amazon CloudWatch metrics, such as CPU, I/O, network, and Amazon Elastic Block Store (Amazon EBS) usage. To generate recommendations, at least 30 consecutive hours of CloudWatch metric data is required in the past 14 days. If you enable the enhanced infrastructure metrics feature, it extends the utilization metrics to 93 days. For more information, see [CloudWatch metric requirements](https://docs.aws.amazon.com/compute-optimizer/latest/ug/requirements.html#requirements-metrics) and [Enhanced infrastructure metrics](https://docs.aws.amazon.com/compute-optimizer/latest/ug/enhanced-infrastructure-metrics.html) in the Compute Optimizer documentation.

Compute Optimizer provides options and the savings associated with each option, based on vCPU, memory, storage, network, risk, and migration effort. You can use the CloudWatch metrics dashboard to analyze the data being used to make the recommendation. With this data, you can rightsize your EC2 instances that are running SQL Server workloads. For more information about how to change your instance type, see [Change the instance type](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-resize.html) in the Amazon EC2 documentation.

## Additional resources
<a name="sql-server-sizing-compute-optimizer-resources"></a>
+ [AWS Compute Optimizer identifies and filters Microsoft SQL Server workloads](https://aws.amazon.com/about-aws/whats-new/2023/05/aws-compute-optimizer-identifies-filters-sql-server-workloads/) (AWS)
+ [Optimizing performance and reducing licensing costs: Leveraging AWS Compute Optimizer for Amazon EC2 SQL Server instances](https://aws.amazon.com/blogs/modernizing-with-aws/optimizing-performance-and-reducing-licensing-costs-leveraging-aws-compute-optimizer-for-ec2-sql-server-instances/) (AWS Blog)
+ [What is AWS Compute Optimizer?](https://docs.aws.amazon.com/compute-optimizer/latest/ug/what-is-compute-optimizer.html) (AWS documentation)
+ [Viewing EC2 instance recommendations](https://docs.aws.amazon.com/compute-optimizer/latest/ug/view-ec2-recommendations.html) (AWS documentation)

# Review Trusted Advisor recommendations for SQL Server workloads
<a name="sql-server-trusted-advisor"></a>

## Overview
<a name="sql-server-trusted-advisor-overview"></a>

[AWS Trusted Advisor](https://docs.aws.amazon.com/awssupport/latest/user/trusted-advisor.html) provides recommendations that help you follow AWS best practices. By analyzing your usage, configuration, and spend, Trusted Advisor provides actionable recommendations to reduce your costs, improve system availability and performance, or help close security gaps. This section focuses on Trusted Advisor checks that can help you reduce the costs of operating SQL Server workloads in the AWS Cloud.

## Cost optimization recommendations
<a name="sql-server-trusted-advisor-recommendations"></a>

Trusted Advisor provides recommendations that help you optimize your SQL Server workloads on Amazon Elastic Compute Cloud (Amazon EC2). The checks inspect your SQL Server workloads and automatically list the instances that need optimization. Operationalizing Trusted Advisor recommendations can reduce costs and improve the security posture of your organization.

The following are Trusted Advisor checks that focus on Microsoft SQL Server:
+ [Amazon EC2 instances over-provisioned for Microsoft SQL Server](https://docs.aws.amazon.com/awssupport/latest/user/cost-optimization-checks.html#ec2-instance-over-provisioned-microsoft-sql-server) – This check analyzes your Amazon EC2 instances that are running SQL Server and alerts you if an instance exceeds the SQL Server software vCPU limit. For example, an instance with SQL Server Standard edition can use up to 48 vCPUs. An instance with SQL Server Web can use up to 32 vCPUs.  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/sql-server-trusted-advisor.html)
+ [Amazon EC2 instances consolidation for Microsoft SQL Server](https://docs.aws.amazon.com/awssupport/latest/user/cost-optimization-checks.html#ec2-instances-consolidation-sql-server) – This check analyzes your Amazon EC2 instances and alerts you if your instance has less than the minimum number of SQL Server licenses. You can consolidate smaller SQL Server instances to help lower costs. If you have many small, license-included SQL Server instances, then consider consolidating. According to the [Microsoft SQL Server 2019 licensing guide](https://download.microsoft.com/download/e/2/9/e29a9331-965d-4faa-bd2e-7c1db7cd8348/SQL_Server_2019_Licensing_guide.pdf), SQL Server requires a minimum of 4 vCPU licenses per instance. If you consolidate these databases, you can save on licensing costs. You can make your decision based on the number of databases on the instance, the maximum database size, and the total size of the databases. Consolidation is supported for Web, Standard, and Enterprise editions of SQL Server. For more information, see [Consolidating SQL Server Databases](https://learn.microsoft.com/en-us/archive/blogs/mvpawardprogram/consolidating-sql-server-databases) (Microsoft blog post).

  AWS does not recommend putting large production databases on only one server. However, you can consolidate smaller ones used for non-production environments, such as for development, testing, and staging. This depends on your current SQL Server usage; if you have low-usage databases, you can consolidate on one server.

## Configure Trusted Advisor
<a name="sql-server-trusted-advisor-configuration"></a>

Do the following to evaluate SQL Server focused checks in Trusted Advisor.

1. Sign in to the AWS Management Console.

1. Open the [AWS Trusted Advisor console](https://console.aws.amazon.com/trustedadvisor/home).

1. In the navigation pane, under **Recommendations**, choose **Cost optimization**.

1. In the **Cost optimization checks** list, review the status of the **Amazon EC2 instances consolidation for Microsoft SQL Server** and **Amazon EC2 instances over-provisioned for Microsoft SQL Server** checks.
   + Green check symbols indicate that your Amazon EC2 instances are optimally configured.
   + Orange alert symbols indicate that there are opportunities for improvement.

1. Choose a check to see its details and recommendations.

1. Follow the instructions provided by the check to optimize your Amazon EC2 instances that are running SQL Server workloads.

1. Monitor your instances regularly, and refresh the checks periodically.

## Additional resources
<a name="sql-server-trusted-advisor-resources"></a>
+ [Trusted Advisor check reference](https://docs.aws.amazon.com/awssupport/latest/user/trusted-advisor-check-reference.html) (AWS documentation)
+ [Microsoft SQL Server on AWS](https://aws.amazon.com/sql/) (AWS)
+ [Microsoft Licensing on AWS](https://aws.amazon.com/windows/resources/licensing/) (AWS)
+ [SQL Server 2019 pricing](https://www.microsoft.com/en-us/sql-server/sql-server-2019-pricing) (Microsoft)
+ [AWS Launch Wizard for SQL Server](https://docs.aws.amazon.com/launchwizard/latest/userguide/launch-wizard-sql.html) (AWS documentation)