Databases Reference
In-Depth Information
types of workload that MySQL generates, because it stalls some requests in the queue
needlessly.
You can see which schedulers are available, and which one is active, with the following
command:
$ cat /sys/block/ sda /queue/scheduler
noop deadline [cfq]
You should replace sda with the device name of the disk you're interested in. In our
example, the square brackets indicate which scheduler is in use for this device. The
other two choices are suitable for server-class hardware, and in most cases they work
about equally well. The noop scheduler is appropriate for devices that do their own
scheduling behind the scenes, such as hardware RAID controllers and SANs, and dead
line is fine both for RAID controllers and disks that are directly attached. Our bench-
marks show very little difference between these two. The main thing is to use anything
but cfq , which can cause severe performance problems.
Take this advice with a grain of salt, though, because the disk schedulers actually come
in many variations in different kernels, and there is no indication of that in their names.
Threading
MySQL uses one thread per connection, plus housekeeping threads, special-purpose
threads, and any threads the storage engine creates. In MySQL 5.5, a thread pool plugin
is available from Oracle, but it's not yet clear how beneficial this is in the real world.
Either way, MySQL requires efficient support for a large number of threads. It really
needs support for kernel-level threads, as opposed to userland threads, so it can use
multiple CPUs efficiently. It also needs efficient synchronization primitives, such as
mutexes. The operating system's threading libraries must provide all of these.
GNU/Linux offers two thread libraries: LinuxThreads and the newer Native POSIX
Threads Library (NPTL). LinuxThreads is still used in some cases, but modern distri-
butions have made the switch to NPTL, and most don't ship LinuxThreads at all any-
more. NPTL is lighter and more efficient, and it doesn't suffer from a lot of the problems
LinuxThreads had.
FreeBSD also ships a number of threading libraries. Historically it had weak support
for threading, but it has gotten a lot better, and in some tests it even outperforms GNU/
Linux on SMP systems. In FreeBSD 6 and newer, the recommended threading library
is libthr ; earlier versions should use linuxthreads , which is a FreeBSD port of GNU/
Linux's LinuxThreads.
In general, threading problems are a thing of the past, now that GNU/Linux and
FreeBSD have gotten good libraries.
 
Search WWH ::




Custom Search