This talk was given at Span London 2014, a great single track conference about distributed systems.
Recording will also be available through Skills Matter.
Building aReactive Database Driveron the JVMMichael NitschingerSoftware Engineer, Couchbase Inc.
View Slide
Let’s start with WHY
JSONJSONJSONJSONJSONPERFORMANCEScalabilityPERFORMANCEPerformanceAlways OnJSONJSONJSONJSONJSONPERFORMANCEFlexibility
Java SDK 1.*• Extends Spymemcached• Adds Config & View Capabilities• Stable & Mature• Older codebase, difficult to maintain and evolve• API inconsistencies over time
Reworking the API
single multiplesync T Iterableasync Future Observable
Event Iterable Observabledata retrieval T next() onNext(T)discover error throws Exception onError()complete returns onCompleted()
Creating & Consumingjust
Creating & Consuming
Transforming
Filtering
Reactive Database Query
Error Handling
Connecting
Consistent API
Document!
Wrap, not mix
Lessons Learned• Huge benefit in exposing reactive APIs• Also expose a synchronous API• Consistency matters• Document observable failure scenarios• Expect a learning curve, documentation helps
A new Architecture
Smart Batchinghttp://mechanical-sympathy.blogspot.co.at/2011/10/smart-batching.html
Backpressure
Netty PipelineEncoder(Encoder(Ne*y(Writes(Ne*y(Reads(Decoder(Decoder(
KeyValue Endpoint
Lessons Learned• Build for the JVM, not for Java• Benchmark early and often• Implicit batching amortizes slow consumers• Use explicit back pressure to avoid swamping• Use Netty for IO and be happy• Bundle your dependencies
Thanks! Questions?Couchbase is hiring :)http://www.couchbase.com/careers