SlideShare a Scribd company logo
© 2020 Percona 1
Focus on the Traffic
Spike
Different causes of slowdown
have different approaches, we
focus on Traffic Spike in this
Presentation
© 2020 Percona 3
Something you
can do NOW
Focus on Changes which you
can implement in Hours or
Days, not weeks or Months
© 2020 Percona 4
Companion
Article
© 2020 Percona5
https://per.co.na/18Things
#1 Scale your
Cloud Instance
Size
© 2020 Percona6
https://aws.amazon.com/ec2/instance-types/
Scaling Instance
Size when
Money are not
concern
© 2020 Percona7
Best Practice
© 2020 Percona 8
Scaling by the Credit Card
Use As Temporary Solution
While you find more cost effective options
Or until Traffic Spike Passes
#2 Deploy More
MySQL Slaves
© 2020 Percona9
Read Intensive
Applications
© 2020 Percona 10
Works best for Read Intensive Applications
Still needs massive amount of data copies (you
pay for)
Caching not very efficient due to many copies in
memory
Changing Application to get advantage of Replicas
may be hard
#3 Deploy
ProxySQL
© 2020 Percona 11
ProxySQL
Considerations
© 2020 Percona 12
Great for Connection Pooling
Can assist with Read-Write Splitting
Supports TTL (Time to Live) based Query Caching
Helps to improve High Availability with Failover
Handling
Why NOT
ProxySQL
© 2020 Percona 13
ProxySQL is NOT
100% MySQL
Compatible
Some application
Adjustments may
need be required
ThreadPool in
Percona Server for
MySQL, MariaDB
Connection Pool in
your Application
Server (Java etc)
#4 Disable Heavy
Load Application
Features
© 2020 Percona 14
Great Application Design Practice –
allow disabling features easier
What Are high load and low business
value features ?
Can be applied to specific users too
#5 Check for
Resource
Bottlenecks
© 2020 Percona15
https://per.co.na/PMM
Primary Raw
Resources of a
System
© 2020 Percona16
#6 Get More CPU
Cores, or Faster
Cores
© 2020 Percona17
Look at Run
Queue Latency
© 2020 Percona18
Tool from BCC Tools Collection https://github.com/iovisor/bcc
Beware of
Stealing
© 2020 Percona19
“Compute
Optimized”
© 2020 Percona20
#7 Get More
Memory
© 2020 Percona21
Do not Run out of Virtual Memory
© 2020 Percona 22
Beware Serious Swapping
© 2020 Percona 23
True Memory
Usage by Process
© 2020 Percona24
Look at Resident + Swap
#8 Move to
Faster Storage
© 2020 Percona 25
Memory is faster than fastest storage
Fast Storage for Write Performance
Fast Storage for Read Performance,
when data set is so large fitting in
memory is impractical
Amount and Type of IO Activity
© 2020 Percona 26
How Latency Compares to the Historical
© 2020 Percona 27
“Fsync” Is Special kind of IO
© 2020 Percona 28
Biolatency: Block
Device Latency
© 2020 Percona29
Tool from BCC Tools Collection https://github.com/iovisor/bcc
#9 Check your
Network
© 2020 Percona 30
Bandwidth
Latency
Packet Loss
How Much Network Traffic do you Have ?
© 2020 Percona 31
External
Measurmenets
© 2020 Percona32
Retransmits – The silent Killer
© 2020 Percona 33
Where
Retransmits
come from
© 2020 Percona34
Tool from BCC Tools Collection https://github.com/iovisor/bcc
#10 Locate and
Optimize Queries
which cause the
load
© 2020 Percona35
Query Execution
Details
© 2020 Percona36
Check Explain
© 2020 Percona 37
#11 Add Missing
Indexes
© 2020 Percona 38
Missing Index can cause query to run
1000s times slower than it should
Most Applications Have Some Missing
Indexes
Index Purpose: Lookup Data, Sorting,
Serving The Data
#12 Drop
Unneeded
Indexes
© 2020 Percona 39
Indexes are Expensive both for Writes and for
Reads
You only should have indexes you need – Drop
Unused Indexes
Drop Duplicate Indexes
Assess Redundant Indexes for Dropping
#13 Configure
MySQL Server
Properly
MySQL Defaults are not designed for High Performance Servers or
High Intensity Workloads
© 2020 Percona40
Top MySQL Settings To Change
max_connections=N
table_definition_cache=M
table_open_cache=X
innodb_buffer_pool_size= 16G (70% of RAM)
innodb_flush_method=O_DIRECT
innodb_log_file_size=2G
© 2020 Percona 41
Operating
System Limits
Limit of Open Files is the most important for MySQL
© 2020 Percona42
#14 Purge
Unneeded Data
© 2020 Percona 43
Is old data needed in the same
operational database ?
Move to different Server
Move to Archival Storage
Tool to Consider
pt-archiver
© 2020 Percona44
#15 Perform
Database
Maintenance
• Database Stats getting out of sync – ANALYZE TABLE
• Database Fragmentation and Bloat – OPTIMIZE TABLE
© 2020 Percona45
Optimizing All
Tables mysqlcheck –optimize -A
© 2020 Percona46
Word of Caution Database Maintenance makes database faster but takes a lot of
resources to run - not a good thing to do during peak load
© 2020 Percona 47
#16 Check your
Background Jobs
© 2020 Percona 48
Can this Background Jobs postponed beyond Peak Times
Can this job be run on the replica (or other data jobs)
Am I avoiding batch job overlaps ?
Is this background job overdue for optimization ?
Can resources this background job uses be limited ?
(throttling)
#17 Check for
Data Hotspots
Data Hotspots – data objects (typically row) which have read,
write or locking contention
© 2020 Percona49
Can cause excessive Errors due to Rollbacks
© 2020 Percona 50
Can see specific queries having issues
© 2020 Percona 51
#18 Check your
Application
Server
Configuration
© 2020 Percona 52
Re-Establishing
Connections
Unnecessary, Especially
with SSL/TLS
Poor Connection Pool
Settings
Poor Performance
Settings (especially for
JDBC)
Use of Prepared
Statements
Caching Settings (if
Available)
Summary
© 2020 Percona 53
Facing Traffic
spike with
MySQL – Do not
Panic
There are many
tools available
for you
Do not try
applying all of
them, pick most
appropriate
ones
Average system
can candle at
least 3x times
traffic using only
changing “low
hanging fruits”
Peter Zaitsev "18 ways to fix MySQL bottlenecks"
Thank you, Let’s Connect!
https://www.linkedin.com/in/peterzaitsev/
https://twitter.com/PeterZaitsev

More Related Content

PDF
Anton Moldovan "Building an efficient replication system for thousands of ter...
PDF
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
PPTX
[오픈소스컨설팅] Linux Network Troubleshooting
PPTX
Troubleshooting common oslo.messaging and RabbitMQ issues
PDF
Tuning TCP and NGINX on EC2
PPTX
Commication Framework in OpenStack
PDF
[2018.10.19] Andrew Kong - Tunnel without tunnel (Seminar at OpenStack Korea ...
PDF
[233] level 2 network programming using packet ngin rtos
Anton Moldovan "Building an efficient replication system for thousands of ter...
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
[오픈소스컨설팅] Linux Network Troubleshooting
Troubleshooting common oslo.messaging and RabbitMQ issues
Tuning TCP and NGINX on EC2
Commication Framework in OpenStack
[2018.10.19] Andrew Kong - Tunnel without tunnel (Seminar at OpenStack Korea ...
[233] level 2 network programming using packet ngin rtos

What's hot (20)

PDF
[OpenInfra Days Korea 2018] (Track 3) - CephFS with OpenStack Manila based on...
PDF
Kubernetes at Datadog Scale
PDF
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
PDF
Performance optimization 101 - Erlang Factory SF 2014
PDF
jtf2016-mom
PPTX
HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)
PPTX
Usenix lisa 2011
PDF
Linux network stack
PDF
Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
PDF
Automated Deployment & Benchmarking with Chef, Cobbler and Rally for OpenStack
PDF
XPDS14 - Scaling Xen's Aggregate Storage Performance - Felipe Franciosi, Citrix
PDF
How to tune Kafka® for production
PDF
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
PDF
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
PPTX
Go語言開發APM微服務在Kubernetes之經驗分享
PDF
Scaling Apache Pulsar to 10 Petabytes/Day
PDF
High Performance Erlang - Pitfalls and Solutions
PDF
Kubernetes 1001
PDF
How to monitor NGINX
PDF
HTTP/2, HTTP/3 and SSL/TLS State of the Art in Our Servers
[OpenInfra Days Korea 2018] (Track 3) - CephFS with OpenStack Manila based on...
Kubernetes at Datadog Scale
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
Performance optimization 101 - Erlang Factory SF 2014
jtf2016-mom
HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)
Usenix lisa 2011
Linux network stack
Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
Automated Deployment & Benchmarking with Chef, Cobbler and Rally for OpenStack
XPDS14 - Scaling Xen's Aggregate Storage Performance - Felipe Franciosi, Citrix
How to tune Kafka® for production
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
Go語言開發APM微服務在Kubernetes之經驗分享
Scaling Apache Pulsar to 10 Petabytes/Day
High Performance Erlang - Pitfalls and Solutions
Kubernetes 1001
How to monitor NGINX
HTTP/2, HTTP/3 and SSL/TLS State of the Art in Our Servers
Ad

Similar to Peter Zaitsev "18 ways to fix MySQL bottlenecks" (20)

PDF
17 Things Developers Should Know About Databases
PPTX
The 5 Minute DBA-DBA Skills for Non-DBA
PDF
Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...
PDF
Peter Zaitsev - Practical MySQL Performance Optimization
PDF
Performance optimisations PHP meetup Rotterdam
PDF
A Deep Dive into Query Performance
PDF
Capacity planning for your data stores
PDF
Running MySQL on Linux
PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
PDF
Modern Database Best Practices
PDF
Evolution of DBA in the Cloud Era
PPTX
How to upgrade like a boss to my sql 8.0?
PPTX
Why are we excited about MySQL 8? / Петр Зайцев (Percona)
PDF
MySQL Performance for DevOps
PDF
High Performance MySQL Optimization Backups Replication and More Second Editi...
PDF
Developing a database server: software engineer's view
ODP
Beyond php it's not (just) about the code
PDF
Fosdem managing my sql with percona toolkit
PDF
The 5 Minute MySQL DBA
PDF
Webinar replay: MySQL Query Tuning Trilogy: Query tuning process and tools
17 Things Developers Should Know About Databases
The 5 Minute DBA-DBA Skills for Non-DBA
Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...
Peter Zaitsev - Practical MySQL Performance Optimization
Performance optimisations PHP meetup Rotterdam
A Deep Dive into Query Performance
Capacity planning for your data stores
Running MySQL on Linux
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
Modern Database Best Practices
Evolution of DBA in the Cloud Era
How to upgrade like a boss to my sql 8.0?
Why are we excited about MySQL 8? / Петр Зайцев (Percona)
MySQL Performance for DevOps
High Performance MySQL Optimization Backups Replication and More Second Editi...
Developing a database server: software engineer's view
Beyond php it's not (just) about the code
Fosdem managing my sql with percona toolkit
The 5 Minute MySQL DBA
Webinar replay: MySQL Query Tuning Trilogy: Query tuning process and tools
Ad

More from Fwdays (20)

PDF
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
PPTX
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
PPTX
"Як ми переписали Сільпо на Angular", Євген Русаков
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
PDF
"Validation and Observability of AI Agents", Oleksandr Denisyuk
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
PPTX
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
PPTX
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
PDF
"AI is already here. What will happen to your team (and your role) tomorrow?"...
PPTX
"Is it worth investing in AI in 2025?", Alexander Sharko
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
PDF
"Scaling in space and time with Temporal", Andriy Lupa.pdf
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
PDF
"Scaling in space and time with Temporal", Andriy Lupa .pdf
PPTX
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
PPTX
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
PPTX
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
"Як ми переписали Сільпо на Angular", Євген Русаков
"AI Transformation: Directions and Challenges", Pavlo Shaternik
"Validation and Observability of AI Agents", Oleksandr Denisyuk
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
"AI is already here. What will happen to your team (and your role) tomorrow?"...
"Is it worth investing in AI in 2025?", Alexander Sharko
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Database isolation: how we deal with hundreds of direct connections to the d...
"Scaling in space and time with Temporal", Andriy Lupa .pdf
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Getting Started with Data Integration: FME Form 101
PDF
cuic standard and advanced reporting.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Weekly Chronicles - August'25-Week II
20250228 LYD VKU AI Blended-Learning.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
Assigned Numbers - 2025 - Bluetooth® Document
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Getting Started with Data Integration: FME Form 101
cuic standard and advanced reporting.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Programs and apps: productivity, graphics, security and other tools
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx

Peter Zaitsev "18 ways to fix MySQL bottlenecks"