Maximizing performance via tuning and optimization
The document discusses performance tuning and optimization strategies for MariaDB servers, covering best practices in server configuration, storage options, and connection handling. It emphasizes monitoring metrics, configuring settings, and query tuning to maximize database performance. Additional resources and references for further reading on tuning techniques and tools are provided.
Overview of maximizing MariaDB performance through tuning and optimization techniques, indicating the importance of server infrastructure.
Discusses best practices including SLAs, metric capturing, and stress testing to ensure optimal performance and avoid potential performance 'cliffs'.
Focuses on server, storage, network, and OS optimizations that enhance database performance, emphasizing memory, storage types, and efficient network setups.
Addresses connection management in MariaDB, back pressure implications, and configurations that impact connection pooling and resource management.
Examines key configuration settings in MariaDB that significantly influence performance, stressing the importance of proper configurations.
Emphasizes the importance of query tuning, finding slow queries, indexing strategies, and using performance tools for optimization.
Final slide for questions and concluding remarks as well as additional resources in the appendix for further learning.
• Service LevelAgreements (SLAs) – Individual Biz/App Transactions – Throughput – Latency (at percentile) – Peaks of peaks or favorable scheduling? • Translate to Database Transactions Define Target
• Dedicated Server •Memory – More usually helps (up to ~dataset size) – Important with read-heavy + slow disk • More CPUs – Highly concurrent use cases – Usually favored over faster CPUs • Faster CPUs – Less concurrent use cases – Dataset fits in memory Database Server
11.
• Local orSAN over NAS – Performance • SSD over HHD – Performance and MTBF – SSD wear not usually a factor • SSDs – Consumer – Prosumer – PCIe – NVMe Storage
12.
• Can beBandwidth Hungry – Regular client traffic – Replication Traffic – Rebuilding replicas from snapshots • Stability matters for Replication • Sometimes overlooked as potential bottleneck • Efficient DNS setup* Network
13.
• vm.swappiness =10 • ext4 or xfs for data files • noatime for filesystem mounts • ulimit changes OS (Linux) mariadb.com/kb/en/library/operating-system-optimizations/
• Runtime changesvia SET GLOBAL • Make permanent with changes to my.cnf – Make sure you have right my.cnf – Verify with SHOW GLOBAL • One change at a time • Production changes – tested, reviewed, version controlled Changing Config Settings my.cnf
Finding Slow Queries slow_query_log =1 slow_query_log-file = /var/lib/mysql/myslow.log long_query_time = 10 Pay attention to similar queries and the query count
24.
Analyzing Slow Queries EXPLAIN SELECT * FROMemployees WHERE MONTH(birth_date) = 8 G id: 1 select_type: SIMPLE table: employees type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 299587 Extra: Using where
25.
• Poor Indexing#1 Reason for poor performance • Basics of B-Tree Indexing same across relational systems • Space/Performance Tradeoff • Write/Read Tradeoff Indexing
26.
• PRIMARY KEY= Clustered Index • Secondary Indexes reference hold primary key – key PRIMARY KEY small • InnoDB Table Stats • Optimizer Hints – https://mariadb.com/kb/en/library/optimizer-hints/ InnoDB Indexing Tips
27.
Query Tuning SHOW STATUS Globalor Session ● Returns List of Internal Counters ● GLOBAL for System-Wide Status — Since Start-Up ● SESSION for Local to Client Connection ● FLUSH STATUS Resets Local Counters ● Monitor Changes to Counters to Identify Hot Spots ● Collect Periodically Status Snapshots to Profile Traffic
28.
Query Tuning PERFORMANCE_SCHEMA ● Similarto INFORMATION_SCHEMA , but Performance Tuning ● Monitors MariaDB Server Events ● Function Calls, Operating System Waits, Internal Mutexes, I/O Calls ● Detailed Query Execution Stages (Parsing, Statistics, Sorting) ● Some Features Storage Engine Specific ● Monitoring Lightweight and Requires No Dedicated Thread ● Designed to be Used Iteratively with Successive Refinement