Redis: the AK-47 of databases
flazz.me
flazz.me
Of all the weapons in the vast soviet arsenal, nothing was more profitable than Avtomat Kalashnikova model of 1947. More commonly known as the AK-47, or Kalashnikov. It's the world's most popular assault rifle. A weapon all fighters love. An elegantly simple 9 pound amalgamation of forged steel and plywood. It doesn't break, jam, or overheat. It'll shoot whether it's covered in mud or filled with sand. It's so easy, even a child can use it; and they do. The Soviets put the gun on a coin. Mozambique put it on their flag. Since the end of the Cold War, the Kalashnikov has become the Russian people's greatest export. After that comes vodka, caviar, and suicidal novelists. One thing is for sure, no one was lining up to buy their cars.
Only tangentially related :) but I thought worth sharing. Anyone care to write a redis version?
AK-47. The very best there is. When you absolutely, positively got to kill every motherf@#$%r in the room, accept no substitutes.
They are great weapons though. I've never cleaned mine or had a jam. I hope this database is that good!
For example, you use a clip to load ammunition into the (internal) magazine of an M1, and you could use a clip to load ammunition into a "banana clip", which actually refers to a style of magazine.
In fact, the internal pistol magazine of a C96 pistol is still a magazine, but it loaded by a stripper clip, and some guns like the Japanese Type 3 are fed directly from stripper type clips - but those aren't "speedloaders" as the article suggests.(To juxtapose the concepts completely...)
http://en.wikipedia.org/wiki/Stripper_clip http://en.wikipedia.org/wiki/C96_pistol http://en.wikipedia.org/wiki/Type_3_Heavy_Machine_Gun
https://secure.wikimedia.org/wikipedia/en/wiki/Clip_%28ammun...
Using the term "clip" to mean "magazine" is both slang, and incorrect.
Some nice illustrations I found: http://i.min.us/ie52d2.jpg http://i.min.us/icklUo.jpg
To any firearms enthusiast, hearing clip and magazine being confused is like hearing nails on a chalk board. Imagine someone at your work insisting that Java and Javascript are the same language.
This is a rather poor analogy. Someone confusing Java and Javascript might believe they can paste their Javascript code into a Java program and have it work. Nothing of this nature will result from confusing clips and magazines. A shooter isn't going to expect to be able to use their Mosin-Nagant clips with their PSL, any more than they would expect for the PSL magazines to be valid replacements for their Winchester 1895 magazines.
It is incorrect, but it's not all that bad. 95% of the time, it is clear from context; the remaining cases primarily concern weapons with a fixed magazine, for which the user probably does know the difference.
It's like everyone calling car wheels "rims"
They're fun.
It's a lot of fun to shoot, the AK is cheap reliable, historical and can be used for fun, hunting (yes) and in survival situations. I actually do a "StartupGuns" [2] event in Pittsburgh where a bunch of us go shooting like OpenCoffee or similar.
[1] http://en.wikipedia.org/wiki/Akm ("Features") [2] http://www.facebook.com/group.php?gid=207534415228
"According to Director Andrew Niccol in the DVD commentary, the guns were real guns rented from a real arms dealer, as it was cheaper for the production to rent 3,000 real guns than to rent 3,000 blank converted props. "
http://en.wikipedia.org/wiki/Brandon_Lee#Death
> (...) behind schedule (...) they decided to make dummy cartridges from real cartridges by pulling out the bullets, dumping out the propellant and reinserting the bullets. However, the team neglected to remove the primers, which, if fired, could still produce just enough force to push the bullet out of the cartridge and into the barrel. At some point prior to the fatal scene, the live primer in one of the improperly constructed dummy rounds was discharged by an unknown person while in the pistol, leaving the bullet stuck in the barrel.
> (...) the same gun was later reloaded with blank cartridges and used in the scene in which Lee was shot. When the first blank cartridge was fired, the stuck bullet was propelled out of the barrel and struck Lee in the abdomen, lodging in his spine.
BTW, I highly recommend "The Gun" by C.J. Chivers. It's a fascinating historical treatise about this weapon.
http://en.wikipedia.org/wiki/Weapons_of_choice
In the books, a near future (near our present) naval task force accidentally travels back in time to WWII. The U.S. eager to get a leg up in the war asks the chrononauts to give them future tech. The only problem is that WWII American doesn't have the manufacturing technology to produce any of the current equipment. So the chrononauts dig through their archives and find plans for the AK-47, which, as it turns out, is manufacturable in early 1940's U.S. thereby giving the Americans a weapon from the future, but still old enough that they could be produced in bulk.
Most of the cheap ones in the 90's were Maadi (Egyptian), and now they're usually Romanian.
> In the spirit of full disclosure, I’m a newb to Redis. My
> knowledge is basically the contents of this post (at the
> time of writing). I don’t use it in production (yet).
> Likewise I’m no expert in AK-47s (I’ve never even fired
> one) or guns in general. I’m aware via notoriety alone.
Fantastic quote. So you're hardly familiar with either component of your simile, but you'll post it anyway? I really don't expect New Yorker-esque editing from bloggers, but that's simply not very substantial writing.No wonder people make fun of the so-called "NoSQL movement."
But that's good. It helps them -- it reinforces their learning and they certainly find out if they got something wrong -- and it helps us -- readers see a lot of articles pop up right when people are interested in and passionate about learning something, rather than months later when they know it all and have moved on.
Early blogging is quick iteration of knowledge. Blog about something you learned today, not years ago.
step 1. Someone posts something (anything will do) on a blog
step 2. HN tears it apart and reconstitutes it with some decent approximation of truth and usually a fair bit of insight.
Basically, the source content is just the jumping off point. The blogs serve as a focal point for directing the HN hive's attention for a while.
You could post a story titled "Sarah Palin is more influential than the Pope but less influential than the iPhone" and fill it with lolcat pictures and still get an interesting discussion here.
Why? Because smart people are awesome.
That's obviously just a legend. This debate was actually carried out in the 2nd half of the 19th century, starting with the Civil War. (Many repeating rifle designs were offered to the Union. Quartermasters repeatedly shut them down on account of expected difficulties with ammo supply. After much time and effort, a few repeating rifles made it through, particularly to the cavalry, where they proved quite decisive in the last year of the war. See Five Forks, for instance.)
Now, I'm pretty sure 'automatic' fire was burst limited. But that's pretty much nearly universally accepted as a good idea in main infantry rifles.
In fact the US Army's M16 was changed from automatic to semi-automatic, so it seems there is a movement in the other direction.
That said I hope the author will revisit the topic when he has more knowledge of the subject matter, such as when using it in production for a while on a fair sized project with a lot of users. That's where the rubber meets the road, first impressions tend to gloss over the areas where the meat is.
One hopes the meat is not between the rubber and the road. That would be unfortunate.
Also this part of the config:
save 900 1
save 300 10
save 60 10000
is not at all obvious. Maybe it's better documented in the sample config. MULTI
get foo # Returns 'abc'
set foo 'abcd' # (as in application code said foo += 'd')
EXEC
while another process sets foo to 'xyz' between my get and set, I just overwrote that value. No serializable transactions.so for this you would really just want to do: APPEND foo d
or for more complex situations you could do use WATCH instead of MULTI so that you can get the intermediate results. so for your example:
WATCH foo GET foo ->value //calculate new_value MULTI SET foo new_value EXEC
now if at any other operation (not part of this connection) modifies foo then the transaction will be aborted.
GET foo -> value //application logic to update value GETSET foo new_value ->prev
then prev will contain the value of foo at the time it was set, so you can then use application logic to roll back or redo the transaction
You can perform just writes inside the block. If you want atomicity with reads in the middle, you need to use WATCH/MULTI/EXEC that uses an optimistic locking algorithm.
With WATCH is very easy. WATCH this keys. Perform your reads. Prepare to write in a transaction. If at least one key was modified in the meantime the transaction will fail.
EDIT: looks like there is rollback support: http://redis.io/commands/discard
Now I clearly state in the doc that transactions are reflected also in the append only file, so there is no chance of partial reply.
Transactions are also applied to the master -> slave link, so also slaves will either have the full transaction or nothing.
Thanks to @garybernhardt on twitter for noticing this problem.
# Save the DB on disk:
#
# save <seconds> <changes>
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
#
# In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changedThis article should not get upvoted.
How can they guarantee that, when RAM is little more than a disk cache on modern operating systems? Is there a syscall that prevents specified pages of virtual memory from being paged out to disk? Or is Redis implemented as a kernel module?
The kernel does let userspace have a /little/ fun on its own.
So fare in two years we never saw an instance where there was a latency problem because part of the dataset was swapped on disk by the OS. This is why we currently don't use mlockall().
Pub/sub exists in a multitude of different pieces of software. ZeroMQ has a pub/sub feature. PostgreSQL has the NOTIFY/LISTEN command which is also a Pub/Sub channel allowing all those listening to be notified of certain events.
This is by no means unique to Redis. It is very useful, so I'll agree with that!
But every weapon was a bit off, so you had to get used to it (I guess that might be the same for all weapons).
okay okay. i hereby patent the definition 'an iPhone of databases' :)