49
Monitoring Linux Performance for the SQL Server Admin Anthony Nocentino, Enterprise Architect, Centino Systems

Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

Embed Size (px)

Citation preview

Page 1: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

MonitoringLinuxPerformancefortheSQLServerAdminAnthonyNocentino,EnterpriseArchitect,Centino Systems

Page 2: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

TechnicalAssistance

If you require assistance during the session, type your inquiry into the question pane on the right side.

Maximize your screen with the zoom button on the top of the presentation window.

Please fill in the short evaluation following the session. It will appear in your web browser.

Page 3: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

ThankYoutoOurSponsors

SUSEisapioneerinopensourcesoftware.Theyprovidereliable,software-definedinfrastructureandapplicationdeliverysolutionsthatgiveenterprisecompanies

greatercontrolandflexibility.Formorethan25yearsthey’vebeendeliveringengineeringexcellence,exceptional

serviceandanunrivaledpartnerecosystemtohelptheircustomersmanagecomplexity,reducecost,andconfidentlydelivermission-criticalservices.

Formoreinformationvisit:https://www.suse.com/partners/alliance/microsoft/sql-server-on-linux/

Page 4: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

LEARN MORE

Career Centerhttp://www.pass.org/Careers.aspx

Page 5: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

AnthonyE.NocentinoEnterpriseArchitect,CentinoSystems

[email protected]

ConsultantandTrainer

FounderandPresidentofCentino Systems

Specializeinsystemarchitectureandperformance

ComputerScience,M.S.andB.S.

MicrosoftMVP- DataPlatform

FriendofRedgate

LinuxFoundationCertifiedEngineer

MicrosoftCertifiedProfessional

Otherplacesonline…

Blog- www.centinosystems.com/blog

PluralsightAuthor

/nocentino @nocentino

Page 6: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• LinuxSystemArchitecture• SQLonLinuxArchitecture• SystemComponents

• CPU/Processes• Memory/Pages• Disk/FileSystems

• MonitoringTools

Agenda

Page 7: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• LinuxOSconcepts,howitworks!• Toolstoviewperformancedata• What’sgoodandwhat’sbad

Thingswe’regoingtocover

Thingswe’reNOTgoingtocover• SQLServerinternals• Performancetroubleshooting

Page 8: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

LinuxArchitecture

Kernel Resource Management and Access

Process, Pages and File Systems

ShellExecutes Your

Commands…Your Interface to the Kernel

Commands, Editors…any User Program

Hardware Physical Resources CPU, Memory and Disk

Users Interact with the Shell Cause Problems :)

Kern

el

Spac

eUs

er S

pace

Page 9: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

SQLonLinuxArchitecture- Drawbridge

From:https://blogs.technet.microsoft.com/dataplatforminsider/2016/12/16/sql-server-on-linux-how-introduction/

Page 10: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

SQLOS

PlacingtasksintoworkersandgettingaccesstotheCPU

Controllingaccesstosystemresources

SchedulingofI/Obothnetworkanddisk

Allocationofmemorytovarioussystemobjects

Scheduling Synchronization I/OMemoryManagement

PrimaryfunctionisresourcemanagementspecifictoRDBMS

“AnewplatformlayerinSQLServer2005toexploitnewhardwarecapabilitiesandtheirtrends”S.Oks

“OperatingSystemsupportforDatabaseManagement”M.Stonebraker

Page 11: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

SQLonLinuxArchitecture- ProcessLayout

From: https://blogs.technet.microsoft.com/dataplatforminsider/2016/12/16/sql-server-on-linux-how-introduction/

Page 12: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

SQLonLinuxArchitecture- SQLPAL

From:https://blogs.technet.microsoft.com/dataplatforminsider/2016/12/16/sql-server-on-linux-how-introduction/

AllotherCode

Win32HostedAPIs(LibOS) SQLOSAPI

SQLOSv2

HostExtension(Memory,Threads/Scheduling,I/O)

PerformanceSensitiveCode

LinuxKernelviaSystemCalls

Page 13: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• CalltablemapsWin32APIsemanticstoLinuxSystemcalls• ~45ABICalls• MemoryManagement• ThreadsandScheduling• SynchronizationPrimitives• I/ONetworkandDisk

• Wecarealotabouthostextensions…it’smorecode

SQLonLinuxArchitecture- HostExtensions

Page 14: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Processvirtualization(notmachine)• Presentinganotherenvironmentinsidetheprocess’contextthat’sdifferentthan

thatofthehardware’soperatingenvironment

• ButtheenvironmentispurposebuiltforSQLServer

• WeneedtounderstandthatthisisahybridWin32/Linuxprocessandhaveafirmgraspof• ResourceallocationandmanagementinSQLPAL• HowthatturnsintoLinuxOSperformance• Debugging

Shhhhhh- SQLPALisVirtualization;)

Page 15: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

CPUandProcesses

Page 16: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Process• Executingprogram,programcode,memoryandresources

• Thread(LWP)• Sharedaccesstoresources

• ProcessandThreadCreation• fork/exec - parentprocessyieldsachildprocesswithanewPID• clone - sameaddressspaceasthreadcreator,cheapandfast!

• ProcessTree• Thehierarchyofparentandit’schildprocesses

WhatisaProcess

Page 17: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Process States

WhatisaProcess(con’t)

Running

Runnable

ZombieStopped

Sleeping

Page 18: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Signals• Methods of process control• kill and killall

• Niceness• Set the execution priority• nice and renice• Default 20, lower is less “nice”

ControllingProcesses

Page 19: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Contextswitching• KernelversusUserMode• CPUScheduling• HowisaSQLOSWorkerscheduledontotheCPU?• Createsathreadviapthreadandthat’spushedintothescheduler

• pthreads?

MoreonProcesses…

Page 20: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Unitofschedulingisthethread• DefaultschedulerisSCHED_OTHER/SCHED_NORMAL

• Timesharingscheduler• Preemptive• Dynamicprioritylist,basedonniceness• Calculatedquantumlengthbasedonpriority

Process/ThreadScheduling

Page 21: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Unitofschedulingisthethread• DefaultschedulerisSCHED_OTHER/SCHED_NORMAL

• Timesharingscheduler• Preemptive• Dynamicprioritylist,basedonniceness• Calculatedquantumlengthbasedonpriority• kernel.sched_min_granularity_ns = 10000000 (10ms)- default• kernel.sched_wakeup_granularity_ns = 15000000 (15ms)- default

• NUMAAware,but…• kernel.numa_balancing = 0 - default

Process/ThreadScheduling

Page 22: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Percentageofwhat?• Loadaverage• RunqueuelengthandI/Owaits• Spikesaren’tbad• Longwaits• User• I/O- disklatencywilleffectaccesstotheCPU• System

CPU- Whattolookfor?

Page 23: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• top/htop• ps• mpstat/pidstat• dstat• procfs

Toolstouseforprocessmonitoring

Page 24: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Processesandthreads• RunloadaverageunderCPUsaturation• Exploringprocfs

Demos

Page 25: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

MemoryandPages

Page 26: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• MemoryLayoutandArchitecture• PhysicalandVirtualMemory• NUMA- freelistspernode• Pages(Anonymous)• DemandPaging• Swapout• TimeandPressure

• Swapin,MajorPageFault• Allocation,MinorPageFault

• FileSystemCacheandswappiness - http://red.ht/2cHg9Vk

Memory

Page 27: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Regularpages- 4KB• Transparenthugepages- 2MB• IncreasesmemoryI/ObydecreasingTLBcachemisses

• SQLOSv2• CanrequestlargepagesinsideSQLServer…withtraceflag834• SQLwillallocatememoryonstartup• WhenSQLPALexposes8GB+toSQLServer

• Asoftoday,nolockedpages…butTF835ison?

Pages

Page 28: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Highconsumersofspace• Physical• Virtual

• ExternalmemorypressureonSQLServer• Excessiveswapping• swappingin/out

Memory- Whattolookfor?

Page 29: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• /proc/meminfo• free• top/htop• ps• vmstat• pidstat

Toolstouseformemorymonitoring

Page 30: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Memorylayout• Isolatingamemoryhog• Identifyingexternalmemorypressure• ExternalmemorypressureonSQLServer

• Excessiveswapping• Swappingin/Swappingout

Demos

Page 31: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

DisksandFileSystems

Page 32: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Sectors(physical)• Actualstorageunitofthedisk,512Bor4KB

• Blocks(logical)• FundamentalunitofI/O,allocation

• Diskshavefiniteperformancecharacteristics• Bandwidth- howmuchdata• Latency- howfast

• StorageInterconnects• Internal• External

Disks

Page 33: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• XFS• Defaultfilesystem- http://red.ht/2dBXccx

• EXT4• Blocksize• Impactutilizationandperformancenominally• 4KBdefaultblocksize

• Mounttimeoptions• Accesstimes- noatime

FileSystems

Page 34: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• XFSandEXT4essentiallythesame• Files• i-nodes• Extents• Blocks

BlockAllocationinLinux

Page 35: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• StreamI/OviaNTUM

• FastI/Oviathehostextension• KernelasynchronousIO(kaio)• io_submit()• Returnstocallerimmediately,completionpollingisinuserspace

• O_DIRECT - bypassespagecacheandI/Ostaysinusermode• fsync()• “probablydesignedbyaderangedmonkeyonsomeseriousmind-controllingsubstances.”- Linus• man 2 open

I/OunderSQLPAL

Page 36: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• SaturateddisksandI/Osubsystems• Swapping• Baseline!

Disks- Whattolookfor?

Page 37: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• iostat• iotop• pidstat• dstat

Toolstousefordiskmonitoring

Page 38: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• FindinghighI/Oprocesses• Measuringdisklatency(DMVsandcmdlinetools)• sys.dm_io_virtual_file_stats

Demos

Page 39: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

MonitoringTools

Page 40: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Nearlyeverythingwe’vetalkedaboutsofarhasbeenpointintime…whataboutbaselining?

• sar - SystemActivityReporter• dstat - writestoCSV

BaseliningTools

Page 41: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Youhaveallofthesametoolsyou’reusedtoforSQLServer• BecauseofSQLOSweget• DMVs• ExtendedEvents

ToolsforMonitoringSQLServer

Page 42: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• NewDMVs

• PSSDiag• https://blogs.msdn.microsoft.com/sqlcat/2017/08/11/collecting-performance-data-with-

pssdiag-for-sql-server-on-linux/• DBFS• https://github.com/Microsoft/dbfs• http://www.centinosystems.com/blog/sql/dbfs-command-line-access-to-sql-server-dmvs/

• Grafana• https://blogs.msdn.microsoft.com/sqlcat/2017/07/03/how-the-sqlcat-customer-lab-is-

monitoring-sql-on-linux/

NewToolsAvailableforSQLonLinux

Page 43: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• Don’tjustlistentome…here’swhatMicrosoftisinterestedin• CPU- mpstat,pidstat• Disk- iostat,iotop• Memory- free,sar• Network- sar• DMVData• Systemloginformation

MetricsCapturedbyPSSDiag

Page 44: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

• LinuxSystemArchitecture• SQLonLinuxArchitecture• SystemComponents

• CPU/Processes• Memory/Pages• Disk/FileSystems

• MonitoringTools

Review

Page 45: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

Needmoredata?Blogwww.centinosystems.com/blog

PluralsightUnderstandingandUsingEssentialToolsforEnterpriseLinux7Linuxbasics,systemarchitecture,fileanddirectorymanagement

LFCE:AdvancedNetworkandSystemAdministrationsystemd,PerformanceandTools,remotefilesystemsandKerberos

SQLServeronLinuxAdministrationFundamentalsInstallation,configurationandmanagement

Page 46: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

References

Manyofthemanpages

https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-performance-best-practices

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/performance_tuning_guide/index

https://www.kernel.org/doc/Documentation/

https://ext4.wiki.kernel.org/index.php/Clarifying_Direct_IO%27s_Semantics

Page 47: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

Questions?

Page 48: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

SQLServeronLinux:DBAFocusedLessonsLearnedfromEarlyDeployments• Denzil Ribeiro

Comingupnext….

Page 49: Monitoring Linux Performance for the SQL Admin - …€¢Disk/File Systems •Monitoring Tools ... •DBFS •https: ... Monitoring Linux Performance for the SQL Admin - PPTX Author:

Thankyouforattending!