Databases 5 min read

Designing Routing Keys for Sharding in an Order Platform

This article explains how to select and implement routing keys for database sharding in a food‑delivery order system, covering supported scenarios, single‑ and multi‑database strategies, hash‑based distribution for both user and merchant data, and practical flow diagrams to ensure balanced and efficient data access.

Top Architect
Top Architect
Top Architect
Designing Routing Keys for Sharding in an Order Platform

After splitting tables, the first problem is choosing a routing key that exists uniquely in each table; the article discusses selecting keys such as timestamps for archival data or business‑related identifiers.

Supported scenarios for a food‑delivery order platform are described from both consumer (C‑end) and merchant (B‑end) perspectives, emphasizing real‑time order status queries and merchant analytics.

Routing strategies are presented for single‑database and multi‑database environments: using the user_id hash modulo the number of tables, or extending the hash to select the appropriate database first and then the table.

Examples illustrate how to store orders by hashing user_id, how merchants can consume order messages from MQ and apply the same routing logic, and visual diagrams (omitted) show the complete data flow.

The article concludes with key points: design routing keys closely tied to business scenarios and ensure even data distribution.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendDatabase designOrder ManagementRouting KeyHash Partitioning
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.