Library / Blogs
Kotlin Engineering Blog
The engineering blog of Kotlin: posts on how it designs, builds and scales its systems.
By Kotlin engineers · Kotlin · Added 2026-10-12
All content belongs to Kotlin engineers / Kotlin. We only link to it and give credit. Report a problem
Learn this article
About 37 min left. Your work is saved as you go.
What you are about to study
Kotlin wrote this to explain how they thought about a problem. You should know the basics: caching, queues and replication.
Ideas you will meet
- Distributed Systems
- Consensus, time, failure and the fundamentals of scale-out.
What we already know about this
Our own lessons on these ideas. Read them here before you start, so it makes sense.
Low-Level Design Practice · 11 minFood deliveryRestaurants, menus, orders and couriers: an order lifecycle with three parties, and how to keep their views consistent.Read here
The problem
Customers browse restaurants, build an order from a menu, pay and track delivery. Restaurants accept and prepare orders. Couriers pick up and deliver them.
Entities
100%Figure SDA-LLD-09-1 · Food delivery classes · © forcsguy.com
OrderItemcopies the name and price at purchase time. Later menu edits must not change old orders.The order lifecycle
100%Figure SDA-LLD-09-2 · Order status · © forcsguy.com
Each party may trigger only some transitions: the restaurant accepts and marks ready, the courier marks picked up and delivered, the customer may cancel early. Keep the allowed-transition table in one place.
const next: Record<string, Record<string, string>> = { PLACED: { restaurantAccepts: "ACCEPTED", restaurantRejects: "CANCELLED", customerCancels: "CANCELLED" }, ACCEPTED: { startPreparing: "PREPARING" }, PREPARING: { courierPicksUp: "PICKED_UP" }, PICKED_UP: { courierDelivers: "DELIVERED" }, }; function apply(order: Order, event: string) { const to = next[order.status]?.[event]; if (!to) throw new Error(`${event} not allowed in ${order.status}`); order.status = to; order.notifyAll(); // observers: customer, restaurant, courier apps }Assigning a courier
100%Figure SDA-LLD-09-3 · Courier assignment · © forcsguy.com
Matching (nearest, fastest, fairest) is a strategy, as in the cab-booking lesson. Batching two orders for one courier is an extension with its own route check.
Design notes
- Price calculation (items, taxes, fees, discount) lives in one service used by cart, checkout and invoice.
- Menu availability: items can sell out; check at add-to-cart and again at placement.
- Idempotent placement: a double tap must not create two orders; use a client-generated order key.
- Notifications use the Observer pattern on status changes.
- Failures: payment fails (do not place), restaurant unresponsive (timeout and refund), courier cancels (reassign).
Real-world reading
Related reading
- Marc Brooker's BlogMarc Brooker · brooker.co.zaBlogs
- PagerDuty BlogPagerDuty engineers · PagerDutyBlogs
- Chaos Monkey (source)Netflix · GitHubGitHub
- AWS Architecture BlogAWS architects · Amazon Web ServicesBlogs
Show 6 moreShow fewer
- Workload isolation using shuffle shardingAmazon Builders' Library · Amazon Web ServicesBlogs
- Scaling Live Videos to a Billion Users at Facebook - Sachin Kulkarni, Director of Engineering at FacebookFacebookYouTube
- Delivery Hero BlogDelivery Hero engineers · Delivery HeroBlogs
- Neural Architecture Search (NAS) for Prohibited Item Detection at MercariMercari engineers · MercariCase Studies
- Kotlin Engineering BlogKotlin engineers · KotlinBlogs
- Groww BlogGroww engineers · GrowwBlogs
Go deeper on this
A path through videos, articles, other case studies and code on the same ideas as Kotlin Engineering Blog.
Warm upGet the vocabulary first.
Books · Free from the author
Concurrent and Distributed Systems (Cambridge lecture notes)
Eight lectures on time, broadcast, replication, consensus and transactions, with notes, slides and video. Free from the author under CC BY-SA.
University of CambridgeIntermediate
Books · Free from the author
Computer Networks: A Systems Approach
How networks are built and why: protocols, routing, congestion control and the internet's architecture. The authors publish it free online under CC BY 4.0.
Systems ApproachIntermediate
WatchHow others solve the same problem, on video.
Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)
ReadEngineers explain it in their own words.
Blogs · Free from the author · Read here
Scalable Web Architecture and Distributed Systems
A full chapter on the building blocks of large websites: availability, performance, reliability, scalability, caches, proxies, indexes, load balancers and queues. Free to read here under CC BY 3.0.
The Architecture of Open Source ApplicationsBeginner40 min
Papers · Read here
Facebook’s photo storage
This paper describes Haystack, an object storage system optimized for Facebook’s Photos application. Facebook currently stores over 260 billion images, which translates to over 20 petabytes of data.
USENIXIntermediate
See it in another companyThe same ideas, a different system.
Case Studies · Read here
Aroma: Using ML for Code Recommendation at Facebook
Thousands of engineers write the code to create our apps, which serve billions of people worldwide. This is no trivial task—our services have grown so diverse and complex that the codebase contains…
FacebookIntermediate
Case Studies · Read here
Brooklin: Distributed Service for Near Real-Time Data Streaming at LinkedIn
Brooklin—a distributed service for streaming data in near real-time and at scale—has been running in production at LinkedIn since 2016, powering thousands of data streams and over 2 trillion messages per day. Today, w...
LinkedInIntermediate
Read the codeSee how it looks when it is real.
GitHub
Engineering Blogs
A huge directory of company engineering blogs to learn from real production systems.
kilimchoiIntermediate
GitHub
Awesome Scalability
Curated reading list of articles on the architecture of scalable, reliable systems.
binhnguyennusIntermediate
Keep learning
Loading community…