Why The Name NoSQL Is Meaningless (To Me)
The ‘NoSQL’ movement has gotten quite popular lately and with good reason, it is breaking new ground on distributed, scalable storage.
But the name ‘NoSQL’ really bugs me, because SQL is just a query language, it is not a storage technology. This is well illustrated in “InnoDB is a NoSQL database”, which I will quote below:
As long as the whole world is chasing this meaningless “NoSQL” buzzword, we should recognize that InnoDB is usable as an embedded database without an SQL interface. Hence, it is as much of a NoSQL database as anything else labeled with that term. And I might add, it is fast, reliable, and extremely well-tested in the real world. How many NoSQL databases have protection against partial page writes, for example?
It so happens that you can slap an SQL front-end on it, if you want: MySQL.
Another thing, it is probably better to say what you are for rather than what you are against, much more constructive. Time to get a new name/acronym I think.
Updated December 18th, 2009 – I am seeing that NoSQL is being renamed to mean Not Only SQL, which I think is much better.
exit() Rather Than free()
I have to admit that I had a bit of a reaction to this post, apologies for quoting more than 50% of the post here but here goes:
See, developers are perfectionists, and their perfectionism also includes the crazy idea that all memory has to be deallocated at server shutdown, as otherwise Valgrind and other tools will complain that someone leaked memory. Developers will write expensive code in shutdown routines that will traverse every memory structure and deallocate/free() it.
Now, guess what would happen if they wouldn’t write all this expensive memory deallocation code.
Still guessing?
OS would do it for them, much much much faster, without blocking the shutdown for minutes or using excessive amounts of CPU. \o/
I am really uncomfortable with the approach of using free() for memory cleanup for the obvious reason that it is usually much, much cheaper to keep a process running than to shut it down and restart it on a regular basis. The other reason is that to rely on free() for memory cleanup is just poor hygiene.
Reminds me of the days of SunOS where common wisdom said that restarting a server once a week was a good idea to keep the memory leaks in check.
Circumvallation
I am have been reading Steve Arnold’s weblog on search, I have known Steve for over ten years now and he likes to challenge the status-quo and pushing people to see beyond the status-quo.
So it was very interesting to read his post about how Google is challenging Reed Elsevier and Thomson by indexing legal texts:
Google has added the full text of US federal cases and state cases. The coverage of the federal cases, district and appellate, is from 1924 to the present. US state cases cover 1950 to the present. Additional content will be added; for example, I have one source that suggested that the Commonwealth of Virginia Supreme Court will provide Google with CD ROMs of cases back to 1924. Google, according to this source, is talking with other sources of US legal information and may provide access to additional legal information as well.
His thesis is that the incumbents are like Vercingetorix stuck in Alesia (1) and that Google is like Ceasar who built two sets of wall around Alesia, one to keep the Gauls in, and the other to keep any relieving force out.
I like the analogy though it is not quite there, Google is not exactly laying siege and they don’t have to defend themselves. On the other hand the incumbents probably feel very much like the Gauls stuck in Alesia.
I was catching up with a long time friend earlier this week (a much smarter person than me), we were talking about lots of thing and one of those things was how particular species will move fluidly from one niche to another as they evolve. My feeling was that sometimes this happens in a fluid fashion without much struggle, but sometimes it can be quite violent resulting in the decimation of one or the other species (2). I wonder if this is closer to what is happening here. Google in moving in on an established market, though not in an explicitly deliberate fashion, and causing discomfort to the incumbents.
Now that a good portion of the data these incumbents charge for is available for free (it always was available for free, but access was difficult), it will likely force them to change their business model if they are to stay relevant. Steve makes that point very explicitly at he end of his post, for example:
Finally, what will be vulnerable to Google disruption will be difficult to use, expensive, and incomplete services. Maybe Reed Elsevier, Thomson Reuters, and Wolters Kluwer should merge. That will give the present crop of senior managers time to cash out. I don’t see an easy, quick, inexpensive, or painless way to prevent the lessons of Alesia being writ large in tomorrow’s digital headlines.
1 – I learned all about the siege of Alesia at when I was at school.
2 – For example, the introduction of Lionfish in the Caribbean is resulting in major population reduction in some indigenous species on the reefs.
InnoDB Compression
I had a few hours to spare a couple of days ago and decided to check InnoDB Plugin 1.0’s support for data compression.
In a project I work on from time to time, there is a table which contains three blobs which contains text data. To store the data efficiently I was using the COMPRESS() function in MySQL and doing a “CONVERT(UNCOMPRESS(text) AS utf8)” to uncompress the data and present it as utf8. No problems there, but with the recent move to the InnoDB Plugin 1.0 in MySQL 5.1 there was an opportunity to push that down the stack.
I ran a few benchmarks and it turned out that using 8K pages was the optimal trade-off between space and time. Using 16K pages did not compress the data very well, and using pages smaller than 8K increased the time needed to store the data. I should note that 8K is also the default.
There are some interesting wrinkles in all this, innodb_file_per_table needs to be enabled and I think the innodb_file_format needs to be set to ‘barracuda’ thought I am not sure about that.
Number Encoding II
To conclude my little foray into number encoding (see the presentation by Jeffrey Dean from Google titled “Challenges in Building Large-Scale Information Retrieval Systems” (video, slides)), here are a few conclusions:
- In terms of raw performance the “Varint Encoding” is much faster than “Byte-Aligned Variable-length Encodings” and I was able to get better numbers than Google got, most likely because I am using a different machine. It would be interesting to know what kind of machine/OS they used for their timings so I could do a direct comparison. My lookup array structure is different (and more compact) than Google’s, assuming I understood Google’s lookup array structure in the presentation.
- The “Byte-Aligned Variable-length Encodings” is faster if you are storing three numbers per posting, namely a document ID, a term position and a field ID. The “Group Varint Encoding” is faster if you are storing four number per posting, namely a document ID, a term position, a field ID and a weight.
- As I described in the last comment in the original post, two bits are used in the header for each varint to indicate its size in bytes, so 0, 1, 2 or 3 indicate whether your varint is 1, 2, 3 or 4 bytes long respectively. However if you store deltas a lot of the numbers you store will be 0, using a byte to store 0 seems wasteful to me. So I changed this so that the two bits indicate the actual number of bytes in the varint, and 0 bytes means 0. This way I don’t actually allocate space unless there is a value other than 0 to store. This saves about 10% in my overall index size, and a lot more if you only take the term postings into account because I store some amount of document metadata in my index. Of course this means that you can’t store a number greater than 16,777,216 which won’t happen unless you are creating huge indices with more than 16,777,216 documents in them or have documents longer that 16,777,216 terms.
Basically it comes down to trade-offs, index compactness vs. decode speed, and looking at speed both in test code (usually a contrived example) and performance on a real data set. I used the Wikipedia data for that along with 200 relatively complex searches designed to read lots of postings lists.
Danger Danger
Plenty has been written about the Danger data loss over the weekend (TechCrunch). For me the most interesting commentary came from John C. Dvorak, he got some things right but he also got some things wrong:
Over the past week, users of the T-Mobile Sidekick platform found that all their contacts and other important information was permanently lost, because of server mishaps. If Microsoft had wanted to throw a monkey wrench into cloud computing, it could not have done a better job.
Huh, don’t think so, this was a data loss screw-up, nothing to do with the cloud. If what we are reading is to be believed, a SAN upgrade went wrong and the data was lost, with no backup.
Insert Ellen Feiss ad here…
Seriously though backups are essential because things will go wrong. Note that I use ‘will’ and not ‘may’, and these may or may not be under our control.
The other things I used to tell clients is to do a fire drill on a regular basis, by that I mean taking the backups and making sure they can be restored properly and completely. I had one client who discovered that all their backups were useless when they checked.
Number Encoding
A while back I came across this very interesting presentation by Jeffrey Dean from Google titled “Challenges in Building Large-Scale Information Retrieval Systems” (video, slides) where he talks about the various challenges that Google ran into over time as they scaled up and how they solved them.
This abstract sets the stage pretty well
Building and operating large-scale information retrieval systems used by hundreds of millions of people around the world provides a number of interesting challenges. Designing such systems requires making complex design tradeoffs in a number of dimensions, including (a) the number of user queries that must be handled per second and the response latency to these requests, (b) the number and size of various corpora that are searched, (c) the latency and frequency with which documents are updated or added to the corpora, and (d) the quality and cost of the ranking algorithms that are used for retrieval.
In this talk I’ll discuss the evolution of Google’s hardware infrastructure and information retrieval systems and some of the design challenges that arise from ever-increasing demands in all of these dimensions. I’ll also describe how we use various pieces of distributed systems infrastructure when building these retrieval systems.
Finally, I’ll describe some future challenges and open research problems in this area.
What particularly appealed to my (gnarly) mind were the various encoding algorithms they tried to encode numbers in their index (pages 54 to 63 of the slides).
Having written a search engine I was particularly interested in how they approached that. I actually settled for what they call “Byte-Aligned Variable-length Encodings” (slide 56) ten years ago having done a bunch of benchmarking (which I repeated every few years to see how well it fared on newer generations of processors.) The encoding is very compact and does very well when you have powerful CPUs and weak IO. I did some revisions over time in the C code which drives it to steer the optimizer, but it has held up well. I used this encoding for the Feedster search engine. As an aside one of the pluses of this encoding is that it is endian independent.
So I was very interested by the “Group Varint Encoding” (slide 63) specifically the claim that the decode time was faster.
Google was able to achieve a decode speed of ~180M numbers/second for the Byte-Aligned Variable-length Encodings and ~400M numbers/second for the Group Varint Encoding.
So I set out to replicate the results and ran into some interesting things.
The machines used for this are an Intel DX58SO motherboard with a Core i7 920 CPU, 2.66GHz, 6GB of RAM, Fedora 11, gcc 4.1.1, and a Mac Pro with 2 Dual Core Xeons, 2.66GHz, 13GB of RAM, Mac OS X 10.5.8, gcc 4.2.1.
The test code is pretty simple, one test writes and reads number from the same area of memory and the second test writes and reads a sequence of numbers over 1GB of memory. I added in verification code to check that the number read was the same as the number written to simulate some in between reading the data.
My results for Byte-Aligned Variable-length Encodings were better, I was able to get ~226M numbers/second on the DX58SO and ~190M numbers/second on the Mac Pro. Removing the verification code I was able to get ~426M and ~405M numbers/second respectively.
And the results for the Group Varint Encoding were much better, I was able to get ~680M numbers/second on the DX58SO and ~500M numbers/second on the Mac Pro. Removing the verification code made reading pretty much instantaneous (less than 1 microsecond to read 4.8B numbers.)
UPDATED October 9th, 2009 – Obviously my own BS meter was off when I wrote that last paragraphs, as I point out in the comments, the optimizer was doing away with most of the code because the results were not used. Preventing it from doing that gave me the same results as the ones I got with the verification code in place and was certainly not instantaneous.
CloudCamp Boston – July 29th, 2009
CloudCamp Boston will be held on July 29th, 2009.
From the conference web site:
CloudCamp is an unconference where early adopters of Cloud Computing technologies exchange ideas. With the rapid change occurring in the industry, we need a place we can meet to share our experiences, challenges and solutions. At CloudCamp, you are encouraged you to share your thoughts in several open discussions, as we strive for the advancement of Cloud Computing. End users, IT professionals and vendors are all encouraged to participate.
I will be attending.
NOSQL Conference Videos
I was not able to attend the NOSQL Conference on June 11th, 2009 in San Francisco, but the Braindump blog posted links to the presentations and videos.
Hadoop and Project Voldemort
Great article in two parts (part 1, part 2) co-authored by Elias Torres (a colleague and friend) on using Hadoop and Project Voldemort for managing very large datasets.
It was interesting to read about the deployment issues they had to deal with as I dealt with some of the same issues with the indices for the search engine at Feedster (the update cycle there was 10 minutes), and the issue with key lookup as I had to engineer that for the search engine.






leave a comment