Testing Redis 2.0.0 Release Canidate with Perl

I’m pretty excited about the upcoming 2.0.0 release of Redis. As you can see in the changelog, I made a few minor contributions to this release. I’m most excited about being able to perform unions and intersections with sorted sets (ZSETs) and the new HASH data structure, not to mention the memory footprint reduction. Once it tests out well, I’m hoping to upgrade our Redis clusters at Craigslist to the 2.0 code base.

To do that I needed to upgrade our Perl client. The current client on CPAN doesn’t know about the protocol changes to allow for binary-safe key names in all commands. But the multi-bulk branch on github has that code. So I merged it into my fork (creating a multi-bulk branch of my own) and adjusted the tests so that all tests pass when running make test. It’s just a few minor fixes but I feel better about not seeing failed tests.

Yay for Github and Open Source.

Now it’s time to build some new RPMs, install, and test our in our development environment.

Posted in craigslist, nosql, programming | 1 Comment

Some Recipes I’d Like To Try This Summer

One of the great things about learning to cook is the plethora of good recipe web sites you can find. And while the recipes aren’t necessarily as good or in-depth as some cookbooks, they do have the benefits of user ratings, comments, and suggestions. Some of the better ones even have RSS feeds, so they’re easy to follow in Google Reader.

Here are a few I’m hoping to try out this Summer:

Added to that is the fact that Kathleen called me a few days ago with the names of four new cookbooks to add to the Amazon wishlist. I guess there will be no reason not to use all our kitchen toys this season!

If I can remember to, I’ll try to come back to this post and update it with a few other recipe links I’ve come across and would love to try.

Oh, that reminds me… I should post pictures of our “garden” soon. We have lots of peppers, tomato plants, herbs, and more.

Posted in cooking | 2 Comments

The Dumb and The Smart of the Internet Age

In two competing but somewhat orthogonal essays in The Wall Street  Journal, Clay Shirky and Nicholas Carr ostensibly argue opposite sides of the Internet’s effects on society. In Does the Internet Make You Smarter? Shirky tries to put the Internet in the larger historical context of the commoditization of media creation and dissemination tools. Carr, in Does The Internet Make You Dumber? focuses on the effects of the ever-present on-line distractions on our ability to read, comprehend, focus, and think deeply about issues.

Both are definitely worth a read. I’ve long admired the writings of Clay and Nick, even though I don’t always agree with them. But in the end, I find that I agree with both of them. They’re both right. As time goes on, we’ll certainly look back over the last 5-10 years as a turning point in self-publishing and self-expression in the (on-line) public sphere. It’s the latest point along the ever growing arc of societal changes brought about by new technology. Shirky paints that picture well.

But Carr makes some very good points as well. We’re still learning how to deal with this new medium and the perils of mindlessly letting it control (or at least over-influence) our thinking and behavior. I still remember when people referred to television as the “boob tube” and talked of it rotting our brains. They, too, were right to be concerned. But ultimately we, the individuals, are still in control. It is our responsibility to recognize that and assert that control.

If you haven’t read their essays, do yourself a favor. Both are thought provoking. If nothing else, see if you agree with one or both of them… or neither!

Posted in tech | 2 Comments

MongoDB Early Impressions

I’ve been doing some prototyping work to see how suitable MongoDB is for replacing a small (in number, not size) cluster of MySQL servers. The motivation for looking at MongoDB in this role is that we need a flexible and reliable document store that can handle sharding, a small but predictable write volume (1.5 – 2.0 million new documents daily), light indexing, and map/reduce operations for heavier batch queries. Queries to fetch individual documents aren’t that common–let’s say 100/sec in aggregate at peak times.

What I’ve done so far is to create a set of Perl libraries that abstract away the data I need to store and provide a “backend” interface to which I can plug in a number of modules for talking to different data stores (including some “dummy” ones for testing and debugging). This has helped to clarify some assumptions and change a few of my early design ideas. As you may remember from I Want a New Data Store, I’m interested in trying a few options.

Then I created another set of modules that can read the existing data from the MySQL tables, joining as necessary, and normalizing some field names as well as removing “empty” fields. (I’ve decided that it’s silly to store “NULL” values in MongoDB, since we still have to store the key even when there’s no value.) That code has allowed me to do some performance testing and, more importantly, sizing tests. I know have a pretty reliable estimate of our storage needs, assuming the data I’ve pulled so far is representative of the future. It looks something like this:

 1GB = ~       300,000 items  (0.3M)
 10GB = ~     3,000,000 items    (3M)
100GB = ~    30,000,000 items   (30M)
  1TB = ~   300,000,000 items  (300M)
 10TB = ~ 3,000,000,000 items    (3B)

This gives me a good way to judge how much space and how many machines we’ll end up needing.

Performance has be very good so far. The bottleneck is clearly getting the data out of MySQL. Because of the scattered nature of the content in the existing system, and the number of queries and joins required, it’s possible to pull at most 50-100 documents per second. Given that we have nearly a billion documents to migrate, it’ll take some time (and a few TB of space). I definitely plan to distribute that work and take advantage of there being multiple copies of the data around.

Programming against MongoDB is not hard at all. The MongoDB Perl modules are great. It’s really just a matter of wrapping your head around the API and getting used to the JavaScript console instead of the MySQL shell. The server’s http interface is handy for a quick idea of what’s going on, though we’ve hardly stressed this instance so far.

Limitations

There are two limitations (or missing feautres) that I’ve encountered so far in MongoDB. The first is a lack of compression. For this particular data set, I’m reasonably confident that both gzip and lzo could easily get somewhere from 3:1 or 5:1 compression. That could mean a substantial space savings (several TB of disk) at a very small CPU cost (and modern CPUs are very fast). The state of compressed file systems in Linux is sad, so the only real hope in the short or medium term is likely MongoDB object compression as requested in SERVER-164, which I have voted for and commented upon.

The second issue I’ve encountered is the 4MB object size limit. SERVER-431 discusses this a bit and I’d love to see some more discussion and voting there. My motivation for this is to allow for sequential reads of larger objects (think of them as something like covering indexes from the relational world) so that they don’t need to be chunked up (think GridFS) and force me to incur disk seeks when retrieving them. Amusingly, I was hoping to store lists (or arrays) in some documents using the $push operator when I ran into this. It didn’t take long to also find SERVER-654 and realize that I wasn’t the only one.

My ultimate wish for the 4MB limit would be a configurable limit so that the DBA or programmer can choose what’s right for their dataset. In my case, I went back and did some more analysis to see how many records would be affected. It turns out that it was a very small percentage of the total data. But the outliers do exist and since there’s a limit, I’d have to work around it anyway. That’s still code I need to write, test, and support. This caused me to think about the problem a little differently and consider other solutions too.

What’s Next

I need to do a bit more work on the storage side and some more testing. The next major piece of this system is an indexing piece that may not end up living inside of MongoDB. I’ll write more about that later, but my current thinking is to use Sphinx (which we already know and love).  This may give me an excuse to play with two new Sphinx features I’ve been itching to try: string attributes and real-time indexing (via the MySQL protocol).

The next MongoDB piece I want to play with is sharding and replication. I’m hoping to get a feel for the strengths and weaknesses, as well as figuring out the right deployment strategy for us if we end up using MongoDB. Thankfully, our new development environment just got setup last week and there’s enough hardware that I can experiment with different topologies to see how it’ll work out.

I’ll write more about both the Sphinx and MongoDB experimentation as it progresses.

Posted in craigslist, mysql, nosql, programming, tech | 7 Comments

Ubuntu 10.4 Impressions

I’ve upgraded two desktop computers to the 64bit release of Ubuntu 10.4 in the last week. One was a fresh install (my desktop at the office, a Dell Optiplex 755) and the other was an in-place upgrade (my desktop at home, a Dell Optiplex 760 with dual monitors). Aside from the new color scheme (yuck), I’m pretty happy with 10.4. So far nothing has broken, crashed, or regressed in any way that I’ve noticed. I was able to easily drop the latest versions of VirtualBox and Google Chrome (the only 3rd party packages I really use) without issue. The most noticeable change so far has to be the boot speed. Both machines go from hitting the Enter key at the Grub menu to a usable desktop in a remarkably short amount of time.

The irony is that since these are Linux desktops, I really don’t reboot them that often. But this means that when I have the confidence to upgrade my laptop, which I do reboot more often, things will definitely feel better. And that also applies to any 10.4 virtual machines I run too. The most interesting question is whether I can get away with all 64bit installs. This is 2010, after all, so I’d like to make use of all this memory. But the VPN client at work has been the limiting factor so far. Thankfully there appears to be a solution on the horizon for that.

I’ve been running the Ubuntu Netbook Remix on my Samsung NC10, so I’m curious to try the Ubuntu 10.4 Netbook Edition on it soon as well. Anyone tried it?

Posted in tech | 6 Comments

The Craigslist Blog

A lot of people don’t seem to realize that there’s an official craigslist blog where you can find responses to the various folks attacking or criticizing us in the media–often without conducting basic background research. Some people thing that craigslist is “killing newspapers” but the hack writing jobs published by some of them certainly can’t be helping their future either.

That aside, the blog is a good place to look for our side of the story. Jim has been doing a great job of responding to some of the more outrageous critics and giving some useful background information what we’ve done over the years. It’s sad but hardly surprising that the so-called journalists (yes, the sames ones who don’t do the basic research) don’t bother to mention or *gasp* link to the blog in their pieces.

Oh, well. This is hardly the first time we’ve seen Old Media resisting change.

Posted in craigslist | Leave a comment

I Want a New Data Store

While there is a dizzying array of technologies that have the “NoSQL” label applied to them, I’m looking for one to replace a MySQL cluster. This particular cluster has roughly a billion records in it, uses a few TB of disk space, and is growing all the time. It is currently a MySQL master with several slaves and handles a fairly light query volume. The reasons we’d like to change it are:

  • ALTER TABLE takes an unreasonably long time, so we can’t add or removed indexes or columns. Changes take over a month.
  • The data footprint is large enough that it requires RAID and we seem to be really good at breaking RAID controllers.
  • Queries are not very efficient, due partly to the underlying data organization, and due partly to the sheer amount of it compared to the available RAM.
  • The data really isn’t relational anymore, so a document store is more appropriate.  It’s just that when it was set up, MySQL was the tool of choice for just about all data storage.

I’ve spent some time looking around at several options, including MongoDB, CouchDB, and Cassandra. And I like aspects of all of them. If I could pick and choose features from all of them, here’s what it might look like:

  • The high-level abstractions provided by CouchDB and MongoDB. Cassandra makes you think more about low-level details and performance (which can be good).
  • The performance of Cassandra. By all accounts it is very fast and got faster in the 0.60 release.
  • A clear understanding of the performance and storage tradeoffs in various schema/indexing designs.
  • The “no single point of failure” and multi-machine replication and sharding features of Cassandra. They’re VERY compelling. CouchDB Lounge is a step in the right direction, but I’d rather see it as part of the core system.
  • Map/Reduce support for ad-doc data analysis and queries.
  • Persistent indexes to speed our most common queries. Cassandra’s feels very “roll your own”, which is consistent with the lower-level nature of Cassandra. CouchDB’s “all views, all the time” feels a bit odd too. MongoDB seems to get this right, providing traditional indexes and support for more ad-hoc operations similar to CouchDB.
  • The documentation of MongoDB. CouchDB is pretty good and there are books available. Cassandra’s docs require a bit more trial and error on the part of the developer as things change with each release.
  • A corporate entity that can provide support, consulting, and possibly custom development. Both CouchDB and MongoDB have this. Cassandra is more a community project, though the bulk of contributions come from developers employed by tech companies–none of them appear to be in the business of doing Cassandra.
  • I’d love to be able to influence the organization of records on disk so that the most common queries will require very few seeks. I’d like to cluster around a particular key that may not be the primary key. I can see ways to do this with Cassandra. I’m not sure about the low-level details of MongoDB or CouchDB.
  • I’d love native compression for large text fields. A substantial portion of our data in this cluster is text.
  • Full-Text indexing would be a nice to have. We’re pretty good with Sphinx already, but having reasonable full-text indexing integrated would simplify things.
  • A good Perl API.

Given all that, what else should I be looking at? What misconceptions do I have? What’s your experience been with any or all of them?

Posted in craigslist, mysql, nosql | 81 Comments

What NOT to focus on for on-line success…

This morning I came across a presentation by Drew Houston (CEO of Dropbox) called Dropbox Startup Lessons Learned. On slide #24 I noticed a list of things they did poorly or didn’t do at all:

  • hiring non-engineers
  • mainstream PR
  • traditional messgaing/positioning
  • deadlines, process, “best practices”
  • having a “real” website
  • partnerships/bizdev
  • having lots of features

After reading that, I realized that Dropbox and Craigslist have a lot in common. We have a very small team and hire engineers carefully. We don’t do a lot of mainstream PR, marketing, positioning, etc. Our development isn’t deadline oriented and we don’t have the flashiest web site around. It’s more of utility over appearance for us. And we don’t have any sales or bizdev people. Like Dropbox, word of mouth is what really made Craigslist successful.

I really wish more companies put these things lower on their priority list–especially larger companies that have begun to suck (or have been sucking for quite some time). Once you do, you start to realize that what your users ultimately care about is having a great product that does what they need and doesn’t get in their way. If it’s great, they’ll tell others and get you more business as a byproduct.

What companies have you seen that follow this model?

Posted in craigslist | 4 Comments

MySQL 5.5.4 is Very Exciting

Yesterday at the MySQL Conference, I spent time in a few sessions discussing the performance enhancements in the MySQL 5.5.3 and 5.5.4 milestone releases. What I saw made me very, very happy. In fact, the timing couldn’t be better. We’re just starting a migration to some new database hardware at work, going from some dual processor, dual core AMD boxes with truly horrible hardware RAID and 32GB RAM setups to machines with 8 and 16 CPU cores, 72GB RAM, and blindingly fast Fusion-io solid state disks (SSDs).

It seems that in the MySQL 5.5.4 release, several performance bottlenecks that really affected scalability beyond 4 cores have been either eliminated or seriously mitigated. Some of the changes were in MySQL itself, while others are InnoDB specific.

  • Multiple Rollback Segments mean the 1,024 concurrent transaction limit goes away and concurrent transactions will have less mutex (lock) contention.
  • Removing MySQL’s LOCK_open mutex (lock) and replacing it with a  Metadata Locking (MDL) Framework eliminates a very large bottleneck when going beyond 4 CPU cores in even read-only benchmarks.
  • InnoDB Recovery is WAY FASTER in this release.  This is the result of some small but important changes to the algorithms used when dealing with the redo log and replaying transactions. At least one O(n*n) operation has become O(n log n) and other optimizations have contributed to an order of magnitude improvement in recovery time.
  • There is now a DELETE buffer inside of InnoDB that should help with workloads that involve some large DELETE runs. I’m optimistic that this may apply to a particularly hairy problem we run into with slave lag during such runs.
  • Split Buffer Pools allow you to squeeze another 30% or so out of InnoDB in workloads that would otherwise bottleneck on the kernel mutex (lock) inside of InnoDB. This means you can tell InnoDB to create N buffer pools instead of a single monolithic one and it will then use a simple hash function to spread pages across the buffer pools. In the future that simple hash function may be something that DBAs can tune. Imagine being able to have a buffer pool per table, or at least being able to isolate certain tables into their own buffer pools. This is roughly similar to having multiple key caches in the MyISAM world.
  • The InnoDB Performance Schema provides a lot more visibility about what’s going on inside of InnoDB.
  • There are numerous improvements to MySQL replication durability that make it less likely to encounter problems when a slave crashes and comes back online.

There is a full list of changes to MySQL 5.5 available on-line. I haven’t yet found documentation for the full changes in the InnoDB plugin 1.1 but I’m sure that will appear soon (or someone will correct me).

The benchmarks presented that compared MySQL 5.5.4 with 5.1 show substantial improvements in a variety of workloads. And given how many shops are still running MySQL 5.0.xx in production (including us), that means there really is A LOT to look forward too–especially on newer hardware.

I, for one, cannot wait to see what this stuff does for us.

Thanks to the MySQL and InnoDB teams for their continued hard work and dedication to making MySQL faster as hardware evolves.

Posted in programming | 29 Comments

Emacs and Perl cperl-mode Color Syntax weirdness after Ubuntu Upgrade

For a quite some time now I’ve been happily using Ubuntu on my desktop and the emacs-snapshot-gtk package of GNU Emacs to get good fonts and a recent Emacs. I edit a lot of Perl code and use cperl-mode to do so (as I have for years). However, recently I’ve noticed the color syntax highlighting to be rather buggy. At seemingly random times it’s loses the colors for a fairly large chunk of code. Other times it just messes up a few lines.

I try to flip font-lock-mode off and back on but the problem persists. It’s become annoying enough that it’s a real distraction. At times the colors flip on and off with every other keystroke, as if the matching engine has become a state machine which every other state disables highlighting. It’s rather odd considering how I’ve used GNU Emacs and cperl-mode flawlessly for many years now.

All the while, indentation and paren/brace/bracket matching seem to work just fine.

Anyone seen this? I’ve done some searching but haven’t turned up anything concrete. It seems to have become an issue when I started upgrading my computers from Ubuntu 9.04 to 9.10. Does this ring a bell for anyone else?

Posted in programming | 3 Comments