Design

Krati is mainly designed for serving simple reads and writes (e.g., key-value access) from memory and providing persistency in the meanwhile. It is intended for read-write-intensive applications with relaxed transactional semantics.

Design Considerations:

Architectural Overview:

The conceptual architecture of Krati is composed of three layers. The top layer is the content data store service API, which includes array-like set/get methods and standard key-value store get/put/delete methods. The bottom layer provides Java NIO-based persistency to back up data segments, indexes, and meta data via disk files.

The layer in the middle manages data segments, data indexes, and write-ahead redo logic. Segment Manager is responsible for segment creation, recycle and compaction. Index Manager uses hash functions to map keys to memory-resident array indexes. It does automatic batch-based flushing to sync data, indexes, and meta data to disk files. Data Handler allows customization of data to put into segments.

Krati segments can be thought of pure data blocks backed by files on disk. Every segment contains a number of data elements. The index manager provides logic for retrieving indexes to data elements in a segment. Krati always keeps indexes in memory for better performance. Krati supports three types of segments:

The following diagram shows the internal implementation of the Krati main class SimpleDataArray. Multiple readers can issue concurrent reads via DataArray get methods. There is one and only one writer, which does append-only writes to data segments via DataArray set methods. The writer periodically starts a compactor to perform segment compaction and reclaim wasted data space.