Sessione tenuta al Global Azure BootCamp 2019, organizzato dalla community CloudGen a Verona, in cui parlo di come dimensionare ed ottimizzare le VM SQL Server su Azure IaaS come da best practices di riferimento Microsoft.
Video: https://youtu.be/Bg9aJAXvoZI
Demo: https://github.com/OmegaMadLab/GAB2019VR-Demo
5. Agenda
SQL Server su Azure
• Infrastructure as a Service: quando e perché
Overview delle best practices suggerite da Microsoft
• Sizing della virtual machine
• Ottimizzazioni post deployment
Automazione
7. SQL Server: Azure proposition
Minor TCO, a scapito delle funzionalità?
Voglio
Azure!
SQL VM
Single DB /
Pool
Maggior controllo? Minor TCO?
Managed
Instances
On-prem L&S? Nuovo progetto?
MANAGEDBYVENDOR
APPLICATION
HYPERVISOR
OS
RUNTIME
DATA
STORAGE
NETWORK
IaaS
YOUMANAGE
SERVERS
MANAGEDBYVENDOR
APPLICATION
HYPERVISOR
OS
RUNTIME
DATA
STORAGE
NETWORK
PaaS
YOUMANAGE
SERVERS
8. IaaS: quando e perché?
• Istanza di SQL Server in esecuzione in una macchina virtuale di
Azure
• Tutte le feature on-prem disponibili in cloud
• Controllo totale di SQL Server
• Velocità e agilità nel deployment, grazie ai template
• Licenza inclusa nel prezzo, o possibilità di utilizzo della propria
licenza
• Dev/Test
• Lift and Shift
• Scenari di DR
10. Area Optimizations When to apply
DS3 or higher for SQL Enterprise edition.
DS2 or higher for SQL Standard and Web editions.
Use Premium Storage. Standard storage is only recommended for dev/test.
Keep the storage account and SQL Server VM in the same region.
Disable Azure geo-redundant storage (geo-replication) on the storage account.
Use a minimum of 2 P30 disks (1 for log files; 1 for data files and TempDB).
Enable read caching on the disk(s) hosting the data files and TempDB.
Do not enable caching on disk(s) hosting the log file.
Stripe multiple Azure data disks to get increased IO throughput.
Format with documented allocation sizes.
Avoid using operating system or temporary disks for database storage or logging.
Move all databases to data disks, including system databases.
Move SQL Server error log and trace file directories to data disks.
Setup default backup and database file locations.
Enable instant file initialization for data files.
Limit or disable autogrow on the database.
Disable autoshrink on the database.
Enable database page compression.
Enable locked pages.
Apply SQL Server performance fixes.
Feature specific Back up directly to blob storage.
VM size
Storage
Disks
I/O
During VM provisioning
After VM provisioning
https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-sql-performance/
17. Famiglie e dimensioni VM
https://docs.microsoft.com/it-it/azure/virtual-machines/windows/sizes
18. Azure Compute Units
Single core performance, referred to an A-family core
SKU Family ACU/Core
Standard_A0 50
Standard_A1-4, Standard_A5-7, Standard_A1-8v2, Standard_A2m-8mv2 100
A8-A11 225*
D1-14, DS1-14 160
D1-15v2, DS1-15v2 210-250*
Dv3, DSv3, Ev3, ESv3 160-190* **
F1-F16, F1s-F16s 210-250*
F2Sv2-F72Sv2 195-210* **
G1-5, GS1-5, L4s-L32s 180-240*
H 290-300*
M 160-180 **
* use Intel® Turbo technology to increase CPU frequency and provide a performance boost.
** Hyper-Threaded hosts (1 physical core = 2 vCpu)
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/acu
19. Famiglie e dimensioni VM
https://docs.microsoft.com/it-it/azure/virtual-machines/windows/sizes
20. Constrained CPU
Name vCPU Specs
Standard_E32-16_v3 16 Same as E32s_v3
Standard_E32-8s_v3 8 Same as E32s_v3
Standard_E64-32s_v3 32 Same as E64s_v3
Standard_E64-16s_v3 16 Same as E64s_v3
Standard_GS4-8 8 Same as GS4
Standard_GS4-4 4 Same as GS4
Standard_GS5-16 16 Same as GS5
Standard_GS5-8 8 Same as GS5
Standard_DS11-1_v2 1 Same as DS11_v2
Standard_DS12-2_v2 2 Same as DS12_v2
Standard_DS12-1_v2 1 Same as DS12_v2
Standard_DS13-4_v2 4 Same as DS13_v2
Standard_DS13-2_v2 2 Same as DS13_v2
Standard_DS14-8_v2 8 Same as DS14_v2
Standard_DS14-4_v2 4 Same as DS14_v2
Name vCPU Specs
Standard_M8-2ms 2 Same as M8ms
Standard_M8-4ms 4 Same as M8ms
Standard_M16-4ms 4 Same as M16ms
Standard_M16-8ms 8 Same as M16ms
Standard_M32-8ms 8 Same as M32ms
Standard_M32-16ms 16 Same as M32ms
Standard_M64-32ms 32 Same as M64ms
Standard_M64-16ms 16 Same as M64ms
Standard_M128-64ms 64 Same as M128ms
Standard_M128-32ms 32 Same as M128ms
Standard_E4-2s_v3 2 Same as E4s_v3
Standard_E8-4s_v3 4 Same as E8s_v3
Standard_E8-2s_v3 2 Same as E8s_v3
Standard_E16-8s_v3 8 Same as E16s_v3
Standard_E16-4s_v3 4 Same as E16s_v3
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/constrained-vcpu
21. Famiglie e dimensioni VM - storage
https://docs.microsoft.com/it-it/azure/virtual-machines/windows/sizes
22. Architettura storage VM
VM
Host Azure Storage
Blobcache
RAM cache
Server SSD cacheTemp Disk OS Disk Data Disk Data Disk
Cached throughput Uncached throughput
https://azure.microsoft.com/en-us/blog/azure-premium-storage-now-generally-available-2/
23. Best practices
Taglie minime raccomandate:
DS2_v2 (2 vCPU 7 GB RAM) per SQL Server Standard Edition
DS3_v2 (4 vCPU 14 GB RAM) per SQL Server Enterprise Edition
Qualche suggerimento in più…
Attenzione al licensing!!!
Attenzione alle ACU!!!
Usate VM che supportano Premium Storage
1
27. Tipologie dischi
Ultra SSD (preview) Premium SSD Standard SSD Standard HDD
Disk type SSD SSD SSD HDD
Scenario
IO-intensive workloads
such as SAP HANA, top
tier databases (for
example, SQL, Oracle),
and other transaction-
heavy workloads.
Production and
performance sensitive
workloads
Web servers, lightly
used enterprise
applications and
dev/test
Backup, non-critical,
infrequent access
Disk size
65,536 gibibyte (GiB)
(Preview)
32,767 GiB 32,767 GiB 32,767 GiB
Max throughput 2,000 MiB/s (Preview) 900 MiB/s 750 MiB/s 500 MiB/s
Max IOPS 160,000 (Preview) 20,000 6,000 2,000
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disks-types
29. Unmanaged vs. Managed Disks
• Premium Storage account limits:
• 50 Gbps bandwidth
• 35 TB for disks
• 10 TB for snapshots
• Standard Storage account limits:
• 50 Gbps bandwidth
• 35 TB for disks
• 10 TB for snapshots
https://blogs.msdn.microsoft.com/igorpag/2017/03/14/azure-managed-disks-deep-dive-lessons-learned-and-benefits/
30. Best practices
Usate Premium Storage con replica locale, e posizionate
lo storage account nello stesso datacenter della VM
Lo storage geo-replicato è supportato solo in scenari
molto particolari utilizzate feature applicative per
ottenere geo-ridondanza
Qualche suggerimento in più…
Possibilmente utilizzate dischi managed
Se usate dischi unmanaged, attenzione al posizionamento su storage
account
1
37. Tipologie dischi
P
R
E
M
I
U
M
S
S
D
Type P4 P6 P10 P15 P20 P30 P40 P50 P60 P70 P80
Disk size in GiB 32 64 128 256 512 1,024 2,048 4,095 8,192 16,384 32,767
IOPS per disk Up to 120 Up to 240 Up to 500 Up to 1,100 Up to 2,300 Up to 5,000 Up to 7,500 Up to 7,500
Up to
16,000
Up to
18,000
Up to
20,000
Throughput per
disk
Up to 25
MiB/sec
Up to 50
MiB/sec
Up to 100
MiB/sec
Up to 125
MiB/sec
Up to 150
MiB/sec
Up to 200
MiB/sec
Up to 250
MiB/sec
Up to 250
MiB/sec
Up to 500
MiB/sec
Up to 750
MiB/sec
Up to 900
MiB/sec
S
T
A
N
D
A
R
D
S
S
D
Type E4 E6 E10 E15 E20 E30 E40 E50 E60 E70 E80
Disk size in GiB 32 64 128 256 512 1,024 2,048 4,095 8,192 16,384 32,767
IOPS per disk Up to 120 Up to 240 Up to 500 Up to 500 Up to 500 Up to 500 Up to 500 Up to 500 Up to 2,000 Up to 4,000 Up to 6,000
Throughput per
disk
Up to 25
MiB/sec
Up to 50
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 400
MiB/sec
Up to 600
MiB/sec
Up to 750
MiB/sec
S
T
A
N
D
A
R
D
H
D
D
Type S4 S6 S10 S15 S20 S30 S40 S50 S60 S70 S80
Disk size in GiB 32 64 128 256 512 1,024 2,048 4,095 8,192 16,384 32,767
IOPS per disk Up to 500 Up to 500 Up to 500 Up to 500 Up to 500 Up to 500 Up to 500 Up to 500 Up to 1,300 Up to 2,000 Up to 2,000
Throughput per
disk
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 60
MiB/sec
Up to 300
MiB/sec
Up to 500
MiB/sec
Up to 500
MiB/sec
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disks-types
38. Famiglie e dimensioni VM - storage
https://docs.microsoft.com/it-it/azure/virtual-machines/windows/sizes
39. Best practices
Usare dischi Premium SSD per workload di produzione
Almeno un disco P30 per i dati ed un P30 per i log
Cache Read-Only per dischi dati e TempDB
Cache None per dischi log o write intensive
Utilizzare Storage Spaces per creare volumi in striping
• Columns = numero dischi in striping
• Interleave = 64KB se workload OLTP, 256KB se workload DWH
Formattare i dischi con dimensione unità di allocazione = 64 KB
Qualche suggerimento in più…
Max due dischi per ogni vCPU
Considerate la possibilità di utilizzare il disco temporaneo per il TempDB
Se utilizzate standard storage:
• Utilizzate il numero massimo di dischi supportato dalla VM in striping
• Impostate la cache a None su tutti i dischi
42. Best practices
Evitate di utilizzare il disco OS per ospitare database, ERRORLOG,
Trace e backup
• Spostare tutto su data disk:
• Impostare path di default per database e backups
• Spostare MSDB, MODEL, TEMPDB:
1. ALTER DATABASE database_name MODIFY FILE ( NAME = logical_name , FILENAME =
'new_pathos_file_name' )
2. Spostare i file
3. Riavviare istanza
• Spostare MASTER, Log SQL e Default Trace:
1. Stop istanza
2. Da SQL Configuration Manager cambiare parametri di startup
3. Spostare i file
4. Riavviare istanza
43. Best practices
Tenere sotto controllo la dimensione dei database
• Autogrowth = ultima spiaggia
• Disabilitare Auto Shrink Impatto su I/O e su frammentazione indici
Privilegi da concedere all’account di servizio
• Perform volume maintenance tasks per abilitare Instant File Initialization funziona solo sui data files!
• Lock Pages in Memory per limitare il paging della memoria utilizzata da SQL
Valutare l’abilitazione della Page Compression su tabelle ed indici
Su SQL 2012 installare la CU10 o successiva per SP1 o la CU1
o successive per SP2
44. Best practices
Valutare la possibilità di eseguire backup direttamente su
storage account
Storage AccountSQL Server VM
Backup
45. Qualche suggerimento in più…
Disabilitare eventuali servizi non necessari (SSAS, SSRS)
Impostare il valore massimo di memoria utilizzabile da SQL Server
per evitare contesa di risorse con il sistema operativo
Valutare la possibilità di suddividere il TempDB in più datafile
Valutare la possibilità di utilizzare il disco temporaneo per il
TempDB
Valutare l’utilizzo di Trace Flag su SQL 2012/2014
• -T1117 e -T1118 per workload OLTP
• -T1117 e -T610 per workload DW