TheLadders Scales With Couchbase

Serving a high-traffic website like TheLadders requires an effective use of caching. Initially, TheLadders implemented heavy local caching on web nodes, which sacrificed large amounts of memory to duplication across nodes.  As their number of web nodes grew, they needed to find a more scalable solution.



Situation

Serving a high-traffic website like TheLadders requires an effective use of caching. Initially, TheLadders implemented heavy local caching on web nodes, which sacrificed large amounts of memory to duplication across nodes.  As their number of web nodes grew, they needed to find a more scalable solution.



TheLadders caches a variety of domain objects.  For example, job objects are cached at keys of the form Job_{ID}, where {ID} is the primary key of the job table in their distributed relational database.  The mapping from database table to domain object usually isn’t one-to-one, however.  The job object in the application is built from joining multiple tables in the database.

The data that makes up these objects changes frequently, from within TheLadders’ many web applications (both external and internal), and also from scripts and sometimes manual updates to the database. Stale data cannot be allowed to remain in the cache for these objects, as users need to take actions based on the current state of the data. The typical write-through cache approach, where writes are synchronously performed to both the cache and the backing store, does not work unless all writes go through a single caching layer.

Solution

The only way to be sure of capturing all changes to cached data is by monitoring at the very lowest level: the backing database.  TheLadders scans its binary logs (via the open-source Tungsten Replicator) for insert/update/delete operations.  Within Tungsten is a mapping of database tables to the domain object types they make up (tables and types have a many-to-many relationship).

When an operation is detected on a table mapped to one or more domain object types, queries are run to retrieve the primary keys of all affected domain objects.  TheLadders then uses Tungsten to call service methods that invalidate these objects in the cache.  To make asynchronous invalidation feasible without serving stale data to users, the entire process from data change to cache invalidation must be completed in a matter of milliseconds. With its sub-millisecond response times, Couchbase was the key to overcoming this challenge.

Results

With the savings in memory costs provided by Couchbase, TheLadders is now caching more data than ever.  They are already storing over 3 million domain objects in a 3-node cluster with 100G of memory, and achieving a 97% cache hit ratio over hundreds of operations per second.  Couchbase’s ease of scaling, in terms of both adding nodes and more memory per node, makes it an excellent choice for anyone dealing with rapidly expanding data sets.  In addition, the web interface makes Couchbase easy to monitor and administer.

TheLadders has many plans to expand its usage of Couchbase, from caching user sessions for seamless code releases / recovery from failed web nodes, to storing high-level counters and other aggregates as the data changes, rather than calculating them every time on the fly.  They also plan to migrate persisted data accessed by primary key from their relational database to Couchbase for faster lookups.  TheLadders found that Couchbase’s support team gave them the peace of mind needed to make Couchbase Server a critical piece of their infrastructure.

After evaluating a variety of caching solutions and key-value databases, Couchbase was the clear winner. It's compatible with the memcached protocol, easy to administer and scale, and maintains enterprise-level availability on commodity hardware. It's also really fast!

– Patrick Delfert, Software Architect

TheLadders is a job-matching service for career-driven professionals, helping them find the jobs, and meet the recruiters and employers, that are right for their career goals.  Their team includes a full crew of job search advisors and specialists, certified professional resume writers and analysts, talent specialists, certified professional career coaches, and all of our behind-the-scenes research and support.  TheLadders is headquartered in New York, with offices in London.