October 26th, 2008 by admin
I attended the MySQL EMEA conference last thursday where I enjoyed a talk from Ivan Zoratti titled “Scaling Up, Scaling Out, Virtualization - What should you do with MySQL?”
They have changed their minds quite a bit. Virtualisation in production is no longer a solid no-no according to them (a lot of people would argue). Solaris containers, anyone?
As most of us know by now, MySQL struggles to utilise multiple cores efficiently. This has been the case for quite some time by now, and people like Google and Percona has grown tired of waiting for MySQL to fix it.
Sun decided to not go down the route of reviewing and accepting the patches, but are now suggesting - are you sitting down? - running multiple instances on the same hardware.
I’m not against this from a technical point of view as it currently actually does improve performance on multiple-core-multiple-disk systems (for an unpatched version) for some workloads, but the fact that they have gone to openly and officially suggest workarounds to their own problem rather than fixing the source of the problem is disturbing.
Granted, I suppose it makes sense to suggest larger boxes if you’ve been bought by a big-iron manufacturer. Also, I should be fair and note that Ivan at least didn’t say scaling out was a negative thing and that it’s still a good option.
If anyone asks me though, I think I’ll keep scaling outwards and use the more sensible version of MySQL
Posted in MySQL | 2 Comments »
October 5th, 2008 by admin
If you, like me, often work in a lot of terminals on a lot of servers, or even a lot of terminals on the same one, you may recognise the frustration of a lost bash history.
I don’t always gracefully log out of my sessions, so every so often my ~/.bash_history isn’t written and all my flashy commands are lost (the history buffer is only committed when you log out, everything that you see in `history` is not actually written to disk). I quite often find myself rewriting the same one-liners or long option list just because I closed my konsole or SecureCRT window without first logging out of all the sessions properly.
So I put some effort into finding a solution to this, and whilst reading through the bash manpage, I saw PROMPT_COMMAND. *pling*
export PROMPT_COMMAND='history -a'
To quote the manpage: “If set, the value is executed as a command prior to issuing each primary prompt.”
So every time my command has finished, it appends the unwritten history item to ~/.bash_history before displaying the prompt (only $PS1) again.
So after putting that line in /etc/bashrc I don’t have to find myself reinventing wheels or lose valuable seconds re-typing stuff just because I was lazy with my terminals.
This is one of those things that I should have done ages ago, but never took the time to.
Posted in Sundry sysadmin | No Comments »
September 15th, 2008 by admin
Varnish has been able to provide caching for more than one backend for quite some time. The achilles heel with this has up until now been that it hasn’t been able to determine whether a backend is healthy or not. This is now a problem of the past! The backend health polling code is available in 2.0 beta1 Sadly it had a bug, so when using the ‘random’ director, it was unable to use the remaining healthy backend if all but one went MIA. I reported this bug and it was fixed in changeset r3174.
So as of now, you can safely use one varnish instance for several front-ends, thus eliminate double-caching (memory waste, unnecessary load on back-ends), reduce network traffic, do rudimentary load balancing, ease management etc.
With the obscene amount of traffic Varnish can push without putting a fairly basic system under any load worth mentioning, you can use a single front-end to serve several nodes in most setups.
Here’s an elementary sample VCL for how to do this:
backend node0 {
.host = "127.0.0.1";
.port = "80";
.probe = {
.url = "/";
.timeout = 50 ms;
.interval = 1s;
.window = 10;
.threshold = 8;
}
}
backend node1 {
.host = "10.0.0.2";
.port = "80";
.probe = {
# .url = "/";
.timeout = 100 ms;
.interval = 1s;
.window = 10;
.threshold = 8;
.request =
"GET /healthcheck.php HTTP/1.1"
"Host: 10.0.0.2"
"Connection: close"
"Accept-Encoding: foo/bar" ;
}
}
director cl1 random {
{ .backend = node0; .weight = 1; }
{ .backend = node1; .weight = 1; }
}
#director cl1 round-robin {
# { .backend = node1; }
# { .backend = node0; }
#}
sub vcl_recv {
set req.backend = cl1;
}
As you can see I’m defining the backends slightly differently. You need to define one of .url or .request, but not both for obvious reasons. If you go for the slighly simpler .url the default request looks like this:
GET / HTTP/1.1
Host: something
Connection: close
If this does not suit your need, comment out .url and use .request to roll your own. This aspect of Varnish is actually quite well documented, so I won’t repeat what’s on the trac page.
There is clearly a lot more you can and, more often than not, should do in the VCL than the above. This is a stripped down version which only pertains to the backend polling functionality.
Posted in Webservers, misc | No Comments »
September 4th, 2008 by admin
There are some good stuff on the horizon! It’s called btrfs (”butter-fs”). It was originally announced/”released” over a year ago by our friends at Oracle and has, in my opinion, not quite received the attention it deserves. I’m keeping a close eye on the very intensive devlopment of this as the feature list is very interesting from several aspects. It’s got some of the big names behind it and will undoubtedly be widely deployed and accepted into the vanilla kernel once stable.
btrfs, like ZFS, implements copy-on-write model, so yes - it will be able to do snapshots! Writeable ones at that. In fact, it’s got the ability to do snapshots of snapshots! Quasi-MVC filesystem!
COW unfortunately makes a filesystem more prone to fragmentation, but luckily btrfs comes with online defragmentation and fs check abilities. The speed of read and write operations will obviously be impaired during such operations, but there’s always ways around that in most performance sensitive setups! If not, there should be!
Sadly, COW isn’t that good of a choice for database workloads. But fret not, COW can be disabled with a mount option (-o nodatacow). This doesn’t mean you will lose the snapshot ability, as btrfs ignores this option if a data extent is referenced by more than one snapshot, so COW will, as far as I understand, be enabled from that you initiate a snapshot and stay that way until you’re done with it.
Early benchmarks show that btrfs is extremely fast at writing, and a little poorer at reading. It will be interesting to see how these numbers change as development proceeds. If added features will have any negative impact on performance. As a side note - I was quite surprised to see the poor numbers for ext3 in these benchmarks!
So if you’re a DBA and your data fits in memory, this filesystem will be right up your alley. With a reasonable amount of tables and some proper values for innodb_open_files and table_cache, I wouldn’t expect any remarkable difference in day-to-day database operation since the real bottleneck usually is in the hardware.
This is generally speaking of course. I’m sure there are workloads out there which will benefit a lot more than “the norm”. Likewise, people with awkward read heavy setups with a lot of data in a lot of files may probably be better off not using btrfs.
If you, like myself, often use blinks of an eye as a unit, you know what I’m talking about.
Yet another interesting functionality built in is the multiple device support. I will not call it a substitute for proper hardware based RAID, but could well be one for LVM (bearing the snapshots in mind as well)!
Another thing worth keeping an eye on is a related project; CRFS which may turn out to be a worthy NFS replacement. While it’s planned to get failover capabilities, I would much rather have seen a client-agnostic MogileFS- style implementation.
Sadly, they are not production ready yet. By far. But it’s something to look forward to. I’ll give it a version or two until I will put it under the microscope further and chuck some real world load onto it. Can’t wait!
Posted in Sundry sysadmin, misc | 1 Comment »
August 26th, 2008 by admin
A nifty tool which might be handy when getting to know a system or tracking down I/O usage is inotify-tools . It’s a lightweight interface to the kernel’s inotify function. It gives a quick overview over which files are accessed and how in any given directory and it’s subdirectories (if asked to).
It can quickly give an overview of efficiency of caching, frequency of commits, and all sorts of useful information for a whole range of applications.
Here’s some example output from the inotifywatch utility during a mysqlslap run:
# inotifywatch /var/lib/mysql/mysqlslap/*
Establishing watches...
Finished establishing watches, now collecting statistics.
total access modify close_write close_nowrite open delete_self filename
728 450 274 1 0 1 1 /var/lib/mysql/mysqlslap/t1.MYD
241 0 238 1 0 0 1 /var/lib/mysql/mysqlslap/t1.MYI
5 1 0 0 1 1 1 /var/lib/mysql/mysqlslap/t1.frm
2 0 0 0 0 0 1 /var/lib/mysql/mysqlslap/db.opt
.
Granted - as far as MySQL is concerned - most information is accessible through SHOW GLOBAL STATUS and/or SHOW ENGINE INNODB STATUS commands. But if you for instance have an erratic fear of the key_read_requests variable, you could always look at how often your MYI files are accessed. You catch my drift..
If you’re only interested in certain file operations, you can apply filters. If you for instance only have interest in file writes, your run would look like this:
# inotifywatch -e modify -e delete_self /var/lib/mysql/mysqlslap/*
Establishing watches...
Finished establishing watches, now collecting statistics.
total modify delete_self filename
49 47 1 /var/lib/mysql/mysqlslap/t1.MYI
44 42 1 /var/lib/mysql/mysqlslap/t1.MYD
2 0 1 /var/lib/mysql/mysqlslap/db.opt
2 0 1 /var/lib/mysql/mysqlslap/t1.frm
.
You can monitor pretty much any file operation, so this tool can be used in a whole range of scenarios. Ever wondered just how many temp files your application creates or? Are you sure it doesn’t open and close the file handle for each operation? Do you want to know which file on your website is the most popular download at the moment but can’t wait until the webstats crontab has ran? I could go on…
inotify-tools come with another utility inotifywait. This tool looks for activity on a specified file or directory and instantly tells you which operation was performed. Nothing amazing, but I can see a few areas of use for that as well, though most of them have tools for that purpose already.
Posted in misc | No Comments »