{"id":22621310,"url":"https://github.com/nemanja-m/kiwi","last_synced_at":"2026-05-04T03:33:37.993Z","repository":{"id":246522852,"uuid":"821358717","full_name":"nemanja-m/kiwi","owner":"nemanja-m","description":"KiWi is a lightweight RESP-compliant key-value store inspired by the Bitcask paper, designed for simplicity and blazingly-fast operations 🥝","archived":false,"fork":false,"pushed_at":"2024-12-09T19:27:26.000Z","size":401,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T02:25:20.197Z","etag":null,"topics":["bitcask","key-value-database","netty","redis-protocol"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nemanja-m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-28T11:10:16.000Z","updated_at":"2024-12-19T18:57:25.000Z","dependencies_parsed_at":"2024-06-28T13:29:16.820Z","dependency_job_id":"5f515849-ee78-4a91-8153-075a9467331a","html_url":"https://github.com/nemanja-m/kiwi","commit_stats":null,"previous_names":["nemanja-m/kiwi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nemanja-m/kiwi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanja-m%2Fkiwi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanja-m%2Fkiwi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanja-m%2Fkiwi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanja-m%2Fkiwi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nemanja-m","download_url":"https://codeload.github.com/nemanja-m/kiwi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanja-m%2Fkiwi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32593943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcask","key-value-database","netty","redis-protocol"],"created_at":"2024-12-08T23:07:30.755Z","updated_at":"2026-05-04T03:33:37.978Z","avatar_url":"https://github.com/nemanja-m.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n   \u003cimg src=\"./docs/logo.png\" alt=\"KiWi Logo\" width=\"200\" height=\"220\"/\u003e\n\u003c/p\u003e\n\n# KiWi: A Lightweight RESP Key-Value Store.\n\nKiWi is a high-performance, [RESP](https://redis.io/docs/latest/develop/reference/protocol-spec/)\ncompliant, key-value store inspired by the Bitcask paper, designed\nfor simplicity, reliability, and blazing-fast read/write operations.\n\n## Features\n\n- RESP protocol support for Redis-compatible client interaction.\n- Non-blocking I/O server with Netty.\n- High-performance key-value store based on the Bitcask storage model.\n- In-memory indexing for fast reads.\n- TTL-based key expiration.\n- Checksums for data integrity.\n- Compaction and efficient file merging process.\n- Hint files for quick startup times.\n- Tunable durability.\n\n## Quick Start\n\n1. Start Docker container\n    ```bash\n    docker run --name kiwi -p 6379:6379 -v ./local/db:/var/lib/kiwi/data nemanjam/kiwi:latest\n    ```\n\n2. Connect to the server with `redis-cli`\n    ```bash\n    redis-cli -h localhost\n    ```\n\n3. Use the server as you would a Redis server.\n    ```text\n    SET key value\n    OK\n\n    GET key\n    \"value\"\n\n    EXISTS key\n    (integer) 1\n\n    DEL key\n    OK\n\n    EXISTS key\n    (integer) 0\n    ```\n\n### Supported Commands\n\n- `SET key value`\n- `GET key`\n- `DEL key`\n- `EXISTS key`\n- `FLUSHDB`\n- `PING`\n- `DBSIZE`\n- `INFO`\n\n## Configuration\n\nKiWi can be configured using environment variables or a HOCON configuration file.\nRefer to [Typesafe Config](https://github.com/lightbend/config) for configuration examples.\n\nDefault values and environment variables:\n\n- [kiwi-core/application.conf](kiwi-core/src/main/resources/application.conf)\n- [kiwi-server/application.conf](kiwi-server/src/main/resources/application.conf)\n\n## Installation\n\n### Prerequisites\n\n- Java 21\n- Docker (optional, for running via a container)\n\n### From Source\n\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/nemanjam/kiwi.git\n    cd kiwi\n    ```\n2. Build \u0026 install the project:\n    ```bash\n    ./gradlew installDist\n    ```\n3. Run the KiWi server:\n    ```bash\n    ./kiwi-server/build/install/kiwi-server/bin/kiwi-server\n    ```\n\n### Docker\n\n1. Build the Docker image\n    ```bash\n    docker build -t kiwi .\n    ```\n2. Run the container:\n    ```bash\n    docker run --rm --name kiwi -p 6379:6379 kiwi:latest\n    ```\n3. Connect to the server:\n    ```bash\n    redis-cli -h localhost -p 6379\n    ```\n\n## Checksums\n\nKiWi uses CRC32 checksums to ensure data integrity. The checksum is stored alongside the data.\nThere is a special command that can be used to verify the data integrity.\n\nChecksum command uses available CPU cores to parallelize the checksum calculation. If checksum\nfails,\nthe following error message will be displayed:\n\n```text\nChecksum failed: segment=00000000000000000000 position=444636640 checksum=2005447726 timestamp=1733002903067 ttl=0 keySize=16 valueSize=0\n```\n\n### Docker\n\n```bash\ndocker run -it --rm -p 6379:6379 nemanjam/kiwi:latest sh checksum --dir [log dir] --threads [threads]\n```\n\n### Java\n\n```bash\njava -cp \"kiwi-server/build/install/kiwi-server/lib/*\" kiwi.core.checksum.Run --dir [log dir] --threads [threads]\n```\n\n## Benchmarks\n\nKiWi can be evaluated with [redis-benchmark](https://redis.io/topics/benchmarks) utility command.\n\nBelow are the results of running `redis-benchmark` with KiWi and Redis on a local setup (MacBook M3\nPro with 18GB RAM and Sequoia 15.1.1).\n\n```text\nredis-benchmark -h localhost -t set -n 100000 -r 10000000 -d 1024\n\n====== SET ======\n  100000 requests completed in 2.18 seconds\n  50 parallel clients\n  1024 bytes payload\n  keep alive: 1\n  host configuration \"save\":\n  host configuration \"appendonly\":\n  multi-thread: no\n\nSummary:\n throughput summary: 45934.77 requests per second\n latency summary (msec):\n          avg       min       p50       p95       p99       max\n        1.016     0.088     0.951     1.863     2.703    30.655\n```\n\n```text\nredis-benchmark -h localhost -t get -n 100000 -r 10000000 -d 1024\n\n====== GET ======\n  100000 requests completed in 1.83 seconds\n  50 parallel clients\n  1024 bytes payload\n  keep alive: 1\n  host configuration \"save\":\n  host configuration \"appendonly\":\n  multi-thread: no\n\nSummary:\n throughput summary: 60753.34 requests per second\n latency summary (msec):\n          avg       min       p50       p95       p99       max\n        0.661     0.088     0.639     0.967     1.311    12.255\n```\n\nJVM options:\n\n```text\n-Xms2g -Xmx2g -XX:UseG1GC –XX:+UseStringDeduplication -XX:+AlwaysPreTouch\n````\n\nKiWi Configuration:\n\n```hocon\nkiwi {\n  storage {\n    log {\n      dir = \"/tmp/kiwi\"\n      segment.bytes = 1073741824 // 1GB\n\n      sync {\n        mode = \"periodic\"\n        periodic {\n          interval = 10s\n        }\n      }\n    }\n  }\n}\n```\n\n## Design\n\nKiWi combines the simplicity of RESP with the efficient storage model described in the Bitcask\npaper. This architecture is designed for high performance and simplicity.\n\n### Storage Model\n\n- All write operations are appended to a log file, ensuring sequential disk writes for maximum\n  performance.\n- When the active log file reaches a configurable size, it is rolled over to a segment file.\n- Periodically, segment files are compacted to remove stale data and reclaim disk space.\n- Crash recovery is achieved by replaying the log files during startup.\n- Disk I/O operations, like log compaction, are handled in background threads to avoid blocking\n  client requests.\n\n### In-Memory Index\n\n- All keys are stored in an in-memory hash table, pointing to their location in the log file.\n- This ensures `O(1)` read performance while keeping the storage footprint minimal.\n\n### Non-Blocking I/O Server\n\n- Netty-based event loop for handling client requests.\n- KiWi supports the RESP protocol, making it compatible with Redis clients and tools.\n\n### Durability\n\n- KiWi provides tunable durability options to balance performance and data safety:\n    - `periodic` (default): Writes are flushed to disk at regular intervals.\n    - `batch`: Writes are batched and flushed when the batch window expires. All writers are blocked\n      until the batch is written.\n    - `lazy`: Flush is delegated to the operating system, which may delay writes for performance.\n\n### Pros\n\n- Fast writes due to sequential disk I/O.\n- Fast reads with O(1) lookups using the in-memory index.\n- Simple and robust crash recovery with the data and hint files.\n- Incremental crash-safe compaction process.\n\n### Cons\n\n- The in-memory index requires all keys to fit in memory.\n- Log compaction introduces periodic I/O overhead.\n\n## Contributing\n\nWe welcome contributions to KiWi! Here’s how you can help:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bugfix.\n3. Submit a pull request with a clear description of your changes.\n\n## License\n\nKiWi is licensed under the MIT License. See [LICENSE](./LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemanja-m%2Fkiwi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnemanja-m%2Fkiwi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemanja-m%2Fkiwi/lists"}