Distributed, high-performance blob storage on SQLite zerodha.tech · 40 points · ...

@best

Distributed, high-performance blob storage on SQLite zerodha.tech · 40 points · 5 comments · HN thread

TL;DR Zerodha describes Blobasaur, an open-source sharded, distributed blob storage server written in Rust that speaks the Redis protocol and uses SQLite as its storage engine. It replaced their unmaintained SSDB store for Kite's user UI preferences and workspace JSON blobs, which range from a few KB to several MB, and reports thousands of ops per second at single-digit millisecond p99 latency.

  • Kite's user layouts, indicator templates and workspace settings are stored as mostly JSON blobs; SSDB was unmaintained, written in C++ outside their stack, and single-node, which forced a 1 MB size cap.
  • Of the alternatives they tested (ScyllaDB, PostgreSQL BYTEA, YugabyteDB, RocksDB, Ceph, SeaweedFS, S3/MinIO, raw files), each was rejected for large-blob throughput, overwrite-driven disk growth, cost or operational complexity.
  • Architecture: keys hash via CRC16 into 16384 slots across nodes (Redis Cluster protocol), then multi-probe consistent hashing picks one of several SQLite shards per node, each with a group-commit writer and a pool of read connections.
  • In a 16-core laptop benchmark with 64 KiB payloads, 16 shards raised HSET throughput from 7,740 to 25,324 ops/s; zstd compression cut average stored size from 63.6 KiB to 5.5 KiB.
  • Durability is deliberately relaxed (WAL with synchronous=NORMAL), since losing a recent chart tweak is acceptable but trading data is not; a three-node 4 vCPU cluster reports p99 around 2 ms during a trading session.
  • Migration was phased: new Terminal mode workloads first, then dual-writes to SSDB and Blobasaur for a month with zero discrepancies before cutover. Known gaps include no live slot rebalancing and no automatic failover.

Discussion The thread is small and mostly questions rather than debate. One commenter asks about replication and fault tolerance, since the post and repository do not mention it, and another replies that the only backup found uses cp, suggesting Litestream or snapshots might be in use. A second top-level thread proposes modelling blobs as relational schemas instead of JSON, and a short sub-thread suggests database-per-user designs, with a question about whether plain SQLite would then suffice. Overall tone is curious and skeptical rather than hostile.

  • Fault tolerance and replication are the key open question (some): Commenters note the post does not mention replication, and the README-level backup appears to be a plain cp. They ask how durability across nodes is actually handled, pointing out that the article only lists static slot assignment and no automatic failover.
  • Store JSON as relational schema instead of blobs (a few): One commenter argues that representing each blob type's schema in SQL, with one SQLite database per type plus a metadata database, would avoid much storage IO and garbage collection for incremental updates. They suggest AI tools could generate such schemas.
  • Database-per-user design would simplify this (a few): A commenter suggests a database per user fits the workload. Another replies that if so, plain SQLite might be enough without the custom sharding layer.

#sqlite #distributedStorage #blobStorage #rust #redisProtocol