Skip to content
Graphviz (DOT) templates

Database Sharding

Application-tier sharding by tenant_id across 4 shards.

Template previewGraphviz (DOT)
shards App App Router Shard router hash(tenant_id) mod 4 App->Router S0 Shard 0 tenants A-F Router->S0 S1 Shard 1 tenants G-L Router->S1 S2 Shard 2 tenants M-R Router->S2 S3 Shard 3 tenants S-Z Router->S3

What this template contains

Graph
Directed
Edges
5
Source
13 lines

Make it your own.

digraph shards {
  rankdir=LR;
  graph [bgcolor=transparent];
  node [shape=box, style="rounded,filled", fontname=Inter, fontsize=10];

  App [label="App", fillcolor="#dbeafe"];
  Router [label="Shard router\nhash(tenant_id) mod 4", fillcolor="#fef3c7"];
  S0 [label="Shard 0\ntenants A-F", shape=cylinder, fillcolor="#dcfce7"];
  S1 [label="Shard 1\ntenants G-L", shape=cylinder, fillcolor="#dcfce7"];
  S2 [label="Shard 2\ntenants M-R", shape=cylinder, fillcolor="#dcfce7"];
  S3 [label="Shard 3\ntenants S-Z", shape=cylinder, fillcolor="#dcfce7"];

  App -> Router;
  Router -> S0; Router -> S1; Router -> S2; Router -> S3;
}