Database-Sharding-diagram.excalidraw
==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠==
Database Sharding — Range-Based vs Hash-Based Topology Diagram
Text Elements
Range-Based Sharding ^range-label Hash-Based Sharding ^hash-label Application ^range-app Application ^hash-app Shard Router ^range-router Shard Router ^hash-router Shard-1 (A–M) ^range-s1 Shard-2 (N–Z) ^range-s2 Shard-1 ^hash-s1 Shard-2 ^hash-s2 Shard-3 ^hash-s3 Hot-spot risk if keys cluster ^range-warn Even distribution, range queries need scatter-gather ^hash-desc Resharding: consistent hashing avoids full redistribution — see Consistent-Hashing ^reshard-note hash(key) % N ^hash-fn
%%
Drawing
{
"type": "excalidraw",
"version": 2,
"source": "https://excalidraw.com",
"elements": [
{
"id": "range-label",
"type": "text",
"x": 60,
"y": 20,
"width": 220,
"height": 28,
"text": "Range-Based Sharding",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "top",
"strokeColor": "#1971c2",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-label",
"type": "text",
"x": 430,
"y": 20,
"width": 220,
"height": 28,
"text": "Hash-Based Sharding",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "top",
"strokeColor": "#e67700",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "range-app-box",
"type": "rectangle",
"x": 90,
"y": 60,
"width": 160,
"height": 44,
"strokeColor": "#1e1e1e",
"backgroundColor": "#f8f9fa",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100
},
{
"id": "range-app-text",
"type": "text",
"x": 110,
"y": 74,
"width": 120,
"height": 20,
"text": "Application",
"fontSize": 14,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "arrow-range-app-router",
"type": "arrow",
"x": 170,
"y": 104,
"width": 0,
"height": 56,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100,
"points": [[0, 0], [0, 56]],
"startArrowhead": null,
"endArrowhead": "arrow"
},
{
"id": "range-router-box",
"type": "rectangle",
"x": 90,
"y": 160,
"width": 160,
"height": 50,
"strokeColor": "#1971c2",
"backgroundColor": "#e7f5ff",
"fillStyle": "solid",
"strokeWidth": 3,
"roughness": 1,
"opacity": 100
},
{
"id": "range-router-text",
"type": "text",
"x": 108,
"y": 177,
"width": 124,
"height": 20,
"text": "Shard Router",
"fontSize": 14,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#1971c2",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "arrow-range-router-s1",
"type": "arrow",
"x": 140,
"y": 210,
"width": -60,
"height": 70,
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100,
"points": [[0, 0], [-60, 70]],
"startArrowhead": null,
"endArrowhead": "arrow"
},
{
"id": "arrow-range-router-s2",
"type": "arrow",
"x": 200,
"y": 210,
"width": 60,
"height": 70,
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100,
"points": [[0, 0], [60, 70]],
"startArrowhead": null,
"endArrowhead": "arrow"
},
{
"id": "range-s1-box",
"type": "rectangle",
"x": 30,
"y": 280,
"width": 130,
"height": 50,
"strokeColor": "#2f9e44",
"backgroundColor": "#ebfbee",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100
},
{
"id": "range-s1-text",
"type": "text",
"x": 40,
"y": 293,
"width": 110,
"height": 24,
"text": "Shard-1 (A–M)",
"fontSize": 13,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "range-s2-box",
"type": "rectangle",
"x": 180,
"y": 280,
"width": 130,
"height": 50,
"strokeColor": "#2f9e44",
"backgroundColor": "#ebfbee",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100
},
{
"id": "range-s2-text",
"type": "text",
"x": 190,
"y": 293,
"width": 110,
"height": 24,
"text": "Shard-2 (N–Z)",
"fontSize": 13,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "range-warn-box",
"type": "rectangle",
"x": 30,
"y": 345,
"width": 280,
"height": 30,
"strokeColor": "#e03131",
"backgroundColor": "#fff5f5",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "range-warn-text",
"type": "text",
"x": 40,
"y": 352,
"width": 260,
"height": 20,
"text": "Hot-spot risk if keys cluster",
"fontSize": 12,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#e03131",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-app-box",
"type": "rectangle",
"x": 460,
"y": 60,
"width": 160,
"height": 44,
"strokeColor": "#1e1e1e",
"backgroundColor": "#f8f9fa",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-app-text",
"type": "text",
"x": 480,
"y": 74,
"width": 120,
"height": 20,
"text": "Application",
"fontSize": 14,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "arrow-hash-app-router",
"type": "arrow",
"x": 540,
"y": 104,
"width": 0,
"height": 56,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100,
"points": [[0, 0], [0, 56]],
"startArrowhead": null,
"endArrowhead": "arrow"
},
{
"id": "hash-router-box",
"type": "rectangle",
"x": 460,
"y": 160,
"width": 160,
"height": 50,
"strokeColor": "#e67700",
"backgroundColor": "#fff3bf",
"fillStyle": "solid",
"strokeWidth": 3,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-router-text",
"type": "text",
"x": 478,
"y": 177,
"width": 124,
"height": 20,
"text": "Shard Router",
"fontSize": 14,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#e67700",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-fn-text",
"type": "text",
"x": 472,
"y": 212,
"width": 136,
"height": 18,
"text": "hash(key) % N",
"fontSize": 11,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "top",
"strokeColor": "#e67700",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "arrow-hash-router-s1",
"type": "arrow",
"x": 500,
"y": 232,
"width": -60,
"height": 48,
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100,
"points": [[0, 0], [-60, 48]],
"startArrowhead": null,
"endArrowhead": "arrow"
},
{
"id": "arrow-hash-router-s2",
"type": "arrow",
"x": 540,
"y": 232,
"width": 0,
"height": 48,
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100,
"points": [[0, 0], [0, 48]],
"startArrowhead": null,
"endArrowhead": "arrow"
},
{
"id": "arrow-hash-router-s3",
"type": "arrow",
"x": 580,
"y": 232,
"width": 60,
"height": 48,
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100,
"points": [[0, 0], [60, 48]],
"startArrowhead": null,
"endArrowhead": "arrow"
},
{
"id": "hash-s1-box",
"type": "rectangle",
"x": 400,
"y": 280,
"width": 90,
"height": 44,
"strokeColor": "#2f9e44",
"backgroundColor": "#ebfbee",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-s1-text",
"type": "text",
"x": 408,
"y": 294,
"width": 74,
"height": 20,
"text": "Shard-1",
"fontSize": 13,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-s2-box",
"type": "rectangle",
"x": 495,
"y": 280,
"width": 90,
"height": 44,
"strokeColor": "#2f9e44",
"backgroundColor": "#ebfbee",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-s2-text",
"type": "text",
"x": 503,
"y": 294,
"width": 74,
"height": 20,
"text": "Shard-2",
"fontSize": 13,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-s3-box",
"type": "rectangle",
"x": 590,
"y": 280,
"width": 90,
"height": 44,
"strokeColor": "#2f9e44",
"backgroundColor": "#ebfbee",
"fillStyle": "solid",
"strokeWidth": 2,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-s3-text",
"type": "text",
"x": 598,
"y": 294,
"width": 74,
"height": 20,
"text": "Shard-3",
"fontSize": 13,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"strokeColor": "#2f9e44",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "hash-desc-text",
"type": "text",
"x": 400,
"y": 338,
"width": 290,
"height": 20,
"text": "Even distribution, range queries need scatter-gather",
"fontSize": 12,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "top",
"strokeColor": "#e67700",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
},
{
"id": "reshard-note-text",
"type": "text",
"x": 60,
"y": 400,
"width": 680,
"height": 20,
"text": "Resharding: consistent hashing avoids full redistribution — see [[Consistent-Hashing]]",
"fontSize": 13,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "top",
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"roughness": 1,
"opacity": 100
}
],
"appState": {
"gridSize": null,
"viewBackgroundColor": "#ffffff"
},
"files": {}
}%%