basic standard premium basic premium standard scale out/in scale up/down
TRANSCRIPT
Microsoft Azure SQL Database Performance and Scale Out Deep DiveJan EngelsbergJoseph Idziorek
DBI-B313
Scalability options in Azure SQL DatabasePredictable Performance: Scale-up or scale-down (Vertical)• Change service-tiers for a given database as capacity/performance needs fluctuate
Elastic Scale: Scale-out or scale-in (Horizontal)• Add or remove databases as more or less capacity/performance as needed
Basic
Standard
Premium
Basic Basic Basic Basic Basic Basic
PremiumStandar
d
Scale out/in
Sca
le u
p/d
ow
n
Case for Change
Web & Business• Price/storage• Throttling• Performance varies based on
neighboring tenants • Deprecated (September 2015)
Basic, Standard & Premium• Price/performance & features• Resource Governance• Predictable Performance • General Available (September
2014)• Backwards Compatible (except
federations)
Based on customer feedback we are moving to a model based on Predictable Performance
Predictable PerformanceWeb / Business Basic / Standard /
PremiumMachineCompute
Wri
tes R
ead
s
Memory
DB 1DB 2
DB 3
DB 4
DB 7
DB 5 DB 6
DB 8DB 9
MachineCompute
Wri
tes R
ead
s
Memory
DB 1DB 2
DB 3
DB 4
DB 7
DB 5 DB 6
DB 8DB 9
DB 1
DB 2DB 3
DB 4
DB 7
DB 5DB 6
DB 8
DB 9
Noisy neighbor!
Bounding boxes
eliminates noisy
neighbors
Roles and ResponsibilitiesAzure SQL Database
• Assure resource are available when they are requested
• Provide insights into and tools to measure resource consumption
• Provide guidance on how to use the new Service Tiers
Customers
• Chose the right Service Tier (features)
• Chose the right Performance Level
• Monitor and react to performance needs
Database Throughput Unit – DTU
Represents the relative power (resources) assigned to the database
Blended measure of CPU, memory, and read and write rates Compare the power across performance levels Simplifies talking about performance, think IOPS vs. %
Monitoring% of current Performance Level
Utilization
75
%
Read
50%
Write
50%
CPU
60%
Memory
Compute
Wri
tes R
ead
s
Memory
DB workload
Bounding Box
Azure SQL Database Benchmark – ASDB An example representing meaningful OLTP-
workloadUses six tables of varying sizes some of which are always larger than available memory and scale with the throughputUses nine transaction typesA transaction is a combination of multiple SELECT, DELETE, INSERT, UPDATE statements
New Performance Levels Summary
Basic Standard Premium
Performance Levels (DTU)
5 S0: 10S1: 20S2: 50
P1: 100 P2: 200 P3: 800
ASDB results 16,600 tx/hour S1: ,520 tx/minuteS1: ,940 tx/minuteS2: 2,570 tx/minute
P1: 105 tx/secondP2: 228 tx/secondP3: 735 tx/second
Maximum DB size 2GB 250GB 500GB
Price* per hour (month) $0.0069 (~$5) S0: $0.0208 (~$15)S1: $0.0417 (~$30)S2: $0.1042 (~$75)
P1: $0.6458 (~$465)P2: $1.292 (~$930)P3: $5.167 (~$3,720)
*Starting November 1st
RESULT
CPU
Writes
Reads
GovernorCPU
Writes
Reads
P1 Governor
Resource Governance
SELECT * FROM a JOIN b ON …
S2
Resource requests are being not rejected but being queued
Overloaded can result in long running transactions and command timeouts
CPU
Writes
Reads
Governor
master.sys.resource_statsBased on 5 minute averages
userdb.sys.dm_db_resource_statsBased on 15 second averages
Percentages relative to performance levelAccessible though Azure Portal
Allows to configure alerting!
Resource Monitoring
Migration from on-premise installationsYou have to test!
Migration from Web&BusinessUse master.sys.resource_stats
Switching between levelsUse userdb.sys.dm_db_resource_stats
Query tuningsys.dm_exec_query_statssys.dm_exec_query_sql_text()sys.dm_exec_query_plansys.dm_exec_requestssys.dm_exec_sessions
Choosing Performance Levels
5 10 20 50 100 200 800DTUs
Changing Performance LevelPowerShell
Set-AzureSqlDatabase
RESTUpdate Database / ServiceLevelObjectiveId
.NETMicrosoft.WindowsAzure.Management.Sql.SqlManagementClientclient.Databases.Update(…)
T-SQLALTER DATABASE … MODIFY (EDITION = …)
Quota ManagementServer Quota
6 Servers per Subscription
Per Server DB Quota1600 DTU150 databases
Examples2 P3 = 2x800 DTU = 1600 DTU160 S0 = 160x10 DTU = 1600 DTU200 S2 = 200x50 DTU = 10000 DTU1 P3, 14 S2,10 S0 … = 1600 DTU / 25 DBs
Customer Scenario
• Application exceeds the limits of a single database: capacity, performance, geo-locality, isolation
• Application Types• Single tenant: Each tenant’s data is stored in a different database• Multi-tenant: Multiple tenants share the same database• Hybrid model: Some tenants share databases, others get their own
database• Temporal Data: Telemetry ingestions/Internet of Things (IOT)
scenarios• Geo-location/Geo-political: Keeping data in geographical regions
for performance and/or policy reasons
Terminology
(1) Database
(2) Sharding Key
. . .
(3) Shard Map Manager
(4) Shard
(4) Shard
(5) Shard Set
(6) Sharded Table
(7) Reference Table
(8) Shardlet
Customer ID
Name
1 Alice
2 Bob
Customer Table
Data Center ID DC Name
1 Boston
2 Miami
Data Center Table
Elastic Scale Overview
Application
Developer
.NET Application
Shard Map Management (SMM)• Define groups of shards for your application• Manage mapping of routing keys to shards
Data Dependent Routing (DDR)• Route incoming requests to the correct
shard, e.g., given a customer ID • Ensure correct routing as tenants move • Cache routing information for efficiency
Multi-Shard Query (MSQ)• Interactive processing across several shards • Same statement executed on all shards with
UNION all semantics
.NET Client APIs
Management Service
Admin/DevOps
Elastic Scale Overview
Application
Developer
.NET Application
Admin/DevOps
Management Service
Split Merge Service (SMS)• Grow or shrink capacity by adding or
removing scale units • Dynamically adjust scale factor of scale
unit• Trigger adjustment dynamically through
policies
Federations Migration Utility• Migrate from Federations to Elastic Scale
Shard Elasticity (SE)• Policy-based horizontal and vertical
sharding using Azure Automation
Management
• Two types of shard maps• Range: contiguous values• List: explicit values
• Four types of sharding keys• INT, BIGINT, GUID, VARBINARY
Elastic Scale Overview[shards_global]sid smi
d server databa
se
1 1 Server1
DB1
2 1 Server1
DB2
[shardmaps_global] smid name
1 RangeShardMap
[shard_mappings_global]mid smi
d min
max
Sid
1 1 0 100 1
2 1 100
200 2
Shard Set
DB1
[0-100) . . .
DB2
[100-200)
DB3
[200-300)
DB4
[300-400)
DB5
[400-500)
DB6
[500-600)
DBn
[n – n+100)
Shard Map Manager
Data Dependent Routing (DDR)
Client AppDDR APIs
Scenario: query a shard with a specific sharding key value
SELECT * FROM customers WHERE customer ID = 104
DB1
[0-100) . . .
DB2
[100-200)
DB3
[200-300)
DB4
[300-400)
DB5
[400-500)
DB6
[500-600)
DBn
[n – n+100)
Application
Developer
Shard Map Manager
Data Dependent Routing (DDR)
// Get a routed connection for a given shardingKeyusing (SqlConnection conn = ShardMap.OpenConnectionForKey(
shardingKey, connectionString /* Credentials Only */,ConnectionOptions.Validate /* Validate */ ));
{using (SqlCommand cmd = new SqlCommand()
{cmd.Connection = conn;cmd.CommandText = "SELECT * FROM customers WHERE customer ID = 104";
SqlDataReader sdr = cmd.ExecuteReader();
// Now consume results from the data reader…}
}
Caching: improve performance of shard operations • Global Shard Map (GSM) – state of all shards in the Shard Map• Local Shard Map (LSM) – state of all shards on a particular shard• Client Cache (eager/lazy) – state of all shards in the Shard Map/known
shards
Data Dependent Routing (DDR)
Client AppDDR APIs
Cache
Application
Developer
Shard Map Manager
GSM
DB
LSM
Multi-Shard Query
Scenario: execute a query across a set of shards (returns a UNION ALL result set)
Client AppMSQ APIs
SELECT count(*) FROM customers
UNION ALL result set
DB1
[0-100) . . .
DB2
[100-200)
DB3
[200-300)
DB4
[300-400)
DB5
[400-500)
DB6
[500-600)
DBn
[n – n+100)
Application
Developer
Shard Map Manager
Multi-Shard Query APIsusing (MultiShardConnection conn = new MultiShardConnection(m_shardMap.GetAllShards(null), MultiShardTestUtils.GetTestSqlCredential())){ using (MultiShardCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT count(*) FROM customers"; cmd.CommandType = CommandType.Text; cmd.Policy = MultiShardPolicy.PartialResults;
using (MultiShardDataReader sdr = cmd.ExecuteReader(includeShardNameColumn: true)) { while (sdr.Read()) {
// Now consume results from the data reader… }
} }}
Split Merge Service
Scenario: perform a split or merge action• Split: create two distinct shards from one• Merge: create one shard from two distinct shards• Point move: move a single tenant to an individual shardSplitMerge
Management Service
Admin/DevOps
DB1
[0-100) . . .
DB2
[100-200)
DB3
[200-300)
DB4
[300-400)
DB5
[400-500)
DB6
[500-600)
DBn
[n – n+100)
DB2.1
[0-200)
DB5.1
[400-450)
DB5.2
[450-500)
Scale Options
ALL shards are regular Azure SQL Databases• Scale up and down individual shards, predictable
performance• Feature support: backup, auditing, etc.• Tooling integration: SSMS, SSDT, portal
DB1
[0-100)
. . .
DB2
[100-200)
DB3
[200-300)
DB4
[300-400)DB5
[400-500)
DB6
[500-600) DBn
[n – n+100)
Basic Standard
Premium
Premium
Basic Standard
Azure SQL Databasehttp://azure.microsoft.com/en-us/documentation/services/sql-database/
Track resources
Elastic Scale Documentation Maphttp://azure.microsoft.com/en-us/documentation/articles/sql-database-elastic-scale-documentation-map/
Elastic Scale Getting Started Samplehttps://code.msdn.microsoft.com/vstudio/Elastic-Scale-with-Azure-a80d8dc6
Near Real-Time Performance Metricshttp://azure.microsoft.com/blog/2014/09/11/azure-sql-database-introduces-new-near-real-time-performance-metrics/
27 Hands on Labs + 8 Instructor Led Labs in Hall 7
DBI Track resources
Free SQL Server 2014 Technical Overview e-book
microsoft.com/sqlserver and Amazon Kindle StoreFree online training at Microsoft Virtual Academy
microsoftvirtualacademy.com Try new Azure data services previews!Azure Machine Learning, DocumentDB, and Stream Analytics
Resources
Learning
Microsoft Certification & Training Resources
www.microsoft.com/learning
TechNet
Resources for IT Professionals
http://microsoft.com/technet
Sessions on Demand
http://channel9.msdn.com/Events/TechEd
Developer Network
http://developer.microsoft.com
Please Complete An Evaluation FormYour input is important!TechEd Schedule Builder CommNet station or PC
TechEd Mobile appPhone or Tablet
QR code
© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.