MySQL UC 2007: Innodb Performance Optimization
MySQL UC 2007: Innodb Performance Optimization
Optimization
M utex:&kernel_m utex
M odule:srv0srv.c
C ount:1828074122
Spin_w aits:762647
Spin_rounds:4781433
O S_w aits:96879
O S_yields:155883
O S_w aits_tim e:0
Hardware and OS Selection
Hardware and OS Selection Checklist
Which CPUs and how many of them ?
How Much Memory ?
How to set up IO Subsystem ?
Does OS Selection matter ?
Which File System is best to use ?
Selecting CPUs
Different CPUs/Architectures scale differently with InnoDB
Old “NetBurst” based Xeons scale poorly
New “Core” based Xeons and Opterons are better
X86_64 is the leading
Multi-Core works well with InnoDB
Over 8 cores per system is reasonable limit
Depends on workload significantly
Innobase is working on further improvements
Scale Out, use multiple lower end servers.
32bit CPUs should be dead by now, so 32bit OS
How much memory ?
Memory is most frequent performance limiting factor for well
tuned applications
InnoDB can use large memory amounts efficiently
Working set must fit in memory
The data pages which are accessed most often
Do not count by rows:
100,000,000 of 100 byte rows, random 1,000,000 are working
set – can touch most of the pages.
Can be 5% of total database size or can be 50%
Make sure to use a 64bit platform, OS and MySQL Version.
How to set up IO SubSystem
InnoDB loads a few hard drives well, but not 100 of them
6-8 per node seems to be optimal configuration
Directly Attached storage usually works best
SAN – increased latency, expensive
NAS – Avoid, risk of data corruption
ISCSI – good for some cases, increased latency
RAID – Battery backed up cache is very important
Make sure you have BBU before enabling WriteBack cache
Hard Drive cache itself should be turned off, or make sure it
is flushed on fsync() or corruption can happen in OS crash.
Local storage configuration
Logs on separate RAID1 volume
Can be helpful, in many cases better to share disk for data
Binary logs on separate volume – can be good idea for
backup recovery reasons
RAID10 good for tablespace
degraded performance can be worse than expected.
RAID5 can be good for certain workloads
just make sure you account for degraded performance.
Large RAID Stripe (128K+) is best in theory but many RAID
controllers do not handle these well.
Software RAID is OK, especially RAID1
Does OS Selection Matter ?
Consider Performance, Tools available, Community
Experience
Windows – used for development, small installations, few
Web/Enterprise scale projects
Solaris – offering some great tools now, works to make
MySQL work well with it, bad community support.
FreeBSD – had history of problems with MySQL in general,
now gets better, fewer tools available, less usage in
production.
Linux – Most commonly used platform for production and
Development. Tools like LVM, Journaling filesystems.
Selecting FileSystem
Applies mainly to Linux which has too many choices
EXT3 – default filesystem in most distributions, works OK
for lower end installations
ReiserFS – support removed from many Linux distributions.
Generally no big win with typical MySQL workload
XFS – Used with a lot of drives in RAID, can give serious
performance improvement
JFS – Rarely used at this point.
Raw partition for InnoDB tablespace – rarely used.
There are often too high expectations about performance
gains by switching file systems.
Recent InnoDB Performance Developments
InnoDB Scalability Patches
Decreased contention over buffer pool pages
Available in 5.0, backported to 4.1
Improved sync_array implementation in MySQL 5.1
Performance gains are very different based on
workload,hardware, concurrency
Can range from few percent to multiple times
Performance still goes down with high number of concurrent
threads.
Prototype for further scalability improvement patches is
available from community
Other Improvements
Row Level replication in MySQL 5.1 eases gap locking
Working on removing Auto_increment “table locks”
Zip compression of database pages
Fast index creation
- No full table rebuild required
- “Sorting” gives less physically fragmented index
Questions from the audience
[email protected]
Visit blog for more Innodb tips
http://www.mysqlperformanceblog.com
Looking for some help ?
[email protected]