Notes
All notes

Cloud Design Patterns (System Design #16)

By now you have met the building blocks. But experienced architects do not rediscover solutions under pressure; they recognize problems and reach for known patterns. “The legacy system must stay up while we replace it” has a name — Strangler Fig. “Reads and writes have wildly different shapes” has a name — CQRS. Naming the pattern turns a vague design debate into a known problem with known trade-offs.

This chapter is a catalog. You do not need to master every pattern — the roadmap itself says getting an overview is enough — but you should know what each solves and when it applies. They are grouped by the problem they address.

Design and implementation patterns

These shape how services are structured and deployed.

\begin{tikzpicture}[font=\rmfamily, >=stealth,
  b/.style={draw, thick, rounded corners=3pt, minimum width=1.55cm, minimum height=0.7cm, align=center, font=\rmfamily\small},
  a/.style={->, thick}]
  \node[b, fill=gray!10] (lb) at (-3.6,0) {router};
  \node[b, fill=blue!10] (old) at (-0.9,0) {legacy};
  \node[b, fill=green!12] (new) at (1.9,0) {new service};
  \draw[a] (lb) -- node[above, font=\scriptsize] {shrinking} (old);
  \draw[a] (lb) -- node[below, font=\scriptsize] {growing} (new);
  \node[font=\rmfamily\small, text=black!60, anchor=north] at (-0.9,-0.7) {Strangler Fig: strangle the legacy gradually};
\end{tikzpicture}

Messaging patterns

These govern how services exchange work and events (Chapter 13).

Data management patterns

These address how data is stored, read, and kept consistent (Chapters 10–12).

\begin{tikzpicture}[font=\rmfamily, >=stealth,
  b/.style={draw, thick, rounded corners=3pt, minimum width=1.8cm, minimum height=0.7cm, align=center, font=\rmfamily\small},
  a/.style={->, thick}]
  \node[b, fill=green!12] (cmd) at (-3.2,0.9) {command (write)};
  \node[b, fill=blue!10] (wm) at (-0.8,0.9) {write model};
  \node[b, fill=orange!16] (q) at (1.8,0.9) {read model};
  \node[b, fill=cyan!15] (query) at (1.8,-0.9) {query (read)};
  \draw[a] (cmd) -- (wm); \draw[a] (wm) -- node[above, font=\scriptsize] {events} (q);
  \draw[a] (q) -- (query);
  \node[font=\rmfamily\small, text=black!60, anchor=north] at (-0.4,-1.4) {CQRS: separate shapes, sync by events};
\end{tikzpicture}

Choosing patterns without over-applying

Patterns are tools, not a badge of sophistication. The failure mode is pattern soup: applying Event Sourcing + CQRS + a service mesh + a saga to a CRUD app with a thousand users. Every pattern adds operational cost, failure modes, and cognitive load.

The three questions that keep you honest:

  1. What measured problem does this solve? If you cannot name one, do not add it.
  2. What is the simplest thing that could work? A monolith with a well-indexed database beats a distributed event-sourced system for most products.
  3. Can we operate it? If nobody on the team has run CQRS or a service mesh in production, adopting it is a liability.

Use the catalog to recognize problems and communicate solutions, then adopt the smallest pattern that fixes the actual bottleneck.

Pitfalls

QQuestionSelf-check

What problem does CQRS solve, and what does it cost? When is Strangler Fig the right migration approach?

ASolution

CQRS separates read and write models so each can be optimized (normalized transactional writes, denormalized fast reads); it costs eventual consistency and syncing machinery, often via events. Strangler Fig is right when replacing a live legacy system: route traffic gradually to new services until the old one can be retired, avoiding a risky big-bang cutover.

Next: Reliability, Resiliency and Security (System Design #17) — keeping it up under failure, and keeping the wrong people out.