SQL Server e GPO Attività manutenzione volume

Per velocizzare le attività che comportano l’allocazione di file data (creazione db, restore db, aggiunta file ad un DB, estensione dimensione di un file DB, autogrow) è possibile aggiugere l’account con cui viene eseguito SQL Server Server alla policy locare di sicurezza Perform Volume Maintenance Tasks che abilita l’instant file initialization.

Questa impostazione non influisce sulla allocazione dei file logs, ma apporta benefici in termini di performance durante l’esecuzione dei comandi CREATE DATABASE, ALTER DATABASE, RESTORE e AUTOGROW.

image

Dopo aver impostato la policy occorre riavviare il servizio di SQL Server (la rimozione di tale impostazione comporta invece un riavvio del sistema). Tale policy ha un’implicazione di sicurezza di cui occorre tenere presente, infatti se attivata quando viene eliminato un file questo viene solo deallocato e lo spazio occupato da questo non viene riempito di zeri permettendo quindi di recuperare i dati come indicato in How and Why to Enable Instant File Initialization:

“This permission keeps SQL Server from “zeroing out” new space when you create or expand a data file (it is not applied to log files).  This helps performance for CREATE DATABASE, ALTER DATABASE, RESTORE, and AUTOGROW. It can have a significant positive impact on how long it takes to create or expand a data file, but there is a small security risk in doing so. That is because a file “delete” really just deallocates the space and a new allocation can reuse that space which may still have data in it. When you do not zero out the existing space there is a possibility that someone could read data that you thought had been deleted. It is very common to turn Instant File Initialization on. Many shops consider the increased performance benefit to far outweigh the small security risk, but you must weigh the cost and benefits within your own environment.”

L’impostazione di tale policy è anche consigliata tra le best practices dell’implementazione di SQL Server su VM in Azure disponibile al seguente Performance Considerations for SQL Server in Windows Azure Virtual Machines, in quanto non è impostata di default nelle SQL Server platform image:

“For databases of any significant size, enabling instant file initialization can improve the performance of some operations involving database files, such as creating a database or restoring a database, adding files to a database or extending the size of an existing file, autogrow, and so on. For information, see How and Why to Enable Instant File Initialization.

To take advantage of instant file initialization, you grant the SQL Server (MSSQLSERVER) service account with SE_MANAGE_VOLUME_NAME and add it to the Perform Volume Maintenance Tasks security policy. If you are using a SQL Server platform image for Windows Azure, the default service account (NT Service\MSSQLSERVER) isn’t added to the Perform Volume Maintenance Tasks security policy. In other words, instant file initialization is not enabled in a SQL Server Windows Azure platform image.

After adding the SQL Server service account to the Perform Volume Maintenance Tasks security policy, restart the SQL Server service.”

Sempre  nella white paper Performance Guidance for SQL Server in Windows Azure Virtual Machines vengono resi disponibili i test sulla creazione e il restore di un DB di 100 GB con e senza l’impostazione dell’instant file initialization:

image

Per ulteriori informazioni si veda Database File Initialization.

Per chi desidera approfondire le potenzialità offerte da Azure vi ricordo i prossimi IT Camp su Azure.