How McDonald’s Scales 20,000 Orders per Second with Hexagonal and Event‑Driven Architecture

This article narrates how McDonald’s food‑delivery platform uses a hexagonal, event‑driven, micro‑service architecture with serverless functions, message brokers, and schema registries to achieve massive scalability, low latency, and reliable order processing for millions of daily users.

21CTO
21CTO
21CTO
How McDonald’s Scales 20,000 Orders per Second with Hexagonal and Event‑Driven Architecture

In March 2024, Maria in Berlin orders a meal from McDonald’s via a mobile app, illustrating the platform’s end‑to‑end flow.

Hexagonal Architecture Overview

The system adopts a hexagonal (ports‑and‑adapters) architecture that isolates the core application from external services such as databases and user interfaces. Business logic resides in the domain layer following Domain‑Driven Design (DDD) principles, ensuring it does not leak outside the hexagon. Ports define contracts for external interactions, while adapters implement those contracts.

Event‑Driven Architecture

McDonald’s couples the hexagonal core with an event‑driven architecture. Producers publish domain events to a message broker; consumers subscribe and react, enabling loose coupling and modularity. A schema registry defines explicit event contracts and validates them, while cached schemas improve performance. A backup database stores events when the broker is unavailable, and failed events are routed to a dead‑letter topic for later remediation.

Scalability and Performance

The platform serves roughly 37,000 locations and over 64 million users, handling up to 20,000 orders per second with latency under 100 ms. It relies on reverse‑proxy API gateways, RESTful micro‑services, SQL databases, serverless functions, and Redis caching backed by relational storage for resilience.

Backend Process Flow

1. Selecting Food from the Menu

Maria opens the app, sees the menu hosted behind a reverse‑proxy API gateway, and the menu data is fetched from a SQL database via serverless functions that return JSON.

2. Loyalty Discount

Based on past purchases, Maria receives a discount. The order event is placed onto a FIFO message queue, guaranteeing ordered processing. Serverless workers poll the queue, apply the discount, and update the order without managing servers.

3. Placing the Order

The app creates a WebSocket connection for bidirectional communication. The client sends an order event to the API gateway, which forwards it to an event bus. Serverless functions validate the order, check restaurant inventory, and trigger downstream services. Redis caches order state, with backups to a relational database for durability.

4. Providing Feedback

After delivery, Maria receives a feedback survey. User responses are collected, ETL‑processed, stored in object storage (e.g., S3), analyzed with NLP for sentiment, and fed into internal models. Results are persisted in a data warehouse for operational reporting.

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.

MicroservicesScalabilityBackend DevelopmentHexagonal ArchitectureEvent-Driven Architecture
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

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.