- Learn
- High Level System Design
- APIs and Communication
HLD-M03
APIs and Communication
How services talk: REST design, pagination, idempotent retries, GraphQL, gRPC, real-time connections, webhooks and API gateways.
Every system is a set of components exchanging messages, and the shape of those messages decides a surprising amount: how easy the system is to use, how it behaves when the network drops a response, how much it costs to scale, and how painful it is to change later.
This module covers the patterns you will use in almost every design. You will design REST resources and pick status codes, see why offset pagination breaks while you scroll, stop a retried payment from charging twice, compare GraphQL and gRPC with plain REST, push updates in real time with WebSockets, receive webhooks safely, and put a gateway in front of it all.
Lessons
- HLD-03.01 REST API design REST models an API as resources identified by URLs, such as /users/42/orders, manipulated with HTTP methods: GET reads, POST creates, PUT replaces, PATCH updates and DELETE removes. Beginner 15 min
- HLD-03.02 Pagination patterns Offset pagination (page 3, 20 per page) is easy, but the database must skip all earlier rows, which gets slow on deep pages, and inserts during browsing cause duplicates or skipped items. Beginner 10 min
- HLD-03.03 Idempotency and safe retries An operation is idempotent if doing it twice has the same effect as doing it once. Intermediate 12 min
- HLD-03.04 GraphQL GraphQL exposes one endpoint and a typed schema; clients ask for exactly the fields they need, possibly across many related objects, in one request. Intermediate 12 min
- HLD-03.05 gRPC and Protocol Buffers gRPC defines services and messages in Protocol Buffers, generates client and server code in many languages, and sends compact binary messages over HTTP/2. Intermediate 12 min
- HLD-03.06 Real-time: polling, long polling, SSE and WebSockets To push updates to clients you can poll on a timer (simple but wasteful and laggy), long-poll where the server holds the request open until there is news, use Server-Sent Events for a one-way stream from server to browser, or open a WebSocket for full two-way messaging. Intermediate 14 min
- HLD-03.07 Webhooks A webhook is an HTTP callback: when something happens, the provider POSTs an event to a URL the consumer registered. Intermediate 8 min
- HLD-03.08 API gateway and backend-for-frontend An API gateway is the front door for many backend services. Intermediate 10 min