Home
Blog
The Ultimate Guide to Swiggy’s Real-Time Order Allocation System

The Ultimate Guide to Swiggy’s Real-Time Order Allocation System

How Swiggy's real-time order allocation system works - GPS clustering, async Kafka dispatch, and distributed server architecture powering 923M+ annual orders.

Kalki Sri Harshini
June 25, 2026
8 Mins

I was bored, hungry, and too lazy to cook. So I opened Swiggy, ordered a burger meal, and within minutes it arrived at my doorstep. What feels effortless to customers is powered by one of the most advanced real-time delivery systems in India.

In FY2025, Swiggy processed 923 million orders, each passing through a sophisticated order allocation engine that handles GPS matching, serviceability checks, and delivery partner assignment in seconds. Behind Swiggy and Instamart lies a high-scale architecture built on event-driven microservices, real-time data streaming with Apache Kafka, and intelligent location-based routing.

In this guide, we'll break down how Swiggy's real-time order allocation system works, covering the delivery time equation, microservice architecture, GeoHash-based serviceability, and asynchronous dispatch mechanisms that enable fast and reliable deliveries at scale.

Building a dispatch or fulfillment pipeline and hitting latency issues under load?

A 30-minute call with a BuildNexTech engineer gives you a clear read on where your architecture will break. No pitch, no commitment.

The Delivery Time Equation: The Design Contract That Governs Everything

Swiggy's entire data pipeline architecture is downstream of one formula:

Delivery Time = Max(Assignment Delay + First Mile, Prep Time) + Last Mile

Every infrastructure boundary exists to honour this contract. The ETA shown to the customer is not a suggestion. Display it too low, and the post-order experience breaks. Display it too high, and the conversion funnel collapses. At 923 million annual orders, a 1.5% abandonment rate from poor ETA accuracy translates to tens of millions in lost GMV.

Quick commerce assignment is not a proximity problem. Swiggy's scoring engine weights five variables simultaneously: GPS proximity, first-mile travel time, delivery partner workload, kitchen preparation forecast, and historical performance per route cluster. A delivery partner 800 metres away with a degraded performance record consistently loses to one 1.4 km out with a stronger track record on that cluster. Demand forecasting feeds directly into this equation. Real-time inventory levels at the nearest dark store, prep time estimates per SKU, and historical order picking duration all enter the scoring model before a delivery partner is assigned. The Order Management System holds every active order's state across this evaluation without blocking any other service.

How Swiggy Integrates Google Maps Into Its Delivery Architecture

Swiggy uses the Google Maps API at two specific points in the order flow. First, for map rendering on the customer side, the live tracking screen showing the delivery partner's location and route is powered by Google Maps. Second, for delivery partner navigation, the DE app uses Google Maps for turn-by-turn directions to the restaurant and the customer drop-off location.

What Google Maps does not handle is the allocation decision itself. Serviceability checks, ETA scoring, and delivery partner assignment all run on Swiggy's internal infrastructure, using GeoHash-based spatial indexing and cached routing data. Google Maps is the presentation layer. The real-time order allocation system operates independently underneath it.

Inside Swiggy's Allocation Engine: Microservices, Infrastructure, and the FSM

The allocation data pipeline architecture runs across six independent services. Each owns a single responsibility, scales via elastic scaling, and fails in isolation. The API Gateway authenticates and routes all client requests first. Behind it, IaaS hosts compute and storage per service, PaaS manages Apache Kafka as the event bus and PostgreSQL as the transactional store, and SaaS handles observability and notification delivery across delivery platforms.

The Six Services That Own the Allocation Flow

The six services in pipeline order:

  • User Service: Authentication, profile resolution, live customer location context.
  • Serviceability Service: Resolves valid restaurants and dark store assignments from an in-memory GeoHash index, not a live database query.
  • Order Service: Owns the full order lifecycle via the Order Management System with transactional correctness.
  • Delivery Matching Service: Runs the multi-factor scoring model and selects the optimal delivery partner.
  • Location Service: Consumes GPS streams, maintains live positions in memory, pushes updates to customer WebSocket sessions via real-time data pipelines.
  • Notification Service: Fires push alerts at every FSM state transition, consuming from Kafka asynchronously.
Kafka-Driven Order State Machine

Microservices by Consistency Tier

The Order Service and Payment Service use PostgreSQL with synchronous replication: strong consistency, no partial writes, no double charges. The Location Service and Notification Service are async Kafka consumers on eventual consistency. Minor tracking delays are acceptable; synchronous blocking at peak is not. The Serviceability Service serves from an in-memory GeoHash index with zero database round-trips, delivering system efficiency at 200 million evaluations per minute.

Our Take: Most teams building for the hyperlocal commerce industry default to a single consistency model because it simplifies early reasoning. That costs them in production. Strong consistency for the Order Management System, eventual consistency for location, and in-memory reads for serviceability is the right model for any system where financial transactions, real-time inventory, and delivery partner assignment share the same data pipeline architecture.

GPS Tracking, GeoHash Clustering, and the Serviceability Engine

A logistics client we worked with rebuilt their serviceability check after live PostgreSQL queries were handling every customer session. At 40,000 concurrent sessions during a peak window, query latency climbed from 12 milliseconds to 340 milliseconds, and orders timed out. Moving to an in-memory spatial index cuts per-evaluation time by 96%.

Swiggy's approach reflects this at several orders of magnitude higher volume. GPS coordinates from each delivery partner map to a hierarchical GeoHash string key. The system resolves a customer drop location to its delivery cluster in O(1) time with zero live database queries. The serviceability engine runs entirely from memory, rebuilt at service startup from the data warehouse.

Point-in-Polygon Checks and the In-Memory Cluster Index

Thousands of delivery cluster polygons exist across hundreds of cities in any quick commerce network. Checking each polygon via a live database query at 200 million evaluations per minute would saturate a standard PostgreSQL instance within seconds of peak traffic. The serviceability engine pre-builds a GeoHash-keyed cluster index in memory. Each drop location maps to its GeoHash key at evaluation time, returning the matching cluster and dark store assignment instantly. O(1) per evaluation, regardless of geographic boundaries. Zero database hits.

Swiggy Instamart uses this engine to resolve which dark store services a customer's location at session start, enabling inventory tracking and real-time inventory checks against the correct micro fulfillment node before any product listing appears.

Real-Time GPS Stream to Customer WebSocket

The Kafka topic delivery-location-events carries each delivery partner's GPS update as a LocationEvent keyed by orderId. Partition-level ordering is guaranteed per order. The Location Service maintains an in-memory position map per active order and pushes live updates to the customer's WebSocket session. The full chain, from delivery partner GPS hardware to tracking screen, runs through stream processing with no synchronous bottleneck.

🍔 Swiggy Real-Time Order Allocation Simulator

Watch how Swiggy automatically allocates delivery partners and delivers orders in real time.
Orders: 128
Riders: 42
Allocated: 119
🏬
Restaurant
🏠
Rahul

⚡ Allocation Engine

Rider A • 0.8 km
Rider B • 2.1 km
Rider C • Busy
🍗 Chicken Biryani ₹349
SWIGGY
📱 New Order Received
⭐⭐⭐⭐⭐ Delivered in 17 mins
📱 Customer Updates
Looking for delivery partner...

Asynchronous Dispatch: Apache Kafka and the SAGA Pattern

The entire dispatch pipeline runs on asynchronous communications. No service waits for a synchronous response. Every action is a published Kafka event consumed independently. The sequence runs: OrderCreated, OrderConfirmed, DeliveryAssigned, PickupConfirmed, DeliveryCompleted. The assignment engine, tracking service, restaurant notifications, and analytics platforms all consume the same event simultaneously with no coupling between them.

SAGA Pattern

Building a warehouse management system or dispatch pipeline, and unsure whether your Kafka topology will hold at scale?

Our engineers have helped teams across logistics, quick commerce, and retail build event-driven data pipeline architectures that do not break under load. Book a 45-minute walkthrough.

The SAGA Compensation Chain: Distributed Failure Without Global Locks

Two-phase commit (2PC) requires a global lock across all participating services. At Swiggy's throughput, that lock stops the pipeline. The SAGA pattern removes it. Every forward event has exactly one compensating event. When a delivery partner becomes unavailable post-assignment, DeliveryCancelled is published, OrderCancelled follows, and the order re-enters the assignment queue automatically. Zero manual intervention. Zero unrecoverable state across the Order Management System.

Just-in-Time Assignment and Order Batching

Swiggy delays delivery partner assignment until kitchen prep time is accounted for. Early assignment generates idle wait time at the restaurant and cascades into worse ETA accuracy on subsequent orders. The order batching heuristic groups two orders from nearby restaurants with compatible prep windows for a single delivery partner. Prep window compatibility is the binding constraint, not geographic proximity. Mismatched prep windows degrade per-order ETA and route efficiency simultaneously, so the system avoids grouping orders whose prep timelines conflict even when geographic overlap looks favourable. That tradeoff does not have a clean answer, and anyone claiming otherwise has not managed a production quick commerce dispatch system at scale.

How BuildNexTech Helps Engineering Teams Build This Faster

Assembling a real-time order allocation system with GPS ingestion, GeoHash serviceability, data lakehouse integration, and SAGA compensation from scratch takes 6 to 9 months for most teams. Across 150+ client engagements in logistics, quick commerce, and retail, BuildNexTech's engineers have seen the same failure modes: hand-rolled Kafka consumer logic without retry governance, missing compensation events, and synchronous bottlenecks where async was required from day one.

What a BNXT.ai Implementation Looks Like

BuildNexTech's AI-native automation services handle retry logic, state recovery, data governance, and observability out of the box. The rollout runs in three concrete phases:

  • Days 1 to 3: Discovery
    • Map the existing allocation workflow end-to-end
    • Define agent boundaries: GPS agent, scoring agent, dispatch agent
  • Days 4 to 7: Integration
    • Connect BNXT.ai's orchestration layer to existing Kafka topics and PostgreSQL schema.
    • No rip-and-replace of current infrastructure
  • Week 2 onwards: Iteration
    • Observability dashboards surface which allocation hop is introducing latency or triggering compensation events
    • Teams iterate on individual agents without full pipeline redeployment

At rollout, the team owns:

  • A fully observable, agentic allocation pipeline
  • Hand-rolled event-handler code replaced with a governed, auditable orchestration layer

A US logistics client reduced manual processing overhead by 40% within six weeks, with the data pipeline architecture handling Apache Spark batch jobs and real-time Kafka streams from a single layer. Amazon Redshift, Google BigQuery, and Apache Flink connectors come pre-built for inventory analytics and data warehouse integration alongside the Order Management System.

Who This Is For

Engineering organisations at Series B and above with allocation latency degrading under peak load, hand-rolled SAGA compensation breaking in edge cases, or cross-zone cluster assignment errors appearing as new cities are added to their quick commerce network. If the dispatch pipeline is the bottleneck between current volume and the next order of magnitude, that is the conversation worth having.

Want to know if your allocation or warehouse management system will hold at the next order of magnitude?

BuildNexTech engineers have worked with 150+ teams across logistics, quick commerce, and retail to build dispatch pipelines that do not break under load. A 30-minute call gives you a clear read on where your current setup has gaps. No commitment required.

Key Takeaway

The Gap Between Moderate Scale and 923 Million Orders Is an Architecture Gap

Swiggy's real-time order allocation system is the product of decisions made early: async Kafka dispatch from the first version, SAGA compensation before the first production incident, and an in-memory GeoHash serviceability layer before the database query problem surfaced. Most teams make these decisions reactively.

Async Kafka dispatch, SAGA compensation, GeoHash in-memory indexing, data lakehouse integration via Amazon Redshift or Google BigQuery, and stream processing via Apache Spark or Apache Flink all apply to any quick commerce or logistics allocation system, regardless of current order volume. The infrastructure scales. The architectural decisions do not change.

People Also Ask

How does Swiggy's delivery partner assignment algorithm work?

Swiggy's assignment engine runs a weighted multi-factor scoring model evaluating GPS proximity, delivery partner workload, first-mile ETA, kitchen prep forecast, and historical performance per route cluster before assigning any order.

What role does Apache Kafka play in Swiggy's quick commerce architecture?

Apache Kafka acts as the central data streaming platform across all six services. Every order state transition publishes a Kafka event consumed simultaneously by the assignment engine, tracking service, restaurant notifications, and analytics platforms.

What is the SAGA pattern, and why is it used in a warehouse management system at scale?

SAGA is a distributed transaction pattern replacing two-phase commit. Every forward event has a compensating event, so if any step in the Order Management System fails, a consistent state is restored across all services without a global lock.

How does Swiggy Instamart handle real-time inventory checks for dark store fulfilment?

The serviceability engine resolves which dark store services a customer's location at session start, performs inventory tracking and real-time inventory checks against that micro fulfillment node, using an in-memory GeoHash index for O(1) resolution across all geographic boundaries.

Can this data pipeline architecture work for smaller, quick commerce, or DTC order fulfillment operations?

Yes. Async Kafka dispatch, SAGA compensation, and in-memory GeoHash serviceability scale down as readily as up. A DTC order fulfillment operation at 10,000 daily orders benefits from the same architectural decisions with a smaller infrastructure footprint.

Don't forget to share this post!