Giter VIP home page Giter VIP logo

tidis's Introduction

Tidis

CI EN doc CN doc

Tidis is the service layer for TiKV, aims to provide redis protocol compatiable distributed storage service powered by PingCAP. Redis protocol has been implemented with multiple datatypes (string/hash/list/set/sortedset) support.

Tidis has been completely redesigned and rewritten in Rust for better performance and lower latency, and added more important features, such as Lua scripts, TLS connections, lock optimization and more.

Background

Redis is an in-memory data structure store, used by lots of companies and projects. It is a very good solution for caching and storing data. But it has some limitations:

  • High cost of memory, not suitable for store huge amounts of data
  • Not easy to manage, and not easy to scale out with huge datasets
  • Lots of use cases are relying on protocol and api, not the extreme performance
  • No global transaction support
  • No data persistence guarantee

We believe it is a good idea to build a redis compatiable distributed storage service based on lower cost storage medium. Further more, there are popular products built with this idea, such as ssdb, pika, kvrocks and so on. But they are all compute storage aggregated architechture, which means it's very complex and complicated to build the basic ability of storage replication, high availability, data sharding, data scaling and so on. Not only it is difficult to implement, but also complicated to operate in production.

Considering the complexities, we take a different approach and build a lite computing service layer on top of TiKV, a distributed storage system based on Raft consensus algorithm. TiKV is an excellent building block for storage systems, it has a lot of features such as high availability, data sharding, data scaling, global transaction and so on. We just work on the data model and computation which is also known as the service layer.

Of course we are not the only ones who have similar ideas. Both Titan and Tidis 1.0 were designed with similar architecture, and they were all popular back to early days and grew their community to some extent. Unfortunately, there are many useful features not implemented by either of them. We believe the community is always looking forward to seeing alternative projects that are more feature complete. Therefore we decided to take over what Tidis 1.0 left behind, redesign and implement the next generation of Tidis with some important yet missing features added, such as Lua script, TLS/SSL, lock optimization, one phase commit, asynchronous commit and many other improvements.

Features

  • Multiple protocols support
  • Linear scale-out
  • Storage and compute disaggregation
  • Highly durable and available with strong consistency
  • Global transaction support

Architecture

Architechture of Tidis

architecture

Architechture of TiKV

  • Placement Driver (PD): PD is the brain of the TiKV system which manages the metadata about Nodes, Stores, Regions mapping, and makes decisions for data placement and load balancing. PD periodically checks replication constraints to balance load and data automatically.
  • Node: A physical node in the cluster. Within each node, there are one or more Stores. Within each Store, there are many Regions.
  • Store: There is a RocksDB within each Store and it stores data in local disks.
  • Region: Region is the basic unit of Key-Value data movement and corresponds to a data range in a Store. Each Region is replicated to multiple Nodes. These multiple replicas form a Raft group. A replica of a Region is called a Peer.

Running

  • Start PD, TiKV and one TiDB (for trigger GC) using TiUP, you can follow the official instructions English or 中文.

  • Build the Tidis server

make release
  • Start the Tidis server
tidis-server --config config.toml

You can use the demo configuration below.

[server]
listen = "0.0.0.0"
port = 6379                               # disable tcp port if set to 0
tls_listen = "0.0.0.0"
tls_port = 6443                           # disable tls if tls_port set to 0
tls_key_file = ""                         # disable tls if key or cert file not set
tls_cert_file = ""
tls_auth_client = false                   # tls_ca_cert_file must be specified if tls_auth_client is true
tls_ca_cert_file = "path/ca.crt"
pd_addrs = "127.0.0.1:2379"               # PD addresses of the TiKV cluster
instance_id = "1"                         # instance_id can be used as tenant identifier
prometheus_listen = "0.0.0.0"
prometheus_port = 8080
log_level = "info"
log_file = "tidis.log"

[backend]
use_txn_api = true                        # use transaction api for full api supported
use_async_commit = true                   # try to use async commit in tikv
try_one_pc_commit = true                  # try to use one pc commit
use_pessimistic_txn = true                # use optimistic transaction mode
local_pool_number = 4                     # localset pool number for handle connections
txn_retry_count = 10                      # transaction retry count
txn_region_backoff_delay_ms = 2           # transaction region error backoff base delay time
txn_region_backoff_delay_attemps = 2      # transaction region error backoff retry max attempts
txn_lock_backoff_delay_ms = 2             # transaction lock error backoff base delay time
txn_lock_backoff_delay_attemps = 5        # transaction lock error backoff retry max attempts
  • Run clients

For the redis protocol, you can use the official redis clients, such as redis-cli.

redis-cli -p 6379
tidis> SET mykey "Hello"
"OK"
tidis> GET mykey
"Hello"
tidis> EXPIRE mykey 10
(integer) 1
# 10 seconds later
tidis> GET mykey
(nil)
tidis> RPUSH mylist "one"
(integer) 1
tidis> RPUSH mylist "two"
(integer) 2
tidis> RPUSH mylist "three"
(integer) 3
tidis> LRANGE mylist 0 0
1) "one"
tidis> LRANGE mylist -3 2
1) "one"
2) "two"
3) "three"
tidis> LRANGE mylist -100 100
1) "one"
2) "two"
3) "three"
tidis> LRANGE mylist 5 10
(nil)
tidis> ZADD myzset 1 "one"
(integer) 1
tidis> ZADD myzset 2 "two"
(integer) 1
tidis> ZADD myzset 3 "three"
(integer) 1
tidis> ZREMRANGEBYSCORE myzset 0 1
(integer) 1
tidis> ZRANGE myzset 0 5 WITHSCORES
1) "two"
2) "2"
3) "three"
4) "3"

Supported commands

Keys

+-----------+-------------------------------------+
|  pexpire  | pexpire key int                     |
+-----------+-------------------------------------+
| pexpireat | pexpireat key timestamp(ms)         |
+-----------+-------------------------------------+
|   expire  | expire key int                      |
+-----------+-------------------------------------+
|  expireat | expireat key timestamp(s)           |
+-----------+-------------------------------------+
|    pttl   | pttl key                            |
+-----------+-------------------------------------+
|    ttl    | ttl key                             |
+-----------+-------------------------------------+
|    type   | type key                            |
+-----------+-------------------------------------+
|    scan   | scan "" [count 10] [match "^pre*"]  |
+-----------+-------------------------------------+
|    ping   | ping                                |
+-----------+-------------------------------------+

String

+-----------+-------------------------------------+
|  command  |               format                |
+-----------+-------------------------------------+
|    get    | get key                             |
+-----------+-------------------------------------+
|    set    | set key value [EX sec|PX ms][NX|XX] | 
+-----------+-------------------------------------+
|    del    | del key1 key2 ...                   |
+-----------+-------------------------------------+
|    mget   | mget key1 key2 ...                  |
+-----------+-------------------------------------+
|    mset   | mset key1 value1 key2 value2 ...    |
+-----------+-------------------------------------+
|    incr   | incr key                            |
+-----------+-------------------------------------+
|   incrby  | incr key step                       |
+-----------+-------------------------------------+
|    decr   | decr key                            |
+-----------+-------------------------------------+
|   decrby  | decrby key step                     |
+-----------+-------------------------------------+
|   strlen  | strlen key                          |
+-----------+-------------------------------------+

Hash

+------------+------------------------------------------+
|  Commands  | Format                                   |
+------------+------------------------------------------+
|    hget    | hget key field                           |
+------------+------------------------------------------+
|   hstrlen  | hstrlen key field                        |
+------------+------------------------------------------+
|   hexists  | hexists key field                        |
+------------+------------------------------------------+
|    hlen    | hlen key                                 |
+------------+------------------------------------------+
|    hmget   | hmget key field1 field2 field3...        |
+------------+------------------------------------------+
|    hdel    | hdel key field1 field2 field3...         |
+------------+------------------------------------------+
|    hset    | hset key field value                     |
+------------+------------------------------------------+
|   hsetnx   | hsetnx key field value                   |
+------------+------------------------------------------+
|    hmset   | hmset key field1 value1 field2 value2... |
+------------+------------------------------------------+
|    hkeys   | hkeys key                                |
+------------+------------------------------------------+
|    hvals   | hvals key                                |
+------------+------------------------------------------+
|   hgetall  | hgetall key                              |
+------------+------------------------------------------+
|   hincrby  | hincrby key step                         |
+------------+------------------------------------------+

List

+------------+---------------------------------------------+
|  commands  |         format                              |
+------------+---------------------------------------------+
|    lpop    | lpop key                                    |
+------------+---------------------------------------------+
|    rpush   | rpush key  item                             |
+------------+---------------------------------------------+
|    lpush   | lpush key  item                             |
+------------+---------------------------------------------+
|    rpop    | rpop key                                    |
+------------+---------------------------------------------+
|    llen    | llen key                                    |
+------------+---------------------------------------------+
|   lindex   | lindex key index                            |
+------------+---------------------------------------------+
|   lrange   | lrange key start stop                       |
+------------+---------------------------------------------+
|    lset    | lset key index value                        |
+------------+---------------------------------------------+
|    ltrim   | ltrim key start stop                        |
+------------+---------------------------------------------+
|   linsert  | linsert key <BEFORE | AFTER> pivot element  |
+------------+---------------------------------------------+

Set

+-------------+-------------------------------------+
|   commands  |             format                  |
+-------------+-------------------------------------+
|     sadd    | sadd key member1 [member2 ...]      |
+-------------+-------------------------------------+
|    scard    | scard key                           |
+-------------+-------------------------------------+
|  sismember  | sismember key member                |
+-------------+-------------------------------------+
|  smismember | smismember key member [member2 ...] |
+-------------+-------------------------------------+
|   smembers  | smembers key                        |
+-------------+-------------------------------------+
|     srem    | srem key member                     |
+-------------+-------------------------------------+
|     spop    | spop key [count]                    |
+-------------+-------------------------------------+
| srandmember | spop key [count]                    |
+-------------+-------------------------------------+

Sorted set

+------------------+---------------------------------------------------------------+
|     commands     |                             format                            |
+------------------+---------------------------------------------------------------+
|       zadd       | zadd key member1 score1 [member2 score2 ...]                  |
+------------------+---------------------------------------------------------------+
|       zcard      | zcard key                                                     |
+------------------+---------------------------------------------------------------+
|      zrange      | zrange key start stop [WITHSCORES]                            |
+------------------+---------------------------------------------------------------+
|     zrevrange    | zrevrange key start stop [WITHSCORES]                         |
+------------------+---------------------------------------------------------------+
|   zrangebyscore  | zrangebyscore key min max [WITHSCORES][LIMIT offset count]    |
+------------------+---------------------------------------------------------------+
| zrevrangebyscore | zrevrangebyscore key max min [WITHSCORES][LIMIT offset count] |
+------------------+---------------------------------------------------------------+
| zremrangebyscore | zremrangebyscore key min max                                  |
+------------------+---------------------------------------------------------------+
| zremrangebyrank  | zremrangebyscore key start stop                               |
+------------------+---------------------------------------------------------------+
|      zcount      | zcount key                                                    |
+------------------+---------------------------------------------------------------+
|      zscore      | zscore key member                                             |
+------------------+---------------------------------------------------------------+
|      zrank       | zrank key member                                              |
+------------------+---------------------------------------------------------------+
|       zrem       | zrem key member1 [member2 ...]                                |
+------------------+---------------------------------------------------------------+
|      zpopmin     | zpopmin key [count]                                           |
+------------------+---------------------------------------------------------------+
|      zpopmax     | zpopmax key [count]                                           |
+------------------+---------------------------------------------------------------+
|      zincrby     | zincrby key increment member                                  |
+------------------+---------------------------------------------------------------+

Lua

+-------------+-----------------------------------------------------+
|   commands  |             format                                  |
+-------------+-----------------------------------------------------+
|     eval    | eval script numkeys [key [key ...]] [arg [arg ...]] |
+-------------+-----------------------------------------------------+
|    evalsha  | evalsha sha1 numkeys [key [key ...]] [arg [arg ...]]|
+-------------+-----------------------------------------------------+
| script load | script load script                                  |
+-------------+-----------------------------------------------------+
| script flush| script flush                                        |
+-------------+-----------------------------------------------------+
|script exists| script exists sha1 [sha1 ...]                       |
+-------------+-----------------------------------------------------+

Security

+-------------+----------------------+
|   commands  |      format          |
+-------------+----------------------+
|    auth     | auth password        |
+-------------+----------------------+

Debug

+-------------+----------------------+
|   commands  |      format          |
+-------------+----------------------+
|    debug    | debug profiler_start |
+-------------+----------------------+
|    debug    | debug profiler_stop  |
+-------------+----------------------+

Cluster

+-----------------+------------+
|   command       |    support |
+-----------------+------------+
|  cluster nodes  |    Yes     |
+-----------------+------------+
|  cluster info   |    Yes     |
+-----------------+------------+

Transaction

+---------+---------+
| command | support |
+---------+---------+
|  multi  | Yes     |
+---------+---------+
|   exec  | Yes     |
+---------+---------+
| discard | Yes     |
+---------+---------+

Client Management

+-----------------+------------+
|   command       |    support |
+-----------------+------------+
|  client setname |    Yes     |
+-----------------+------------+
|  client getname |    Yes     |
+-----------------+------------+
|  client id      |    Yes     |
+-----------------+------------+
|  client list    |    Yes     |
+-----------------+------------+
|  client kill    |    Yes     |
+-----------------+------------+

Run E2E tests

You can run complete sets of all supported commands using the tools provided in the repo test directory, just run

python3 test_helper.py [--ip ip] [--port 6379]

TLS/SSL support

TLS/SSL encryption is necessary for security, especially in public access environment, such as providing cloud services in AWS, GCP or Azure cloud.

Tidis support one-way and two-way TLS authentication handshake. In one-way authentication, you can use the ca certificate and password for security transport and authenticate. If you choose two-way authentication, it is safe using ca certificate with client-side key and certificate without password.

1. Generate tls certs and key for test

#!/bin/bash

# Generate some test certificates which are used by the regression test suite:
#
#   tests/tls/ca.{crt,key}          Self signed CA certificate.
#   tests/tls/redis.{crt,key}       A certificate with no key usage/policy restrictions.
#   tests/tls/client.{crt,key}      A certificate restricted for SSL client usage.
#   tests/tls/server.{crt,key}      A certificate restricted for SSL server usage.

generate_cert() {
    local name=$1
    local cn="$2"
    local opts="$3"

    local keyfile=tests/tls/${name}.key
    local certfile=tests/tls/${name}.crt

    [ -f $keyfile ] || openssl genrsa -out $keyfile 2048
    openssl req \
        -new -sha256 \
        -subj "/O=Redis Test/CN=$cn" \
        -key $keyfile | \
        openssl x509 \
            -req -sha256 \
            -CA tests/tls/ca.crt \
            -CAkey tests/tls/ca.key \
            -CAserial tests/tls/ca.txt \
            -CAcreateserial \
            -days 365 \
            $opts \
            -out $certfile
}

mkdir -p tests/tls
[ -f tests/tls/ca.key ] || openssl genrsa -out tests/tls/ca.key 4096
openssl req \
    -x509 -new -nodes -sha256 \
    -key tests/tls/ca.key \
    -days 3650 \
    -subj '/O=Redis Test/CN=Certificate Authority' \
    -out tests/tls/ca.crt

cat > tests/tls/openssl.cnf <<_END_
[ server_cert ]
keyUsage = digitalSignature, keyEncipherment
nsCertType = server

[ client_cert ]
keyUsage = digitalSignature, keyEncipherment
nsCertType = client
_END_

generate_cert server "Server-only" "-extfile tests/tls/openssl.cnf -extensions server_cert"
generate_cert client "Client-only" "-extfile tests/tls/openssl.cnf -extensions client_cert"
generate_cert redis "Generic-cert"

2. Server and client config

  • Server-side
tls_listen = "0.0.0.0"
tls_port = 6443
tls_key_file = "path/server.key"
tls_cert_file = "path/server.crt"
tls_auth_client = false           # tls_ca_cert_file must be specified if tls_auth_client is true
tls_ca_cert_file = "path/ca.crt"
  • Client-side

tls_auth_client is false, client just use root ca certificate

./src/redis-cli --tls --cacert ./tests/tls/ca.crt

tls_auth_client is true, client must be configure certs and key file for client auth in server side

./src/redis-cli --tls  --cert ./tests/tls/client.crt --key ./tests/tls/client.key --cacert ./tests/tls/ca.crt

Global transaction

Thanks to the global transaction mechanism in TiKV cluster, Tidis can support global transaction easily. Use MULTI/EXEC/DISCARD command just like Redis Cluster but without caring about the CROSSSLOT error, just use it like a single Redis instance.

In Tidis, there are two kinds of transaction models, optimistic and pessimistic models.

Pessimistic transaction is prefered when you have many concurrent writes to limited hot keys. Otherwise, you should use optimistic transaction instead for better performance.

You can refer to the documents in TiDB optimistic transaction and pessimistic transaction.

In addition, the 1pc and async commit options are helpful for better performance in most use cases. You can refer to the documents in PingCAP blog AsyncCommit, the Accelerator for Transaction Commit in TiDB 5.0 for details.

Lua Script

Tidis use mlua library to interpret lua scripts. We can use EVAL/EVALSHA to execute lua script with global transaction support, without caring about the CROSSSLOT error either.

The lua script will be running in a new transaction context, so all read and writes in the lua script are guaranteed to be atomic.

All lua script e2e test cases are located in test/test_lua.py.

Asynchronous key deletion

For collection keys with thousands of items, deletion can be a time-consuming operation, enable the async deletion configuration could greatly reduce the operation time.

The big key deletion task will run in background and response to user immediately without waiting for the background task's completion. We maintain multiple versions of the same key if the old version has been deleted in asynchronous way. If there are pending deletes with old versions, next new version of the key will be monotonic increase from the largest version of the key. Otherwise, the new version will start from 0.

For big keys with thousands of elements deletion, the time spent decrease from seconds to milliseconds.

type hash list set sorted set
sync deletion 1.911778 s 2.047429 s 2.145035 s 4.892823 s
async deletion 0.005159 s 0.004694 s 0.005370 s 0.005403 s

Super batch support

Enable super batch could have significant performance benefits, and you can tune it based on your real workload.

Super batch is a feature that can reduce the number of request round-trips to TiKV. It is enabled by default, and can be disabled by setting to allow_batch=false in the configuration file. There are more configuration options available for advanced tuning. max_batch_wait_time is the maximum waiting time for a batch, and max_batch_size is the maximum number of keys in one batch. overload_threshold is the threshold of the backend TiKV server's load, if the load is higher than this value, the batch request will be sent immediately.

You can tune the parameters according to your workload. In the following test, we set max_batch_wait_time to 10ms, overload_threshold to 0, and max_batch_size varies. The test result shows that the throughput increases 50% and p999 latency decreases 40% with max_batch_size=20.

Performance

The topology of cluster to run benchmark has 3 TiKV nodes, 3 Tidis nodes, 1 PD node and 1 TiDB node (for gc). We benchmark the cluster using multiple memtier-benchmark processes, with various number of parallel connections. The benchmark result shows the max read and write throughput are 540k ops/s and 125k op/s respectively.

The latency distribution shows that the latency will increase when the cluster load reaches to a certain limit. The p9999 latency increased significantly with 1200 concurrent connections, up to 47ms.

We also compared the benchmark result with other similar Redis on TiKV projects (Titan and Tidis 1.0), the result shows that Tidis has better write throughput than Titan and Tidis 1.0.

The write thoughput of Tidis is almost twice of Titan and Tidis 1.0 and the latency are the best all the time.

See more Benchmark details here.

License

Tidis is under the Apache-2.0 license. See the LICENSE file for details.

Acknowledgment

tidis's People

Contributors

blacktear23 avatar carllerche avatar everlastingbugstopper avatar iosmanthus avatar morgan279 avatar praying avatar sunxiaoguang avatar weedge avatar yongman avatar zoubingwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tidis's Issues

tikv client error

Hi. I'm running tikv with the following command:

tiup playground v8.0.0 --mode tikv-slim

my tidis is clone of master branch and I've build it with the command make release

I'm running tidis with the config bellow:

[server]
listen = "0.0.0.0"
port = 6380                               # disable tcp port if set to 0
tls_listen = "0.0.0.0"
tls_port = 0                            # disable tls if tls_port set to 0
tls_key_file = ""                         # disable tls if key or cert file not set
tls_cert_file = ""
tls_auth_client = false                   # tls_ca_cert_file must be specified if tls_auth_client is true
pd_addrs = "127.0.0.1:2379"               # PD addresses of the TiKV cluster
instance_id = "1"                         # instance_id can be used as tenant identifier
# prometheus_listen = "0.0.0.0"
# prometheus_port = 8080
log_level = "info"
log_file = "tidis.log"

[backend]
use_txn_api = true                        # use transaction api for full api supported
use_async_commit = true                   # try to use async commit in tikv
try_one_pc_commit = true                  # try to use one pc commit
use_pessimistic_txn = true                # use optimistic transaction mode
local_pool_number = 4                     # localset pool number for handle connections
txn_retry_count = 10                      # transaction retry count
txn_region_backoff_delay_ms = 2           # transaction region error backoff base delay time
txn_region_backoff_delay_attemps = 2      # transaction region error backoff retry max attempts
txn_lock_backoff_delay_ms = 2             # transaction lock error backoff base delay time
txn_lock_backoff_delay_attemps = 5        # transaction lock error backoff retry max attempts

However, when I connect to tidis with redis-cli and I run some simple commands I get the following error:

2024/03/22 04:17:29.977 +03:30 ERRO error occured so rollback transaction: PessimisticLock error: MultipleKeyErrors([KeyError(KeyError { locked: None, retryable: "", abort: "Error(ApiVersionNotMatched { cmd: prewrite, storage_api_version: V1ttl, req_api_version: V1 })", conflict: None, already_exist: None, deadlock: None, commit_ts_expired: None, txn_not_found: None, commit_ts_too_large: None, assertion_failed: None })])

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', src/config.rs:17:18

Config { server: Server { listen: Some("0.0.0.0"), port: Some(6666), tls_listen: Some("0.0.0.0"), tls_port: Some(6443), tls_key_file: Some(""), tls_cert_file: Some(""), tls_auth_client: Some(false), tls_ca_cert_file: Some(""), pd_addrs: Some("basic-pd:2379"), instance_id: Some("1"), prometheus_listen: Some("0.0.0.0"), prometheus_port: Some(8080), password: None, log_level: Some("info"), log_file: Some("tikv-service.log"), cluster_broadcast_addr: None, cluster_topology_interval: None, cluster_topology_expire: None, meta_key_number: None }, backend: Backend { timeout: None, ca_file: None, cert_file: None, key_file: None, conn_concurrency: None, use_txn_api: None, use_async_commit: Some(true), try_one_pc_commit: Some(true), use_pessimistic_txn: Some(false), local_pool_number: Some(8), completion_queue_size: Some(1), grpc_keepalive_time: Some(10000), grpc_keepalive_timeout: Some(2000), allow_batch: Some(true), overload_threshold: None, max_batch_wait_time: Some(10), max_batch_size: Some(20), max_inflight_requests: Some(10000), txn_retry_count: Some(2), txn_region_backoff_delay_ms: Some(2), txn_region_backoff_delay_attemps: Some(5), txn_lock_backoff_delay_ms: Some(2), txn_lock_backoff_delay_attemps: Some(5), cmd_lrem_length_limit: None, cmd_linsert_length_limit: None, async_deletion_enabled: None, async_gc_worker_number: None, async_gc_worker_queue_size: None, async_gc_interval: None, async_del_list_threshold: None, async_del_hash_threshold: None, async_del_set_threshold: None, async_del_zset_threshold: None, async_expire_list_threshold: None, async_expire_hash_threshold: None, async_expire_set_threshold: None, async_expire_zset_threshold: None } }
thread 'main' panicked at 'called Result::unwrap() on an Err value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', src/config.rs:17:18
stack backtrace:
0: 0x5641a28bfe85 - std::backtrace_rs::backtrace::libunwind::trace::hc5f0e1506f4edb39
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
1: 0x5641a28bfe85 - std::backtrace_rs::backtrace::trace_unsynchronized::h53b1c5dc3c06560b
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x5641a28bfe85 - std::sys_common::backtrace::_print_fmt::h1a7d5f48906eae70
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/sys_common/backtrace.rs:66:5
3: 0x5641a28bfe85 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed9a08d0af811fa5
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/sys_common/backtrace.rs:45:22
4: 0x5641a25c12bc - core::fmt::write::h574d7e8060e08389
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/core/src/fmt/mod.rs:1198:17
5: 0x5641a28ba875 - std::io::Write::write_fmt::h3266c77374172c32
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/io/mod.rs:1672:15
6: 0x5641a28c15e1 - std::sys_common::backtrace::_print::h745319fa404abc88
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/sys_common/backtrace.rs:48:5
7: 0x5641a28c15e1 - std::sys_common::backtrace::print::h42f1b482778349d6
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/sys_common/backtrace.rs:35:9
8: 0x5641a28c15e1 - std::panicking::default_hook::{{closure}}::hf42ee92d109b18cd
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:295:22
9: 0x5641a28c12e2 - std::panicking::default_hook::heb8c1646fafa37cf
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:314:9
10: 0x5641a28c1c05 - std::panicking::rust_panic_with_hook::h92fcad6ddbd25f63
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:698:17
11: 0x5641a28c1b04 - std::panicking::begin_panic_handler::{{closure}}::hf30199cc9cd78007
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:588:13
12: 0x5641a28c0404 - std::sys_common::backtrace::__rust_end_short_backtrace::h98e4e812e85c2d18
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/sys_common/backtrace.rs:138:18
13: 0x5641a28c1862 - rust_begin_unwind
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:584:5
14: 0x5641a2131933 - core::panicking::panic_fmt::h1627e39d69366ab1
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/core/src/panicking.rs:142:14
15: 0x5641a2131a83 - core::result::unwrap_failed::h2204b6a125c3a2d0
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/core/src/result.rs:1814:5
16: 0x5641a29113f8 - std::sync::once::Once::call_once::{{closure}}::h49b5f817f97d7bf1
17: 0x5641a2145857 - std::sync::once::Once::call_inner::h74c7da7f2846c57d
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/sync/once.rs:434:21
18: 0x5641a24506fd - tidis_server::main::{{closure}}::hbb9ccba715ebdc04
19: 0x5641a2458e7b - std::thread::local::LocalKey::with::h8862b2e7b4b48003
20: 0x5641a2501198 - tokio::park::thread::CachedParkThread::block_on::hba951e378d918c40
21: 0x5641a2460abf - tokio::runtime::thread_pool::ThreadPool::block_on::h8fb9eebe21f032d6
22: 0x5641a2173ac8 - tokio::runtime::Runtime::block_on::ha69bceff291e9731
23: 0x5641a21e3654 - tidis_server::main::h43630419fa303ff1
24: 0x5641a2173be3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0960f520f1deb7f5
25: 0x5641a21ea539 - std::rt::lang_start::{{closure}}::hc47d23f927dc6187
26: 0x5641a28b67ff - core::ops::function::impls::<impl core::ops::function::FnOnce for &F>::call_once::hf7c3141f4fac8a1d
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/core/src/ops/function.rs:280:13
27: 0x5641a28b67ff - std::panicking::try::do_call::hee900854d655c1eb
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:492:40
28: 0x5641a28b67ff - std::panicking::try::h81f99697b06ffa19
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:456:19
29: 0x5641a28b67ff - std::panic::catch_unwind::h456424d2b65bbb47
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panic.rs:137:14
30: 0x5641a28b67ff - std::rt::lang_start_internal::{{closure}}::hfc1ba9f6ec042223
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/rt.rs:128:48
31: 0x5641a28b67ff - std::panicking::try::do_call::hb3cd0ad13902daaf
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:492:40
32: 0x5641a28b67ff - std::panicking::try::ha823b8c8b15583c8
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panicking.rs:456:19
33: 0x5641a28b67ff - std::panic::catch_unwind::h7b4f4c25642b0e7a
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/panic.rs:137:14
34: 0x5641a28b67ff - std::rt::lang_start_internal::he1611cbb74772eca
at /rustc/4d6d601c8a83284d6b23c253a3e2a060fd197316/library/std/src/rt.rs:128:20
35: 0x5641a21e5ce2 - main
36: 0x7fe064c493d5 - __libc_start_main
37: 0x5641a2170077 -

Which version of tikv is recommended to use?

I would like to know which version of tikv the performance test was run on.

For my tests, I used tikv 5.3.0 but found that after writing a lot of data, the store size remained around 10GB and didn't grow anymore.
Therefore, I suspect that tidis will not work well on tikv 5.3.0.

Is there an active expiration for ttl other than the lazy expiration in Tidis ?

I am trying to understand how Tidis implements redis protocol. I known that an get command for a string will check its ttl and delete it if expired, but what if a key has outlived its ttl and is never accessed after it's set ?
In other Redis alike products, like Tendis, will use rocksdb's compaction filter to delete those keys in compaction, or launch a background thread to periodically scan those expired keys and delete them.
I do notice that the Db set() method would use a BTreeMap to track keys with ttl, but I don't see there is any releationship between the Db set method and the ttl releated commands such as expire or setex, it seems that the latter would directly write kv into TiKV without using any TiKV's ttl interface ? Besides, the set() method of Db is marked as dead_code and is written in 3 years ago, I assume that is the legacy code from Tidis 1.0 ?
So is the lazy expiration the only way to delete expired keys in Tidis or am I missing anything ?

8-RESOURCE_EXHAUSTED, message: "Received message larger than max (9612720 vs. 4194304)

Based on 3 TiKV nodes + 3 PD nodes, I deployed 1 Tidis node, and the part of config.toml

[server]
pd_addrs = "172.26.9.81:2379,172.26.9.82:2379,172.26.9.83:2379"
instance_id = "1"
prometheus_listen = "0.0.0.0"
prometheus_port = 8080
log_level = "info"
log_file = "tikv-service.log"

After some writing (Redis) sorted set, I got some error message in tikv-service.log:

2023/01/04 12:54:40.182 +08:00 ERRO error occured so rollback transaction: gRPC error: RpcFailure: 8-RESOURCE_EXHAUSTED Received message larger than max (9612720 vs. 4194304)
2023/01/04 12:54:40.183 +08:00 ERRO connection error TikvClient(Grpc(RpcFailure(RpcStatus { code: 8-RESOURCE_EXHAUSTED, message: "Received message larger than max (9612720 vs. 4194304)", details: [] })))
2023/01/04 12:54:44.090 +08:00 ERRO error occured so rollback transaction: gRPC error: RpcFailure: 8-RESOURCE_EXHAUSTED Received message larger than max (9723284 vs. 4194304)

distributed deployment

does tidis support distributed deployment? only one tidis instance for tikv??? or support cluster mode?

Create dockerfile for reproducible build

tikv-service depends on grpcio, which depends on lots of deps like cmake, perl, protobuf. It will blow up users' mind if they are the first time to try to build the tikv-service. We may need a dockerfile to make it reproducible in docker.

set command can overwrite data structure of hash

May be this is a bug.

How to reporduce the test:
image

Diving into the code, can see that string and hash meta key has the same key format.
For the set command, may be it need to check if there is a existing key ?
image
image

Questions about the result of performance test

This is the performace detail I have read, https://github.com/tidb-incubator/tidis/blob/master/docs/performance.md

Yet, I have some questions about the test result.

  1. What is the data structure that described by "read" and "write"?
    As we all known, for hset and set command the performance should be different a lot. String structure may have a good performance than hash because it need few api to call. For my test result, set command have 2x performance to hset command.
  2. What is the data size ?
    The test do not clearify the data size that read or write. 1000 bytes and 100bytes data size should have different test result on write command.
  3. What is the resource usage on a given test case?
    This question may be a little hard to answer. I mean we should know the bottleneck on a given test case.

Tidis performance comparison

Hello ,

Have we ever done Tidis performance comparison with Redis ? Or with MYSQL ?

If Yes, can you share the same? If not, may be we should do it?

Would be interesting to see the results.

Thanks.

is this production ready?

the word "incubator" in tidb "incubator" is not very reassuring.

  1. can i use tidis in production?
  2. anyone using tidis as user case studies?

@yongman will u be supporting this repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.