Banco de Dados – Planejando um ambiente SQL Server de alta performance e missão crítica Vitor Fava Data Platform MVP
Agenda Introduction The Life Cycle of a Query Memory (Physical/Virtual) CPU Architecture Storage SQL Server File Layout
Vitor Fava MVP Data Platform Pass Chapter Leader do SQLManiacs Module 0: Introduction Course ####y Vitor Fava MVP Data Platform Pass Chapter Leader do SQLManiacs SQL Server Database Consultant na Pythian CEO da Vita Database Solutions vitortff@gmail.com http://vfava.worpress.com http://www.youtube.com/vitortff https://groups.google.com/group/sqlmaniacs Welcome students to the course and introduce yourself. Provide a brief overview of your background to establish credibility. Ask students to introduce themselves and provide their backgrounds, product experience, and expectations of the course. Record student expectations on a whiteboard or flip chart that you can reference during class.
Introduction Memory, disk, and CPU are the holy trinity of resources in a Computer system, and memory is first because it’s the area you’re most likely to have an issue with; Memory issues can cause both disk and CPU saturation; Storage systems have been confounding database administrators and designers since Microsoft first released SQL Server; Today DBAs are not only required to design and maintain SQL Server, but are also often pressed into service as storage administrators; For DBAs working in the enterprise, communication with the server, networking, and especially storage teams are always a challenge;
The Life Cycle of a Query
Physical Memory When the term physical memory is used, it’s usually in relation to RAM (random access memory), but it actually also includes the system page file; It is regarded as the fastest type of storage you can use, but it’s volatile, meaning you lose what was stored when you reboot the computer; RAM modules is measured in gigabytes per second (GB/s) with nanosecond (ns) response times, whereas hard disk throughput is measured in megabytes per second (MB/s) with millisecond (ms) response times; It’s also expensive and limited in capacity compared to nonvolatile storage such as a hard disk;
Maximum Supported Physical Memory Feature Enterprise Standard Express (Advanced Services) Express Database Engine Windows Maximum 128 GB 1 GB Analysis Services Tabular: 16 GB MOLAP: 64 GB N/A Reporting Services 64 GB 4 GB
Virtual Memory If all the processes running on a computer could only use addresses in physical RAM, the system would very quickly experience a bottleneck. Windows assigns a virtual address space (VAS) to each process. This provides a layer of abstraction between an application and physical memory so that the operating system can choose the most efficient way to use physical memory across all the processes; For example, two different processes can both use the memory address 0xFFF because it’s a virtual address and each process has its own VAS with the same address range. The size of the virtual address space is determined largely by the CPU architecture.
Virtual Memory – x86 The virtual address space for a 32-bit system is only 4GB; Broken down into 2GB for kernel mode and 2GB for user mode;
Virtual Memory – x64 A 64-bit CPU running 64-bit software architecture can manipulate values that are up to 64 bits in length; Value between 0 and 18,446,744,073,709,551,616 to reference a memory address; 44-bit address bus provides a virtual address space on 64-bit systems of 16TB;
Virtual Memory Manager
Sizing the Page File Windows will manage the size of your page file recommending a page file size of 1.5 times the size of RAM; The primary purpose of a page file is to allow Windows to temporarily move data from RAM to disk to help it manage resources effectively; When a page file is heavily used, it indicates memory pressure; and the solution is to optimize your memory resources or buy more RAM, rather than to optimize your page file; If you have disk space concerns on your page file drive, then setting the page file to 50% of total available RAM;
SMP Traditional architecture, every processor has access to every memory bank across a shared system bus to a central memory controller on the motherboard (SMP);
SMP
Non-Uniform Memory Architecture - NUMA Non-Uniform Memory Architecture (NUMA) is a hardware design that improves server scalability by removing motherboard bottlenecks;
Non-Uniform Memory Architecture - NUMA
NUMA – SQL Server’s Use of NUMA SQL Server creates its own internal nodes on startup that map directly on to NUMA nodes;
SQL Server NUMA Memory Configuration
Non-Uniform Memory Architecture - NUMA
Min and Max Server Memory Min Server Memory (MB) and Max Server Memory (MB) control the allowable size of all SQL Server’s memory usage; Look at SQL Server’s maximum usage; MSSQL$<instance>:Memory Manager\Total Server Memory (KB); Determine the maximum potential for memory requirements outside SQL Server; 2GB for Windows; xGB for SQL Server worker threads; 512MB, if you use linked servers, extended stored procedure dlls, or objects created using Automation procedures (sp_OA calls); 1–3GB, for other applications that might be running on the system, such as backup programs or anti-virus software;
Lock Pages in Memory Lock Pages in Memory (LPIM) is used as a work-around for a problem than can occur between Windows and SQL Server; It was especially bad on older versions of SQL Server, which could run on Windows Server 2003 and earlier; This is known as aggressive working set trimming and had a devastating effect on SQL Server’s memory allocation — and therefore performance First set Max Server Memory appropriately; SQL Server’s buffer pool pages are “locked” and non-pageable so Windows can’t take them when trimming; SQL Server Error Log: Using Locked Pages in the Memory Manager;
Optimize for Ad-Hoc Workloads When this option is enabled, SQL Server will cache only a plan stub the first time a piece of ad-hoc T-SQL is executed, rather than the full plan; If SQL Server subsequently tries to reuse that plan, it will be generated again but this time cached in full; This avoids the scenario of thousands of single-use plans taking up valuable space in cache;
The Fundamental Characteristics of Storage
The Fundamental Characteristics of Storage Latency; IOPS; Bandwidth; These three measurements are all related, so you can’t just look at one of them in isolation, without knowing the others; Storage vendors tend to show their best -case numbers in isolation;
Storage Technology Storage array controllers group disks into volumes called a redundant array of inexpensive disks (RAID); RAID-constructed volumes offer capacity without failure protection; RAID 0; RAID 1; RAID 5; RAID 1+0;
Storage Technology
Storage Tiering
Storage Performance Counters Latency Average Disk sec/Read Average Disk sec/Write IOPS Disk Reads/sec Disk Writes/sec Bandwidth Disk Read Bytes/Sec Disk Write Bytes/Sec
SQL Server – File Layout 10,000 transactions and 10K SAS drives; About 140 IOPS, therefore, you need 142 of them; Design tempdb to be about 20 percent of the expected I/O for the main data files, so you expect 2,000 IOPS; SATA drives perform sequential operations extremely well, so they are a great candidate for dump drives (RAID 6); You should completely isolate the log onto its own set of RAID 1+0 SAS disk drives;
SQL Server – File Layout Microsoft recommends the use of a 64KB allocation unit size for data, logs, and tempdb; When using SQL Server FILESTREAM to store unstructured data, ensure that the partition used to host FILESTREAM data is formatted with an appropriate sector size, usually 4KB; SQL Server Analysis Services (SSAS) will read and write cube data to small XML files and should therefore also utilize a 32KB-sector size;
SQL Server – Disk Layout
Disk Benchmark Tools CrystalDiskMark (http://bit.ly/1vm5dPe) SQLIO (http://bit.ly/1obVdIV) DiskSpd (http://bit.ly/1whNzQL)
Referências SQL Server Internal 2012 - Internals & Troubleshooting Microsoft Windows Clustering: Storage Area Networks http://www.microsoft.com/windowsserver2003/techinfo/overview/san.mspx StorPort in Windows Server 2003: Improving Manageability and Performance in Hardware RAID and Storage Area Networks http://www.microsoft.com/windowsserversystem/wss2003/techinfo/plandeploy/storportwp.mspx Virtual Device Interface Specification http://www.microsoft.com/downloads/details.aspx?FamilyID=416f8a51-65a3-4e8e-a4c8-adfe15e850fc&DisplayLang=en Windows Server System Storage Home http://www.microsoft.com/windowsserversystem/storage/default.mspx Microsoft Storage Technologies – Multipath I/O http://www.microsoft.com/windowsserversystem/storage/technologies/mpio/default.mspx Storage Top 10 Best Practices http://sqlcat.com/top10lists/archive/2007/11/21/storage-top-10-best-practices.aspx