 [](https://travis-ci.org/Qihoo360/pika)  | **Stargazers Over Time** | **Contributors Over Time** | |:-----------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | [](https://starchart.cc/OpenAtomFoundation/pika) | [](https://contributor-graph-api.apiseven.com/contributors-svg?chart=contributorOverTime&repo=OpenAtomFoundation/pika) | ## Introduction[中文](https://github.com/OpenAtomFoundation/pika/blob/unstable/README_CN.md) PikiwiDB is a high-performance, large-capacity, multi-tenant, data-persistent elastic KV data storage system using RocksDB as the storage engine. It is fully compatible with the Redis protocol and supports its commonly used data structures, such as string/hash/list/zset/set/geo/hyperloglog/pubsub/bitmap/stream, etc. [Redis Interface](https://github.com/OpenAtomFoundation/pika/wiki/pika-%E6%94%AF%E6%8C%81%E7%9A%84redis%E6%8E%A5%E5%8F%A3%E5%8F%8A%E5%85%BC%E5%AE%B9%E6%83%85%E5%86%B5). When Redis's in-memory usage exceeds 16GiB, it faces problems such as limited memory capacity, single-threaded blocking, long startup recovery time, high memory hardware costs, easily filled buffers, and high switching costs when one master and multiple replicas fail. The emergence of PikiwiDB is not to replace Redis but to complement it. PikiwiDB strives to completely comply with the Redis protocol, inherit Redis's convenient operation and maintenance design, and solve the bottleneck problem of Redis running out of memory capacity once the data volume becomes huge by using persistent storage. Additionally, PikiwiDB can support master-slave mode using the slaveof command, and it also supports full and incremental data synchronization. PikiwiDB can be deployed in a single-machine master-slave mode (slaveof) or in a [Codis](https://github.com/OpenAtomFoundation/pika/tree/unstable/codis) cluster mode, allowing for simple scaling and shrinking. Migration from Redis to PikiwiDB can be smoothly executed by [tools](https://github.com/OpenAtomFoundation/pika/tree/unstable/tools). ## PikiwiDB Features * **Protocol Compatibility**: Fully compatible with the Redis protocol, emphasizing high performance, large capacity, low cost, and scalability. * **Data Structures**: Supports Redis's common data structures, including String, Hash, List, Zset, Set, Geo, Hyperloglog, Pubsub, Bitmap, Stream, ACL, etc. * **Cold and Hot Data**: Caches hot data and persistently stores the full data in RocksDB, implementing a hierarchical storage of cold and hot data. * **High Capacity**: Compared to Redis's in-memory storage, PikiwiDB supports data volumes in the hundreds of gigabytes, significantly reducing server resource consumption and enhancing data reliability. * **Deployment Modes**: Supports single-machine master-slave mode (slaveof) and Codis cluster mode, making scaling and shrinking simple. * **Easy Migration**: Smooth migration from Redis to PikiwiDB without modifying code. * **Convenient Operation and Maintenance**: Comprehensive operation and maintenance command documentation. ## PikiwiDB Storage Engine Architecture * Supports multiple platforms: CentOS, Ubuntu, macOS, Rocky Linux * Multi-threaded model * Based on the RocksDB storage engine * Multiple granularity data caching model ## Deployment Modes ### 1. Master-Slave Mode * Architecture similar to Redis * Good compatibility with Redis protocol and data structures * Each data structure uses a separate RocksDB instance * Master-slave adopts binlog asynchronous replication  ### 2. Distributed Cluster Mode * Adopts Codis architecture, supports multiple groups * Each group forms a master-slave set * Elastic scaling based on groups  ## PikiwiDB User Showcase
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
> Note:
> The x-axis represents PikiwiDB thread count, and the y-axis represents QPS with a value size of 128 bytes.
> "set3/get7" indicates 30% set and 70% get operations.
* ##### Case One Conclusion
From the above graph, it can be observed that setting PikiwiDB's worker thread count to 20-24 is more cost-effective.
#### 3.2 Case 2
* ##### Test Objective
Evaluate the RTT performance of PikiwiDB with the optimal worker thread count (20 threads).
* ##### Test Conditions
* PikiwiDB Data Size: 800GB
* Value: 128 bytes
* ##### Test Results
```c
====== GET ======
10000000 requests completed in 23.10 seconds
200 parallel clients
3 bytes payload
keep alive: 1
99.89% <= 1 milliseconds
100.00% <= 2 milliseconds
100.00% <= 3 milliseconds
100.00% <= 5 milliseconds
100.00% <= 6 milliseconds
100.00% <= 7 milliseconds
100.00% <= 7 milliseconds
432862.97 requests per second
```
```c
====== SET ======
10000000 requests completed in 36.15 seconds
200 parallel clients
3 bytes payload
keep alive: 1
91.97% <= 1 milliseconds
99.98% <= 2 milliseconds
99.98% <= 3 milliseconds
99.98% <= 4 milliseconds
99.98% <= 5 milliseconds
99.98% <= 6 milliseconds
99.98% <= 7 milliseconds
99.98% <= 9 milliseconds
99.98% <= 10 milliseconds
99.98% <= 11 milliseconds
99.98% <= 12 milliseconds
99.98% <= 13 milliseconds
99.98% <= 16 milliseconds
99.98% <= 18 milliseconds
99.99% <= 19 milliseconds
99.99% <= 23 milliseconds
99.99% <= 24 milliseconds
99.99% <= 25 milliseconds
99.99% <= 27 milliseconds
99.99% <= 28 milliseconds
99.99% <= 34 milliseconds
99.99% <= 37 milliseconds
99.99% <= 39 milliseconds
99.99% <= 40 milliseconds
99.99% <= 46 milliseconds
99.99% <= 48 milliseconds
99.99% <= 49 milliseconds
99.99% <= 50 milliseconds
99.99% <= 51 milliseconds
99.99% <= 52 milliseconds
99.99% <= 61 milliseconds
99.99% <= 63 milliseconds
99.99% <= 72 milliseconds
99.99% <= 73 milliseconds
99.99% <= 74 milliseconds
99.99% <= 76 milliseconds
99.99% <= 83 milliseconds
99.99% <= 84 milliseconds
99.99% <= 88 milliseconds
99.99% <= 89 milliseconds
99.99% <= 133 milliseconds
99.99% <= 134 milliseconds
99.99% <= 146 milliseconds
99.99% <= 147 milliseconds
100.00% <= 203 milliseconds
100.00% <= 204 milliseconds
100.00% <= 208 milliseconds
100.00% <= 217 milliseconds
100.00% <= 218 milliseconds
100.00% <= 219 milliseconds
100.00% <= 220 milliseconds
100.00% <= 229 milliseconds
100.00% <= 229 milliseconds
276617.50 requests per second
```
* ##### Case 2 Conclusion
The response time for 99.9% of get/set operations is within 2ms.
#### 3.3 Case 3
* ##### Test Objective
Evaluate the maximum QPS for each command in PikiwiDB with the optimal worker thread count.
* ##### Test Conditions
* PikiwiDB Worker Thread Count: 20
* Number of Keys: 10,000
* Number of Fields: 100 (excluding lists)
* Value: 128 bytes
* Number of Command Executions: 10 million (except for lrange)
* ##### Test Results
```c
PING_INLINE: 548606.50 requests per second
PING_BULK: 544573.31 requests per second
SET: 231830.31 requests per second
GET: 512163.91 requests per second
INCR: 230861.56 requests per second
MSET (10 keys): 94991.12 requests per second
LPUSH: 196093.81 requests per second
RPUSH: 195186.69 requests per second
LPOP: 131156.14 requests per second
RPOP: 152292.77 requests per second
LPUSH (needed to benchmark LRANGE): 196734.20 requests per second
LRANGE_10 (first 10 elements): 334448.16 requests per second
LRANGE_100 (first 100 elements): 50705.12 requests per second
LRANGE_300 (first 300 elements): 16745.16 requests per second
LRANGE_450 (first 450 elements): 6787.94 requests per second
LRANGE_600 (first 600 elements): 3170.38 requests per second
SADD: 160885.52 requests per second
SPOP: 128920.80 requests per second
HSET: 180209.41 requests per second
HINCRBY: 153364.81 requests per second
HINCRBYFLOAT: 141095.47 requests per second
HGET: 506791.00 requests per second
HMSET (10 fields): 27777.31 requests per second
HMGET (10 fields): 38998.52 requests per second
HGETALL: 109059.58 requests per second
ZADD: 120583.62 requests per second
ZREM: 161689.33 requests per second
PFADD: 6153.47 requests per second
PFCOUNT: 28312.57 requests per second
PFADD (needed to benchmark PFMERGE): 6166.37 requests per second
PFMERGE: 6007.09 requests per second
```
* ##### Conclusion
Overall performance is excellent, but some commands exhibit weaker performance (LRANGE, PFADD, PFMERGE).
#### 3.4 Case 4
* ##### Test Objective
Compare the maximum QPS between PikiwiDB and Redis.
* ##### Test Conditions
* PikiwiDB Worker Thread Count: 20
* Number of Keys: 10,000
* Number of Fields: 100 (excluding lists)
* Value: 128 bytes
* Number of Command Executions: 10 million (except for LRANGE)
* Redis Version: 3.2.0
* ##### Test Result
## Observability
### Metrics
1. PikiwiDB Server Info: system, ip, port, run_id, config file etc.
2. PikiwiDB Data Info: db size, log size, memory usage etc.
3. PikiwiDB Client Info: The number of connected clients.
4. PikiwiDB Stats Info: status information of compact, slot, etc.
5. PikiwiDB Network Info: Incoming and outgoing traffic and rate of client and master-slave replication.
6. PikiwiDB CPU Info: cpu usage.
7. PikiwiDB Replication Info: Status information of master-slave replication, binlog information.
8. PikiwiDB Keyspace Info: key information of five data types.
9. PikiwiDB Command Exec Count Info: command execution count.
10. PikiwiDB Command Execution Time: Time-consuming command execution.
11. RocksDB Metrics: RocksDB information of five data types, includes Memtable, Block Cache, Compaction, SST File, Blob File etc.
More details on [Metrics](tools/pika_exporter/README.md).
## Documents
* [wiki](https://github.com/OpenAtomFoundation/pika/wiki)
* release notes
- [What's new in PikiwiDB v3.5.2](https://my.oschina.net/dubbogo/blog/10315913)
- [What's new in PikiwiDB v3.5.1](https://my.oschina.net/dubbogo/blog/10114890)
- [What's new in PikiwiDB v3.5.0](https://mp.weixin.qq.com/s/NNnmd0RtQ-vx9arW9YBcBA)
## Contact Us

* [Slack Channel](https://join.slack.com/t/w1687838400-twm937235/shared_invite/zt-1y72dch5d-~9CuERHYUSmfeJZh32Z~qQ)