Cloud Advanced: Architecture, Resilience and Security
Cloud Architecture Patterns
In this lesson you will
- Compare monoliths and microservices
- Use queues and events to decouple services
- Apply caching and CDNs to speed up and protect systems
Introduction
An architecture is how the parts of a system fit together. Good cloud architectures share a few patterns, each solving a specific problem and each with trade-offs. The skill is choosing the simplest one that works.
Layered (n-tier) applications
The classic design: a presentation tier (the web front end), an application tier (business logic) and a data tier (databases). Each tier can be scaled and secured separately, with the data tier kept private. It is simple and works for most applications.
Monolith versus microservices
- A monolith is one deployable application. Easy to build, test and run at the beginning, but a big codebase can slow teams down, and the whole thing must scale together.
- Microservices split the system into small services, each owning one capability and its own data, communicating over the network. Teams can deploy independently and scale each part separately. The costs are real: network failures, harder debugging, data consistency problems, and much more operations work.
A common, sensible path: start with a well-structured monolith, and split out services only when a clear need appears.
Quick quiz
Which statement about microservices is the most accurate?
Queues and event-driven design
A message queue sits between a producer and a consumer. The producer puts a message on the queue and moves on. Consumers process messages at their own pace.
Benefits:
- Decoupling: services do not need each other to be online at the same moment.
- Smoothing spikes: a flood of requests becomes a backlog that workers clear steadily.
- Retries: failed messages can be tried again, or moved to a dead-letter queue for inspection.
Example: after an order is placed, the web app drops a message. Separate workers send the email, update stock and print the label, each independently.
In event-driven systems, services publish events ("order placed") and others subscribe. It is flexible, but flow is harder to follow, so use good monitoring.
Because messages can be delivered more than once, handlers should be idempotent: processing the same message twice has the same effect as once.
Caching
A cache stores the results of expensive or frequent work in fast memory, so you do not repeat it.
- In-memory caches such as Redis for database results and sessions
- HTTP caching in browsers and servers
- Content delivery networks (CDNs) keep copies of your files at locations around the world, close to users. They cut latency, reduce load on your servers, and help absorb attacks.
The hard part is invalidation: making sure stale data is refreshed. Use sensible expiry times and clear rules.
Other useful patterns
- API gateway: a single entry point that handles routing, authentication and rate limiting.
- Circuit breaker: stop calling a failing service for a while, to avoid cascading failure.
- Retry with backoff: try again after increasing delays, with a limit.
- Strangler pattern: gradually replace parts of an old system with new services.
- Database per service and read replicas to scale reads.
Choosing
Ask: what is the actual problem? Scale, team independence, reliability or cost? Choose the lightest pattern that fixes it, and write down the trade-offs you accepted.
Try it yourself
Sketch the architecture for an online shop's checkout: which parts are synchronous, which use a queue, and what you would cache. Mark where an idempotent handler is needed.
Summary
- Layered apps are simple and effective, and microservices trade simplicity for independence.
- Queues and events decouple services, smooth spikes and allow retries, so design idempotent handlers.
- Caches and CDNs reduce latency and load, and the key challenge is invalidation.
Lesson complete
+20 XP
Nice work. Keep going while it is fresh.
Sources and further reading