X-Sorting-Hat-ShopId

The HTTP X-Sorting-Hat-ShopId response header is an unofficial, Shopify-specific header containing the shop identifier used by Shopify's Sorting Hat load balancer to route requests to the correct pod.

Note

The X- prefix for non-standard headers is deprecated per RFC 6648.

Usage

Shopify's infrastructure runs on a pod-based architecture where each pod is an isolated set of datastores serving a group of shops. The Sorting Hat is a Lua-based routing layer inside Shopify's load balancers, built on OpenResty. When a request arrives, the Sorting Hat looks up the shop identifier, matches the shop to a pod, and attaches routing HTTP headers to the request before forwarding.

The X-Sorting-Hat-ShopId header carries the numeric shop identifier the Sorting Hat used for the routing decision. Application servers downstream read this header to connect to the correct datastore for the matched shop. The value in this header matches the value in X-ShopId for the same request, since both reference the same underlying store. The difference is context: X-ShopId identifies the store in general terms, while X-Sorting-Hat-ShopId reflects the identifier as seen by the routing layer.

Values

Numeric shop identifier

The value is an integer representing the Shopify store the Sorting Hat resolved for request routing. Older stores have shorter identifiers and newer stores have longer ones.

Example

A standard Shopify storefront response includes the shop identifier used by the Sorting Hat routing layer. This value maps the request to a specific pod in Shopify's infrastructure.

X-Sorting-Hat-ShopId: 24001675360

The Sorting Hat headers typically appear together. The shop ID determines which pod handles the request, and the pod ID confirms where the request was processed.

X-Sorting-Hat-ShopId: 5980684391
X-Sorting-Hat-PodId: 52

In a full Shopify response, the routing headers appear alongside the general store identifier. All three values work together to trace a request through Shopify's infrastructure.

X-ShopId: 14872774
X-Sorting-Hat-ShopId: 14872774
X-Sorting-Hat-PodId: 124
X-ShardId: 52

The X-ShardId and X-Sorting-Hat-PodId values differ because shards and pods use separate numbering in Shopify's architecture. Each pod maps to a single MySQL shard, but the identifiers come from different assignment spaces.

Takeaway

The X-Sorting-Hat-ShopId header exposes the shop identifier used by Shopify's Sorting Hat load balancer to route a request to the correct pod and datastore. The value pairs with X-Sorting-Hat-PodId to provide full routing traceability.

See also

Last updated: March 6, 2026