background preloader

Memcached

Facebook Twitter

Processing language for memcached. Memcached is a hashtable with a simple API that allows for remote access. It is a major component of many large-scale web sites because it caches results from more expensive remote resources, i.e. DB access. The API consists of a several different storage methods (set, add, replace, append, prepend, cas), retrieval methods (get, gets), and a delete command (delete). Unfortunately, if you want to do something more complex than simple store/retrieve with memcached, then you have to make lots of expensive remote calls. For example, say I store a tree in the cache, where each node is “key, node key, node key”. To delete the entire tree, you have to recursively get the root node, delete it, then get both branches, delete them, etc. This is expensive. A possible solution is to send Forth scripts to memcached to execute locally. A better example is to delete a tree as described above. . : delete-tree ( key -- ) dup get each [ dup 0 = [ . ] [ delete-tree ] if ] delete Like this: Like Loading...

Memcached Adoption Spur Solutions. What Matters in an Asynchronous Job Queue. Oct. 4, 2008, 1:02 p.m. An asynchronous job queue is a key element of system scalability. Job queues are particularly well-suited for web sites where an HTTP request requires some actions to be performed that may take longer than a second or two and where immediate results aren't necessarily required. Important Properties of a Job Queue There are several properties of such a queue system that have various levels of importance. Everybody has a different take on the levels of importance of each property.

I'm going to list the properties that I find important and why here. A Single Job is Handled by a Single Worker This one is seemingly obvious. Note that this is not universally true, however. Different Jobs May be Handled by Different Workers I have different classes of workers dedicated to performing different jobs. Priority Queues I've never deployed a worker queue and not needed to start prioritizing jobs. Delayed Jobs My #1 reason to delay a job is because of a temporary failure. LightCloud - Distributed and persistent key value database.

Distributed and persistent key-value database Features Built on Tokyo Tyrant. One of the fastest key-value databases [benchmark]. Tokyo Tyrant has been in development for many years and is used in production by Plurk.com, mixi.jp and scribd.com (to name a few)... But that's not all, we also support Redis (as an alternative to Tokyo Tyrant)! Check benchmarks and more details about Redis in LightCloud adds support for Redis.

Stability It's production ready and Plurk.com is using it to store millions of keys on only two servers that run 3 lookup nodes and 6 storage nodes (these servers also run MySQL). How LightCloud differs from memcached and MySQL? Memcached is used for caching, meaning that after some time items saved to memcached are deleted. MySQL and other relational databases are not efficient for storing key-value pairs, a key-value database like LightCloud is. How LightCloud differs from redis and memcachedb? Benchmark against memcached Benchmark program Useful links Lua extension License. In-Memory Caching: Why We Can't Just Trust the Database to.

I remember taking an operating systems class in college and marveling at the fact that operating system design seemed less about elegant engineering and more about [what I viewed at the time as] performance hacks. I saw a similar sentiment recently captured by Eric Florenzano in his post It's Caches All the Way Down where he starts describing how a computer works to a friend and ends up talking about the various layers of caching from CPU registers to L2 caches to RAM and so on.

At the end of his post Eric Florenzano asks the following question I've often heard at work and in developer forums like programming.reddit That's what struck me. When you come down to it, computers are just a waterfall of different caches, with systems that determine what piece of data goes where and when. For the most part, in user space, we don't care about much of that either.

Eric is simultaneously correct and incorrect in his statements around caching and database layers. Rockstar Memcaching. A peek at memcached's implementation. I am a huge fan of memcached and we use it a lot on Plurk . Why to like memcached: it's a very simple protocol and supported for a lot of languages it's used by web-giants ( Facebook has now 25 terabytes of memcached cache ) it performs really well I have looked lightly into the internals of memcached to find out how it does its magic and what it makes it such an amazing choice for caching.

External libraries used memcached uses these external libraries: libevent : libevent is used to provide non-blocking IO. Bob Jenkins's hash function is used for hashing How memcached manages memory Memcached does not use malloc/free for memory management, but a manual memory manager (implemented in slabs.c). The primary goal of the slabs subsystem in memcached was to eliminate memory fragmentation issues totally by using fixed-size memory chunks coming from a few predetermined size classes (early versions of memcached relied on malloc()'s handling of fragmentation which proved chunks of this size. Memory). A Bunch of Great Strategies for Using Memcached and MySQL Better. The primero recommendation for speeding up a website is almost always to add cache and more cache. And after that add a little more cache just in case. Memcached is almost always given as the recommended cache to use. What we don't often hear is how to effectively use a cache in our own products.

MySQL hosted two excellent webinars (referenced below) on the subject of how to deploy and use memcached. The star of the show, other than MySQL of course, is Farhan Mashraqi of Fotolog. You may recall we did an earlier article on Fotolog in Secrets to Fotolog's Scaling Success, which was one of my personal favorites. Fotolog, as they themselves point out, is probably the largest site nobody has ever heard of, pulling in more page views than even Flickr. What is Memcached? The first part of the first webinar gives a good overview of memcached. The rest of the first webinar is Farhan explaining in wonderful detail how they use memcached at Fotolog. Memcached and MySQL Go Better Together. Spymemcached. A simple, asynchronous, single-threaded memcached client written in java. Efficient storage of objects. General serializable objects are stored in their serialized form and optionally compressed if they meet criteria. Certain native objects are stored as tightly as possible (for example, a Date object generally consumes six bytes, and a Long can be anywhere from zero to eight bytes).

Resilient to server and network outages. Note - as of the 2.9 (and 2.10) series, artifacts are published to Maven Central and the groupId has changed from "spy" to "net.spy": Grab the new artifacts from here: Please use at least 2.10.2 from the 2.10 series since it fixes some issues for the new 2.10.0 and 2.10.1 features!

Please note that google code doesn't allow file uploads starting 2014. YourKit is kindly supporting the spymemcached open source project with its full-featured Java Profiler. Memcached: a distributed memory object caching system.