Evolving NoSQL Databases without Downtime

Karla Saur, Tudor Dumitras, Michael W. Hicks

TL;DR

KVolve is a system that enables NoSQL databases to evolve their data schemas on-the-fly without service interruptions. By implementing automatic "lazy" migration within the database engine itself, it provides applications with a logically consistent view of the newest data version while eliminating the need for complex, error-prone version-handling code in the application layer.

What Problem Does This Paper Address?

As applications grow, their data requirements change. In the world of NoSQL (like Redis or MongoDB), developers often need to rename keys, add fields to JSON objects, or change data types. Traditionally, this leaves developers with two bad choices:

  1. Eager Migration (Stop-the-World): Shut down the app, run a script to convert every record, and restart. For large databases, this can take hours (the paper cites a 22-hour lock for a Wikipedia upgrade).
  2. Manual Lazy Migration: Rewrite application code to handle both old and new formats simultaneously. This "pollutes" the codebase with maintenance logic, creates technical debt, and is prone to subtle race conditions where concurrent updates might clobber each other.

The authors address the challenge of supporting high-availability applications that require frequent schema changes without incurring massive downtime or forcing developers to write "spaghetti" migration code.

Methods

The authors introduce KVolve, built as an extension to the popular Redis key-value store. Its architecture relies on three core pillars:

  • Versioned Data: Every data item in the store is tagged with a version ID. These tags are invisible to the application but allow KVolve to track which items are "stale."
  • Update Specifications: When a schema change is needed, the developer submits a "transformer function" (written in C or a similar language) that defines how to turn an old key/value into a new one.
  • On-Demand (Lazy) Transformation: KVolve acts as an interceptor. When an application requests a key (a GET command), KVolve checks the version. If it’s old, KVolve runs the transformer function, updates the database record atomically, and then returns the new version to the app.

To handle key renames (e.g., changing the prefix user: to member:), KVolve uses an Update Information Hash Table (UIHT). This allows the database to "look back" through previous key versions to find data that hasn't been renamed yet.

Datasets

The researchers evaluated KVolve using a mix of synthetic benchmarks and real-world application workloads:

  • Redis-bench: The standard performance benchmark included with Redis to measure raw throughput and latency.
  • redisfs: A Redis-backed file system. The authors tested upgrading it from version .5 to .7, which involved renaming directory keys and adding zlib compression to file data.
  • Amico: A social network system backed by Redis. They used a workload derived from the LiveJournal data set (from the SNAP library), containing ~4.8 million nodes and ~69 million edges, to simulate a large-scale social graph upgrade.

Key Insights and Ideas

  • The "Logically Consistent" View: This is the "aha" moment. KVolve ensures that once an upgrade is installed, the application only sees the new version. The database handles the "time travel" behind the scenes. This removes the burden of version-checking from the developer entirely.
  • Atomicity is Hard to Do Manually: If a developer tries to do lazy migration in the app, a GET followed by a SET to update the format isn't naturally atomic. Another client could sneak in a write between those steps. By moving this logic into the database (which is single-threaded in Redis's case), KVolve guarantees atomicity for free.
  • Bijections for Keys: For lazy key renames to work, the transformation must be a "bijection"—meaning you can uniquely map the new key back to the old one. The authors found that in practice, almost all real-world NoSQL schema changes (mostly prefix changes) satisfy this requirement.

Key Results

  • Zero Downtime: In the redisfs and Amico tests, KVolve maintained service throughout the upgrade. In contrast, "eager" migration caused a 12-second pause for redisfs and an 87-second pause for Amico.
  • Minimal Performance Hit: During normal operation (no active upgrade), KVolve adds essentially zero overhead. Even during an active upgrade with 10 pipelined instructions, the throughput overhead was capped at roughly 5.7%.
  • Memory Overhead: Storing version tags and the UIHT adds about 15% memory overhead for a database with 1 million small keys. While not negligible, it is a reasonable trade-off for high-availability systems.

Limitations and Future Work

  • Redis Specifics: The current implementation leverages Redis's single-threaded nature for atomicity. Porting this to multi-threaded NoSQL stores (like Cassandra) would require more complex locking mechanisms.
  • Transformer Complexity: Writing transformer functions in C can be "tedious." The authors suggest a Domain Specific Language (DSL) would make the system more user-friendly.
  • Distributed Systems: The paper focuses on a single Redis instance. The authors identify extending KVolve to Redis Cluster (distributed/sharded environments) as a primary goal for future research.

Summary updated

BibTeX
@inproceedings{saur2016evolving,
  author = {Karla Saur and Tudor Dumitras and Michael W. Hicks},
  title = {{Evolving NoSQL Databases without Downtime}},
  booktitle = {ICSME},
  year = {2016},
  url = {https://openreview.net/forum?id=7FlPgh6A69},
}
Figure