8000 A heavy command (KEYS, DEL of a big key) stalls every other connection despite worker threads · Issue #754 · kividbio/kividb · GitHub
[go: up one dir, main page]

Skip to content

A heavy command (KEYS, DEL of a big key) stalls every other connection despite worker threads #754

Closed

Description

@murtazayusuf

Summary

A heavy command on one connection makes every other connection wait for it to finish, even though KiviDB runs 6 worker threads. KEYS over 2M keys takes 148 ms, and a probe client's PING on a separate connection waits 140 ms. Deleting a 3M-field hash takes 116 ms; the probe waits 115 ms. KiviDB is faster than Redis on both commands, but it stalls other clients the same way. This was repeatable in every run, so it isn't the probe sharing a worker thread by chance (with 6 threads, that would happen about 1 time in 6).

The most common complaint we found across GitHub Redis-slowness issues is exactly this: one heavy command freezes everyone. That's the pain a multi-threaded Redis-compatible server is best placed to remove.

Numbers (2 fresh runs each)

Redis 8.10.3: command / other client's worst PING KiviDB 1.2.2: command / other client's worst PING
KEYS user:99* over 2M keys (11,111 matches) 235–236 ms / 226–227 ms 148 ms / 140 ms
DEL of a 3M-field hash 232–236 ms / 231–235 ms 116 ms / 115 ms

Repro

Load 2M keys user:N, then run KEYS user:99* while another connection PINGs every 1 ms. Record that connection's worst latency.

Real-world cases (each is one heavy command freezing everyone)

Questions

  • What does KEYS (and a big DEL) hold that a PING on another connection needs: a global lock, every shard's lock, or a barrier? PING touches no data.
  • Could keyspace-wide reads walk the shards one at a time, releasing each, and could freeing a large value move to a background thread (Redis's lazyfree)?

Environment

  • KiviDB 1.2.2 (kividb/kividb:v1.2.2, prebuilt image, default settings plus --port 6379 --protected-mode no) vs Redis 8.10.3 (redis:8, --save "" --appendonly no, default single-threaded I/O).
  • One server at a time on the same host: AWS CodeBuild, 8 vCPU, 15 GB, linux x86_64, Docker. The client is Python 3.12 with redis-py 5.2.1 in a container on the same host. Each server is started fresh for each run.
  • The snippets above are the relevant parts of the harness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0