SlideShare a Scribd company logo
Running	
  MySQL	
  on	
  Linux	
  
Peter	
  Zaitsev	
  
CEO,	
  Percona	
  
Great	
  Wide	
  Open	
  	
  
Atlanta,GA	
  
16	
  March	
  2016	
  
	
  
About	
  Percona	
  
Solu@ons	
  for	
  
Success	
  with	
  
MySQL	
  and	
  
MongoDB	
  
Support,	
  
Consul@ng,	
  
Managed	
  Services	
  
SoIware	
  for	
  
Success	
  with	
  Data	
  
Management	
  
100%	
  Open	
  
Source,	
  no	
  lock-­‐in	
  
required	
  
About	
  the	
  Presenta8on	
  
• Distribu@on	
  
• Hardware	
  
• OS	
  Configura@on	
  
• MySQL	
  Installa@on	
  
• MySQL	
  Configura@on	
  	
  
Cover	
  what	
  
you	
  need	
  
to	
  run	
  
MySQL	
  on	
  
Linux	
  
successfully	
  
3	
  
Why	
  Linux	
  ?	
  
Most	
  Popular	
  PlaVorm	
  for	
  Produc@on	
  
Deployments	
  
The	
  main	
  plaVorm	
  for	
  MySQL	
  Engineering	
  
Efforts	
  
Great	
  Default	
  Choice!	
  
4	
  
Choices	
  
• Long	
  Support;	
  Stability	
  
“Server	
  Grade	
  
Distribu@on”	
  
• Especially	
  with	
  Newer	
  
Hardware	
  
Recent	
  
enough	
  	
  
• RHEL/CentOS/Oracle/Amazon	
  
• Debian,	
  Ubuntu	
  
Most	
  Popular	
  
Choices	
  
Things	
  to	
  Consider	
  
Low	
  Overhead	
  
monitoring	
  support	
  
“perf”,	
  Irace,	
  eBPF	
  
NVMe	
   Docker	
  Support	
  
File	
  System	
  
Encryp@on	
  
New	
  Block	
  Device	
  
Infrastructure	
  
SoIware	
  RAID	
  
6	
  
Hardware	
  
• Really!	
  
Hardware	
  can	
  
go	
  a	
  long	
  way!	
  	
  
• With	
  100	
  queries/page	
  =	
  120K	
  page	
  
views/minute	
  
• Some	
  80M	
  page	
  views/day	
  
(considering	
  daily	
  spike)	
  
Over	
  200K	
  
simple	
  queries/
sec	
  on	
  modern	
  
hardware	
  
7	
  
MySQL 5.7 Performance Improvements
Sysbench Benchmark
*Informa)on	
  from	
  Oracle	
  OpenWorld	
  presenta)on	
  by	
  Geir	
  Hoydalsvik	
  
Starts	
  with	
  8	
  Threads	
  
What	
  about	
  2-­‐4	
  threads?	
  
Hardware	
  
• Go	
  for	
  fast	
  cores.	
  All	
  cores	
  are	
  rarely	
  
used	
  these	
  days	
  
• Cache	
  and	
  fast	
  memory	
  bus	
  are	
  
important	
  
CPU	
  
• OIen	
  most	
  important	
  for	
  performance	
  
• Your	
  working	
  set	
  must	
  fit	
  in	
  memory	
  
well	
  
• Less	
  memory	
  =	
  more	
  pressure	
  on	
  IO	
  
Memory	
  
9	
  
Choose	
  Solid	
  State	
  for	
  Main	
  Storage	
  
Proprietary	
  PCE-­‐E	
  and	
  NVMe	
  
SATA	
  SSDs	
  very	
  inexpensive	
  
SoIware	
  RAID	
  to	
  beat	
  SATA	
  limits	
  
SSDs	
  available	
  in	
  the	
  cloud	
  –	
  use	
  them	
  
Not	
  all	
  Flash	
  is	
  created	
  equal	
  
10	
  
More	
  on	
  SSD/Flash	
  
Think	
  about	
  Write	
  Endurance	
  
Behavior	
  on	
  Power	
  Loss	
  	
  
Data	
  Reten@on	
  	
  
Firmware	
  
11	
  
Know	
  your	
  Goals	
  
• Reads?	
  	
  
• Writes?	
  	
  
• Random?	
  	
  
• Sequen@al?	
  
Are	
  you	
  bound	
  by	
  	
  
• Sustained	
  writes?	
  	
  	
  	
  	
  
• Handle	
  spikes?	
  Do	
  you	
  need	
  	
  
• Many	
  devices	
  reach	
  peak	
  IOPs	
  at	
  unreachable	
  concurrency	
  
What	
  concurrency	
  
do	
  you	
  operate?	
  
• SAN/NAS	
  is	
  a	
  frequent	
  cause	
  of	
  surprise	
  
Think	
  about	
  latency/
response	
  @me	
  
12	
  
Performance	
  vs.	
  Memory	
  
13	
  
Compression	
  of	
  Performance	
  Gains	
  
14	
  
Network	
  
Latency	
  is	
  king	
  
Minimize	
  number	
  of	
  hops	
  between	
  Database	
  and	
  Web	
  Server	
  
Ensure	
  running	
  1Gbit	
  link	
  speed	
  at	
  least	
  (10Gb	
  is	
  gaining	
  popularity)	
  
Monitor	
  for	
  packet	
  loss	
  and	
  latency	
  
Network	
  problems	
  are	
  oIen	
  blamed	
  on	
  database	
  
15	
  
Network	
  Tuning	
  
Might	
  be	
  needed	
  some@mes	
  
• echo	
  8192	
  >	
  /proc/sys/net/ipv4/tcp_max_syn_backlog	
  
• Mysql:	
  	
  back_log=1000	
  
• net.ipv4.ip_local_port_range="1024	
  64000“	
  
• net.core.somaxconn	
  =	
  1024	
  
• net.core.rmem_max	
  =	
  16777216	
  
• net.core.wmem_max	
  =	
  16777216	
  
• net.ipv4.tcp_rmem	
  =	
  4096	
  87380	
  16777216	
  
• net.ipv4.tcp_wmem	
  =	
  4096	
  65536	
  16777216	
  
• net.ipv4.max_tw_buckets=360000	
  
• net.core.netdev_max_backlog	
  =	
  2500	
  
• ifconfig	
  eth0	
  txqueuelen	
  1000	
  
Persistent	
  connec@ons	
  with	
  MySQL	
  
• Thread_pool	
  	
  	
  (Percona	
  Server,	
  MariaDB,	
  MySQL	
  Enterprise)	
  
• 	
  Proxy	
  
16	
  
Virtualiza8on	
  and	
  Cloud	
  
Virtualiza@on	
  has	
  cost	
  
Cloud	
  rarely	
  provides	
  highest	
  performance	
  
hardware	
  (Getng	
  beuer)	
  
There	
  is	
  a	
  lot	
  of	
  MySQL	
  use	
  in	
  the	
  Cloud	
  
and	
  Virtualized	
  Environments	
  
17	
  
 
	
  
Linux	
  Configura8on	
  
18	
  
In	
  General…	
  
For	
  most	
  workloads	
  
Linux	
  Runs	
  MySQL	
  
surprisingly	
  well	
  with	
  
no	
  addi@onal	
  tuning	
  
19	
  
General	
  Configura8on	
  
• vm.swappiness=0	
  
Reduce	
  
Tendency	
  
to	
  swap	
  
20	
  
General	
  Configura8on	
  
Reduce	
  the	
  File	
  Cache	
  	
  
• vm.dirty_ra@o=5	
  
NUMA	
  can	
  cause	
  problems	
  
• hup://bit.ly/I0GSt3	
  
• Interleaving	
  with	
  numactl	
  
• MySQL	
  5.6+	
  Supports	
  innodb_numa_interleave	
  
21	
  
Storage	
  Configura8on	
  
• Re-­‐Configure	
  MySQL	
  without	
  OS	
  Reinstall	
  
Separate	
  OS	
  and	
  
MySQL	
  Par@@on	
  
• CFQ	
  can	
  cause	
  problems	
  
• Deadline	
  or	
  Noop	
  are	
  oIen	
  beuer	
  choice	
  
• elevator=deadline	
  on	
  kernel	
  boot	
  
Configure	
  IO	
  
Scheduler	
  
• #	
  echo	
  100000	
  >	
  /sys/block/sdX/queue/nr_requests	
  
Queue	
  length	
  
(especially	
  MyISAM)	
  
• Virtually	
  no	
  overhead	
  when	
  not	
  in	
  snapshot	
  mode	
  
• Reserve	
  some	
  space	
  for	
  snapshots	
  Consider	
  using	
  LVM	
  
22	
  
 
	
  
	
  
	
  
	
  
Which	
  one	
  do	
  you	
  use	
  ?	
  	
  
FILESYSTEMS	
  
23	
  
Filesystems	
  
XFS	
  –	
  “Old”	
  High	
  Performance	
  Favorite	
  
EXT4	
  –	
  Works	
  very	
  good	
  for	
  some	
  workloads	
  
Avoid:	
  
• Ext2	
  
• Ext3	
  
• ReiserFS	
  
• ZFS	
  (may	
  be	
  good	
  for	
  development)	
  	
  
• Btrfs	
  
24	
  
FS	
  Tuning	
  
rela@me	
  (noa@me)	
  
ext3:	
  tune2fs	
  –O	
  dir_index	
  -­‐c	
  –l	
  –i	
  0	
  –e	
  remount-­‐ro	
  
xfs:	
  nobarrier	
  	
  
• Assuming	
  RAID	
  w	
  BBU	
  or	
  Flash	
  
25	
  
WHAT	
  MYSQL	
  VARIANT	
  ARE	
  YOU	
  
RUNING	
  ?	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
26	
  
Main	
  Choices	
  
MySQL	
  	
  
Percona	
  Server	
  
MariaDB	
  
27	
  
MySQL	
  Versions	
  
Newer	
  versions	
  scale	
  beuer	
  
MySQL	
  5.7	
  is	
  most	
  scalable	
  
Percona	
  Server	
  5.7	
  brings	
  even	
  more	
  improvements	
  J	
  
Use	
  5.7	
  for	
  New	
  Development	
  
Upgrade	
  to	
  MySQL	
  5.7	
  if	
  you	
  need	
  it	
  now	
  
28	
  
Check	
  out	
  Percona	
  XtraDB	
  Cluster	
  
Based	
  on	
  Galera	
  Technology	
  
Innodb	
  Storage	
  Engine	
  you	
  already	
  know	
  
Synchronous	
  Replica@on	
  
Parallel	
  Apply	
  
Automa@c	
  Provisioning	
  
No	
  Stale	
  Reads	
  
Not	
  for	
  all	
  workloads	
  
29	
  
How	
  to	
  Install	
  
• hup://dev.mysql.com/downloads/repo/	
  
• hup://www.percona.com/doc/percona-­‐server/5.7/installa@on.html	
  
Use	
  Repositories:	
  
Best	
  
• Need	
  older	
  Version	
  	
  Download	
  RPM/DEB	
  
• Good	
  for	
  tes@ng	
  with	
  MySQL	
  Sandbox	
  Use	
  Tar.gz	
  package	
  
• hups://hub.docker.com/_/percona/	
  Docker	
  Images	
  
• Do	
  you	
  really	
  have	
  good	
  reason	
  to	
  do	
  it	
  ?	
  
• Many	
  problems	
  are	
  caused	
  by	
  bad	
  builds	
  Build	
  our	
  own	
  
30	
  
MySQL	
  Configura8on	
  
• Even	
  newer	
  MySQL	
  5.7	
  defaults	
  
are	
  unlikely	
  to	
  be	
  op@mal	
  
You	
  need	
  to	
  tune	
  MySQL	
  
configura@on	
  
• hup://bit.ly/1fuP0SZ	
  
Check	
  out	
  presenta@on	
  
which	
  goes	
  in	
  depth	
  into	
  
configura@on	
  tuning	
  
• Avoid	
  obsessive	
  tuning	
  disorder	
  
Typically	
  getng	
  5	
  
variables	
  right	
  
responsible	
  for	
  90%	
  
performance	
  gain	
  
31	
  
MySQL	
  Variables	
  
• How	
  many	
  connec@ons	
  
server	
  will	
  support	
  ?	
  
max_connec@ons	
  
• How	
  many	
  “open”	
  tables	
  
there	
  will	
  be	
  allowed	
  
table_open_cache	
  
• How	
  many	
  files	
  can	
  be	
  open	
  	
  open_files_limit	
  
32	
  
Top	
  Variables	
  
•  Set	
  80%	
  of	
  memory	
  some@mes	
  more	
  Innodb_buffer_pool_size	
  
•  Best	
  setng	
  in	
  most	
  cases	
  Innodb_flush_method=O_DIRECT	
  
•  Set	
  256MB	
  or	
  more	
  	
  
•  Larger	
  logs	
  =	
  longer	
  recovery	
  @me	
  
Innodb_log_file_size	
  
•  Truly	
  ACID:	
  1	
  	
  
•  Can	
  Afford	
  Data	
  Loss:	
  2	
  
Innodb_flush_log_at_trx_commit=?	
  
33	
  
Advanced	
  Ideas	
  
• taskset	
  -­‐pc	
  0,12,2,14	
  `cat	
  /var/
lib/mysql/mysqld1.pid`	
  	
  
Running	
  mul@ple	
  
MySQL	
  instances	
  ?	
  
• Jemalloc	
  	
  
• Tcmalloc	
  –old	
  favorite	
  
Memory	
  Alloca@on	
  
Hostspot	
  ?	
  
• Roll	
  back	
  easily	
  if	
  things	
  go	
  
wrong	
  
LVM	
  Snapshot	
  
before	
  maintenance	
  
or	
  upgrade	
  
34	
  
Beware	
  of	
  the	
  “Scripts”	
  
• Timeouts	
  might	
  be	
  
not	
  enough	
  for	
  safe	
  
database	
  shutdown	
  
• The	
  automated	
  
upgrade/check	
  	
  
Start/
Stop	
  
Scripts	
  
can	
  be	
  
nasty	
  
35	
  
Automa8on	
  
Manual	
  approach	
  is	
  a	
  
no	
  
• Does	
  not	
  Scale	
  
• And	
  is	
  Error	
  Prone	
  
Automate	
  installa@on,	
  
upgrades,	
  
configura@on	
  
• Puppet,	
  	
  
• Chef	
  	
  
• Ansible	
  	
  
Keep	
  Configura@on	
  
under	
  version	
  control	
  
• At	
  very	
  least	
  leave	
  
comments	
  on	
  what	
  
you	
  chance	
  and	
  why	
  
36	
  
Monitoring	
  and	
  Trending	
  
•  Just	
  make	
  sure	
  you’re	
  doing	
  it	
  
Many	
  tools	
  to	
  choose	
  
from!	
  
•  Check	
  out	
  PMP	
  
•  hup://www.percona.com/soIware/percona-­‐monitoring-­‐
plugins	
  
Nagios	
  and	
  CACTI	
  
•  hup://grafana.org/	
  
Grafana	
  –	
  new	
  
genera@on	
  trending	
  
•  hup://bit.ly/1M6r7Vk	
  
Check	
  out	
  Grafana	
  +	
  
Prometheus	
  Monitoring	
  
37	
  
Prometheus	
  +	
  Grafana	
  Example	
  
38	
  
Linux	
  OOM	
  Killer	
  
• SSH	
  
• MySQL	
  Server	
  
• Various	
  jobs	
  
• Backup	
  	
  
• Percona	
  Toolkit	
  	
  
• Background	
  Batch	
  jobs	
  
What	
  are	
  
your	
  
priori@es	
  ?	
  
• echo	
  -­‐17	
  >	
  /proc/2592/oom_adj	
  
• do	
  not	
  kill	
  ever	
  
• echo	
  10	
  >	
  /proc/2592/oom_adj	
  	
  	
  
• More	
  like	
  	
  to	
  be	
  killed	
  
Configuring	
  
39	
  
Tools	
  you	
  need	
  to	
  know	
  
General	
  Linux	
  
• Top	
  
• Vmstat	
  
• Iostat	
  
• Strace	
  
• Gdb	
  
• perf	
  
MySQL	
  
• Percona	
  Toolkit	
  
• Innotop	
  
• Percona	
  Xtrabackup	
  
• MyDumper	
  
40	
  
Resources	
  for	
  MySQL	
  on	
  Linux	
  
•  Brendan	
  Gregg’s	
  web	
  site	
  
– hup://www.brendangregg.com/	
  
•  Percona’s	
  Blog	
  
– hup://www.percona.com/blog/	
  
•  Ernie	
  Souhrada	
  IOPS	
  inves@ga@on	
  
– bit.ly/2546xes	
  
41	
  
www.percona.com	
  	
  	
  
Percona	
  Live	
  
Data	
  Performance	
  Conference	
  
•  April	
  18-­‐21	
  in	
  Santa	
  Clara,	
  CA	
  at	
  the	
  Santa	
  Clara	
  
Conven@on	
  Center	
  
•  Register	
  with	
  code	
  “GWO”	
  to	
  receive	
  15%	
  off	
  at	
  
registra@on	
  
•  MySQL,	
  NoSQL,	
  Data	
  in	
  the	
  Cloud	
  
	
  
www.perconalive.com	
  
43	
  
Thank You!
Peter	
  Zaitsev	
  
pz@percona.com	
  
@PeterZaitsev	
  	
  
bit.ly/PerconaJobs	
  

More Related Content

What's hot (20)

PPTX
RubiX
Shubham Tagra
 
PPTX
An introduction to SQL Server in-memory OLTP Engine
Krishnakumar S
 
PDF
What is new in MariaDB 10.6?
Mydbops
 
PDF
Configuring workload-based storage and topologies
MariaDB plc
 
PPT
MySQL HA Percona cluster @ MySQL meetup Mumbai
Remote MySQL DBA
 
PPTX
Oracle GoldenGate for MySQL Overview
Jinyu Wang
 
PDF
Elephants in the Cloud
Mike Fowler
 
PDF
Alluxio Data Orchestration Platform for the Cloud
Shubham Tagra
 
PPTX
Inside CynosDB: MariaDB optimized for the cloud at Tencent
MariaDB plc
 
PDF
ApacheCon 2020 - Flink SQL in 2020: Time to show off!
Timo Walther
 
PDF
Alluxio+Presto: An Architecture for Fast SQL in the Cloud
Alluxio, Inc.
 
PPTX
Using Alluxio as a Fault-tolerant Pluggable Optimization Component of JD.com'...
Alluxio, Inc.
 
PDF
12 in 12 – A closer look at twelve or so new things in Postgres 12
BasilBourque1
 
PDF
Apache Ratis - In Search of a Usable Raft Library
Tsz-Wo (Nicholas) Sze
 
PDF
MySQL Query Optimization (Basics)
Karthik .P.R
 
PPTX
Presentation by TachyonNexus & Intel at Strata Singapore 2015
Tachyon Nexus, Inc.
 
PDF
MariaDB ColumnStore
MariaDB plc
 
PDF
25 snowflake
剑飞 陈
 
PDF
POLARDB: A database architecture for the cloud
oysteing
 
PDF
Bn 1016 demo postgre sql-online-training
conline training
 
An introduction to SQL Server in-memory OLTP Engine
Krishnakumar S
 
What is new in MariaDB 10.6?
Mydbops
 
Configuring workload-based storage and topologies
MariaDB plc
 
MySQL HA Percona cluster @ MySQL meetup Mumbai
Remote MySQL DBA
 
Oracle GoldenGate for MySQL Overview
Jinyu Wang
 
Elephants in the Cloud
Mike Fowler
 
Alluxio Data Orchestration Platform for the Cloud
Shubham Tagra
 
Inside CynosDB: MariaDB optimized for the cloud at Tencent
MariaDB plc
 
ApacheCon 2020 - Flink SQL in 2020: Time to show off!
Timo Walther
 
Alluxio+Presto: An Architecture for Fast SQL in the Cloud
Alluxio, Inc.
 
Using Alluxio as a Fault-tolerant Pluggable Optimization Component of JD.com'...
Alluxio, Inc.
 
12 in 12 – A closer look at twelve or so new things in Postgres 12
BasilBourque1
 
Apache Ratis - In Search of a Usable Raft Library
Tsz-Wo (Nicholas) Sze
 
MySQL Query Optimization (Basics)
Karthik .P.R
 
Presentation by TachyonNexus & Intel at Strata Singapore 2015
Tachyon Nexus, Inc.
 
MariaDB ColumnStore
MariaDB plc
 
25 snowflake
剑飞 陈
 
POLARDB: A database architecture for the cloud
oysteing
 
Bn 1016 demo postgre sql-online-training
conline training
 

Similar to Running MySQL on Linux (20)

PDF
OSDC 2016 - Tuning Linux for your Database by Colin Charles
NETWAYS
 
PDF
Tuning Linux for your database FLOSSUK 2016
Colin Charles
 
PDF
MySQL Performance Tuning London Meetup June 2017
Ivan Zoratti
 
PDF
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
PDF
The Proper Care and Feeding of MySQL Databases
Dave Stokes
 
PDF
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
Dave Stokes
 
PPTX
MySQL Tech Tour 2015 - Manage & Tune
Mark Swarbrick
 
PPT
MySQL Performance Tuning at COSCUP 2014
Ryusuke Kajiyama
 
PDF
MySQL Performance for DevOps
Sveta Smirnova
 
PDF
High Performance MySQL Optimization Backups Replication and More Second Editi...
samsmadomira
 
PDF
Full Download High Performance MySQL Optimization Backups Replication and Mor...
qunajfogoe
 
PDF
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Severalnines
 
PDF
MySQL Performance for DevOps
Sveta Smirnova
 
PDF
My First 100 days with a MySQL DBMS
Gustavo Rene Antunez
 
PDF
50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf
AsparuhPolyovski2
 
PDF
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Dylan Butler
 
PDF
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Dave Stokes
 
PDF
01 demystifying mysq-lfororacledbaanddeveloperv1
Ivan Ma
 
PDF
MySQL Performance - Best practices
Ted Wennmark
 
PDF
Optimizing MySQL for Cascade Server
hannonhill
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
NETWAYS
 
Tuning Linux for your database FLOSSUK 2016
Colin Charles
 
MySQL Performance Tuning London Meetup June 2017
Ivan Zoratti
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
The Proper Care and Feeding of MySQL Databases
Dave Stokes
 
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
Dave Stokes
 
MySQL Tech Tour 2015 - Manage & Tune
Mark Swarbrick
 
MySQL Performance Tuning at COSCUP 2014
Ryusuke Kajiyama
 
MySQL Performance for DevOps
Sveta Smirnova
 
High Performance MySQL Optimization Backups Replication and More Second Editi...
samsmadomira
 
Full Download High Performance MySQL Optimization Backups Replication and Mor...
qunajfogoe
 
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Severalnines
 
MySQL Performance for DevOps
Sveta Smirnova
 
My First 100 days with a MySQL DBMS
Gustavo Rene Antunez
 
50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf
AsparuhPolyovski2
 
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Dylan Butler
 
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Dave Stokes
 
01 demystifying mysq-lfororacledbaanddeveloperv1
Ivan Ma
 
MySQL Performance - Best practices
Ted Wennmark
 
Optimizing MySQL for Cascade Server
hannonhill
 
Ad

More from Great Wide Open (20)

PDF
The Little Meetup That Could
Great Wide Open
 
PDF
Lightning Talk - 5 Hacks to Getting the Job of Your Dreams
Great Wide Open
 
PDF
Breaking Free from Proprietary Gravitational Pull
Great Wide Open
 
PDF
Dealing with Unstructured Data: Scaling to Infinity
Great Wide Open
 
PDF
You Don't Know Node: Quick Intro to 6 Core Features
Great Wide Open
 
PDF
Hidden Features in HTTP
Great Wide Open
 
PPTX
Using Cryptography Properly in Applications
Great Wide Open
 
PDF
Lightning Talk - Getting Students Involved In Open Source
Great Wide Open
 
PPTX
You have Selenium... Now what?
Great Wide Open
 
PDF
How Constraints Cultivate Growth
Great Wide Open
 
PDF
Inner Source 101
Great Wide Open
 
PDF
Search is the new UI
Great Wide Open
 
PDF
Troubleshooting Hadoop: Distributed Debugging
Great Wide Open
 
PPTX
The Current Messaging Landscape
Great Wide Open
 
PDF
Apache httpd v2.4
Great Wide Open
 
PDF
Understanding Open Source Class 101
Great Wide Open
 
PDF
Thinking in Git
Great Wide Open
 
PDF
Antifragile Design
Great Wide Open
 
PDF
Elasticsearch for SQL Users
Great Wide Open
 
PPTX
Open Source Security Tools for Big Data
Great Wide Open
 
The Little Meetup That Could
Great Wide Open
 
Lightning Talk - 5 Hacks to Getting the Job of Your Dreams
Great Wide Open
 
Breaking Free from Proprietary Gravitational Pull
Great Wide Open
 
Dealing with Unstructured Data: Scaling to Infinity
Great Wide Open
 
You Don't Know Node: Quick Intro to 6 Core Features
Great Wide Open
 
Hidden Features in HTTP
Great Wide Open
 
Using Cryptography Properly in Applications
Great Wide Open
 
Lightning Talk - Getting Students Involved In Open Source
Great Wide Open
 
You have Selenium... Now what?
Great Wide Open
 
How Constraints Cultivate Growth
Great Wide Open
 
Inner Source 101
Great Wide Open
 
Search is the new UI
Great Wide Open
 
Troubleshooting Hadoop: Distributed Debugging
Great Wide Open
 
The Current Messaging Landscape
Great Wide Open
 
Apache httpd v2.4
Great Wide Open
 
Understanding Open Source Class 101
Great Wide Open
 
Thinking in Git
Great Wide Open
 
Antifragile Design
Great Wide Open
 
Elasticsearch for SQL Users
Great Wide Open
 
Open Source Security Tools for Big Data
Great Wide Open
 
Ad

Recently uploaded (20)

PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 

Running MySQL on Linux

  • 1. Running  MySQL  on  Linux   Peter  Zaitsev   CEO,  Percona   Great  Wide  Open     Atlanta,GA   16  March  2016    
  • 2. About  Percona   Solu@ons  for   Success  with   MySQL  and   MongoDB   Support,   Consul@ng,   Managed  Services   SoIware  for   Success  with  Data   Management   100%  Open   Source,  no  lock-­‐in   required  
  • 3. About  the  Presenta8on   • Distribu@on   • Hardware   • OS  Configura@on   • MySQL  Installa@on   • MySQL  Configura@on     Cover  what   you  need   to  run   MySQL  on   Linux   successfully   3  
  • 4. Why  Linux  ?   Most  Popular  PlaVorm  for  Produc@on   Deployments   The  main  plaVorm  for  MySQL  Engineering   Efforts   Great  Default  Choice!   4  
  • 5. Choices   • Long  Support;  Stability   “Server  Grade   Distribu@on”   • Especially  with  Newer   Hardware   Recent   enough     • RHEL/CentOS/Oracle/Amazon   • Debian,  Ubuntu   Most  Popular   Choices  
  • 6. Things  to  Consider   Low  Overhead   monitoring  support   “perf”,  Irace,  eBPF   NVMe   Docker  Support   File  System   Encryp@on   New  Block  Device   Infrastructure   SoIware  RAID   6  
  • 7. Hardware   • Really!   Hardware  can   go  a  long  way!     • With  100  queries/page  =  120K  page   views/minute   • Some  80M  page  views/day   (considering  daily  spike)   Over  200K   simple  queries/ sec  on  modern   hardware   7  
  • 8. MySQL 5.7 Performance Improvements Sysbench Benchmark *Informa)on  from  Oracle  OpenWorld  presenta)on  by  Geir  Hoydalsvik   Starts  with  8  Threads   What  about  2-­‐4  threads?  
  • 9. Hardware   • Go  for  fast  cores.  All  cores  are  rarely   used  these  days   • Cache  and  fast  memory  bus  are   important   CPU   • OIen  most  important  for  performance   • Your  working  set  must  fit  in  memory   well   • Less  memory  =  more  pressure  on  IO   Memory   9  
  • 10. Choose  Solid  State  for  Main  Storage   Proprietary  PCE-­‐E  and  NVMe   SATA  SSDs  very  inexpensive   SoIware  RAID  to  beat  SATA  limits   SSDs  available  in  the  cloud  –  use  them   Not  all  Flash  is  created  equal   10  
  • 11. More  on  SSD/Flash   Think  about  Write  Endurance   Behavior  on  Power  Loss     Data  Reten@on     Firmware   11  
  • 12. Know  your  Goals   • Reads?     • Writes?     • Random?     • Sequen@al?   Are  you  bound  by     • Sustained  writes?           • Handle  spikes?  Do  you  need     • Many  devices  reach  peak  IOPs  at  unreachable  concurrency   What  concurrency   do  you  operate?   • SAN/NAS  is  a  frequent  cause  of  surprise   Think  about  latency/ response  @me   12  
  • 14. Compression  of  Performance  Gains   14  
  • 15. Network   Latency  is  king   Minimize  number  of  hops  between  Database  and  Web  Server   Ensure  running  1Gbit  link  speed  at  least  (10Gb  is  gaining  popularity)   Monitor  for  packet  loss  and  latency   Network  problems  are  oIen  blamed  on  database   15  
  • 16. Network  Tuning   Might  be  needed  some@mes   • echo  8192  >  /proc/sys/net/ipv4/tcp_max_syn_backlog   • Mysql:    back_log=1000   • net.ipv4.ip_local_port_range="1024  64000“   • net.core.somaxconn  =  1024   • net.core.rmem_max  =  16777216   • net.core.wmem_max  =  16777216   • net.ipv4.tcp_rmem  =  4096  87380  16777216   • net.ipv4.tcp_wmem  =  4096  65536  16777216   • net.ipv4.max_tw_buckets=360000   • net.core.netdev_max_backlog  =  2500   • ifconfig  eth0  txqueuelen  1000   Persistent  connec@ons  with  MySQL   • Thread_pool      (Percona  Server,  MariaDB,  MySQL  Enterprise)   •   Proxy   16  
  • 17. Virtualiza8on  and  Cloud   Virtualiza@on  has  cost   Cloud  rarely  provides  highest  performance   hardware  (Getng  beuer)   There  is  a  lot  of  MySQL  use  in  the  Cloud   and  Virtualized  Environments   17  
  • 19. In  General…   For  most  workloads   Linux  Runs  MySQL   surprisingly  well  with   no  addi@onal  tuning   19  
  • 20. General  Configura8on   • vm.swappiness=0   Reduce   Tendency   to  swap   20  
  • 21. General  Configura8on   Reduce  the  File  Cache     • vm.dirty_ra@o=5   NUMA  can  cause  problems   • hup://bit.ly/I0GSt3   • Interleaving  with  numactl   • MySQL  5.6+  Supports  innodb_numa_interleave   21  
  • 22. Storage  Configura8on   • Re-­‐Configure  MySQL  without  OS  Reinstall   Separate  OS  and   MySQL  Par@@on   • CFQ  can  cause  problems   • Deadline  or  Noop  are  oIen  beuer  choice   • elevator=deadline  on  kernel  boot   Configure  IO   Scheduler   • #  echo  100000  >  /sys/block/sdX/queue/nr_requests   Queue  length   (especially  MyISAM)   • Virtually  no  overhead  when  not  in  snapshot  mode   • Reserve  some  space  for  snapshots  Consider  using  LVM   22  
  • 23.           Which  one  do  you  use  ?     FILESYSTEMS   23  
  • 24. Filesystems   XFS  –  “Old”  High  Performance  Favorite   EXT4  –  Works  very  good  for  some  workloads   Avoid:   • Ext2   • Ext3   • ReiserFS   • ZFS  (may  be  good  for  development)     • Btrfs   24  
  • 25. FS  Tuning   rela@me  (noa@me)   ext3:  tune2fs  –O  dir_index  -­‐c  –l  –i  0  –e  remount-­‐ro   xfs:  nobarrier     • Assuming  RAID  w  BBU  or  Flash   25  
  • 26. WHAT  MYSQL  VARIANT  ARE  YOU   RUNING  ?                       26  
  • 27. Main  Choices   MySQL     Percona  Server   MariaDB   27  
  • 28. MySQL  Versions   Newer  versions  scale  beuer   MySQL  5.7  is  most  scalable   Percona  Server  5.7  brings  even  more  improvements  J   Use  5.7  for  New  Development   Upgrade  to  MySQL  5.7  if  you  need  it  now   28  
  • 29. Check  out  Percona  XtraDB  Cluster   Based  on  Galera  Technology   Innodb  Storage  Engine  you  already  know   Synchronous  Replica@on   Parallel  Apply   Automa@c  Provisioning   No  Stale  Reads   Not  for  all  workloads   29  
  • 30. How  to  Install   • hup://dev.mysql.com/downloads/repo/   • hup://www.percona.com/doc/percona-­‐server/5.7/[email protected]   Use  Repositories:   Best   • Need  older  Version    Download  RPM/DEB   • Good  for  tes@ng  with  MySQL  Sandbox  Use  Tar.gz  package   • hups://hub.docker.com/_/percona/  Docker  Images   • Do  you  really  have  good  reason  to  do  it  ?   • Many  problems  are  caused  by  bad  builds  Build  our  own   30  
  • 31. MySQL  Configura8on   • Even  newer  MySQL  5.7  defaults   are  unlikely  to  be  op@mal   You  need  to  tune  MySQL   configura@on   • hup://bit.ly/1fuP0SZ   Check  out  presenta@on   which  goes  in  depth  into   configura@on  tuning   • Avoid  obsessive  tuning  disorder   Typically  getng  5   variables  right   responsible  for  90%   performance  gain   31  
  • 32. MySQL  Variables   • How  many  connec@ons   server  will  support  ?   max_connec@ons   • How  many  “open”  tables   there  will  be  allowed   table_open_cache   • How  many  files  can  be  open    open_files_limit   32  
  • 33. Top  Variables   •  Set  80%  of  memory  some@mes  more  Innodb_buffer_pool_size   •  Best  setng  in  most  cases  Innodb_flush_method=O_DIRECT   •  Set  256MB  or  more     •  Larger  logs  =  longer  recovery  @me   Innodb_log_file_size   •  Truly  ACID:  1     •  Can  Afford  Data  Loss:  2   Innodb_flush_log_at_trx_commit=?   33  
  • 34. Advanced  Ideas   • taskset  -­‐pc  0,12,2,14  `cat  /var/ lib/mysql/mysqld1.pid`     Running  mul@ple   MySQL  instances  ?   • Jemalloc     • Tcmalloc  –old  favorite   Memory  Alloca@on   Hostspot  ?   • Roll  back  easily  if  things  go   wrong   LVM  Snapshot   before  maintenance   or  upgrade   34  
  • 35. Beware  of  the  “Scripts”   • Timeouts  might  be   not  enough  for  safe   database  shutdown   • The  automated   upgrade/check     Start/ Stop   Scripts   can  be   nasty   35  
  • 36. Automa8on   Manual  approach  is  a   no   • Does  not  Scale   • And  is  Error  Prone   Automate  installa@on,   upgrades,   configura@on   • Puppet,     • Chef     • Ansible     Keep  Configura@on   under  version  control   • At  very  least  leave   comments  on  what   you  chance  and  why   36  
  • 37. Monitoring  and  Trending   •  Just  make  sure  you’re  doing  it   Many  tools  to  choose   from!   •  Check  out  PMP   •  hup://www.percona.com/soIware/percona-­‐monitoring-­‐ plugins   Nagios  and  CACTI   •  hup://grafana.org/   Grafana  –  new   genera@on  trending   •  hup://bit.ly/1M6r7Vk   Check  out  Grafana  +   Prometheus  Monitoring   37  
  • 38. Prometheus  +  Grafana  Example   38  
  • 39. Linux  OOM  Killer   • SSH   • MySQL  Server   • Various  jobs   • Backup     • Percona  Toolkit     • Background  Batch  jobs   What  are   your   priori@es  ?   • echo  -­‐17  >  /proc/2592/oom_adj   • do  not  kill  ever   • echo  10  >  /proc/2592/oom_adj       • More  like    to  be  killed   Configuring   39  
  • 40. Tools  you  need  to  know   General  Linux   • Top   • Vmstat   • Iostat   • Strace   • Gdb   • perf   MySQL   • Percona  Toolkit   • Innotop   • Percona  Xtrabackup   • MyDumper   40  
  • 41. Resources  for  MySQL  on  Linux   •  Brendan  Gregg’s  web  site   – hup://www.brendangregg.com/   •  Percona’s  Blog   – hup://www.percona.com/blog/   •  Ernie  Souhrada  IOPS  inves@ga@on   – bit.ly/2546xes   41  
  • 42. www.percona.com       Percona  Live   Data  Performance  Conference   •  April  18-­‐21  in  Santa  Clara,  CA  at  the  Santa  Clara   Conven@on  Center   •  Register  with  code  “GWO”  to  receive  15%  off  at   registra@on   •  MySQL,  NoSQL,  Data  in  the  Cloud     www.perconalive.com  
  • 43. 43   Thank You! Peter  Zaitsev   [email protected]   @PeterZaitsev     bit.ly/PerconaJobs