/kagami

Library for using Kafka as a commit log

Primary LanguageScalaApache License 2.0Apache-2.0

Kagami

Build Status

Availability is one of the key concerns for any of today's microservices. Providing availability in any stateful service is not straightforward and requires a lot of work. Replication is one of the solutions used world wide by developers to provide availability for their microservices. But getting Replication right is one tough problem as it requires a lot of corner cases handling.

Kagami (japanese name for mirror) solves this problem by using kafka as a commit log.

  • Kagami offers a simple interface which needs to be implemented by the users for receiving replicated data.
  • Kagami takes care of replicating the state/writes from one node to some other node.
  • Kagami makes sure that these replicas are evenly distributed across nodes.
  • Kagami also support iterative snapshotting and replica reconstruction required in cases of node loss.

You can now build distributed available systems by simply plugging Kagami library in your application.

For more details, see this

Requirements

  • Curator Framework >= 2.8 version
  • Kafka >= 1.1.0

Getting Started

You need to have zookeeper ( localhost:2181 ) and kafka ( localhost:9092 ) running on your machine

git clone https://github.com/mridulv/kagami.git
cd kagami
mvn package
java -jar target/kagami-1.0-SNAPSHOT-jar-with-dependencies.jar token1 &
java -jar target/kagami-1.0-SNAPSHOT-jar-with-dependencies.jar token2 &

Overview

Here is a basic architecture explaining the internals of kagamiFramework

Overview

Usage

For using this library you just need to add a request listener to kagamiFramework (see for example SimpleKagamiClient), and the kagami library will make sure that all the writes for the replicas which are assigned to this node are made to this request listener.

new KagamiFramework()
      .addRequestListener(simpleKagamiClient)
      .init()

For example implementation, have a look at SimpleKagamiClient