Cloud Design Patterns— Explained Simply

Rahat Shaikh
Jan 17 · 10 min read

“There are only patterns, patterns on top of patterns, patterns that affect other patterns. Patterns hidden by patterns. Patterns within patterns…”

- Chuck Palahniuk

Perhaps the simplest way to describe a pattern would be a regularity that predictably repeats itself. The beauty of patterns lies in their ubiquity — From the way organelles are arranged in the smallest of micro-organisms to the way stars line up in galaxies, patterns exist everywhere. You simply can’t escape these patterns which govern most (if not all) laws of our physical world.

Unsurprisingly, design patterns also exist in the universe of software design. A software design pattern is a reusable solution (template) to commonly occurring issues. The world first started to take note of design patterns in software in the 1970s and much like the technologies they have come to now build, patterns have been evolving ever since.

Building efficient and scalable software is a lot like building a brick wall — A brick-layer takes great care to ensure the pattern and symmetry of their wall is maintained. This allows the foundation to be strong enough to support the weight of everything that is stacked on top of it. It allows the building of a taller, stronger, more “scalable” wall (pardon the pun). Like the brick-layer, a software engineer needs to pay attention to the design patterns that direct the underlying software if they are to create a solution that is both efficient and scalable.

With the rising popularity of Cloud Computing, the focus of Engineers everywhere has now shifted to harnessing the patterns that govern these processes.

Here’s a compilation of cloud design patterns that I’ve found to be repeatedly useful to me. I admit this list is biased from my own experience but I will try and add to it as I learn more. Hope this helps you understand design patterns that much better.


1. Asynchronous Request and Reply

Problem Statement

When we talk about Cloud Applications, Micro-services often come to mind. This is an architecture style where multiple micro-services i.e. remote APIs or third-party services are composed to perform dedicated functions to provide a particular functionality to a client application.

In such a setup, synchronously processing the client request before all the back end work is completed may not always be feasible. This is especially true in the case of long-running processes. Furthermore, latency also becomes a consideration when the response to the client needs to be a few milliseconds.

Solution: Asynchronous Processing (HTTP Polling or Event Notification)

Let us simplify with an example


2. Command and Query Responsibility Segregation (CQRS)

Problem Statement

Traditionally, people interact with Information Systems through a CRUD data store. Read and Write Data models are often the same. As the complexity of the application increases, multiple representations of the information are created, all referring to one common data (conceptual) model. This can lead to data/resource contentions, performance slowdown and in some cases, security issues.

Solution: Separate the Read and Write models

Let us simplify with an example


3. Event Sourcing

Problem Statement

When interacting with data, most applications store the current state of the data. Updates to the data elements are typically overwritten by the latest. If one wanted a history of all the updates, the application would need to be built to maintain history tables. Every time an update request is made, the current data would be moved to the history table before being overwritten. This adds to the overhead of having a robust historical backup and ensuring the application scale plan includes scaling the historical stores as well.

Solution — Event Store

- A complete rebuild
- A point in time rebuild
- Reverse events

Let us simplify with an example


4. Retry

Problem Statement

A distributed environment is prone to transient errors due to slow networks, timeouts etc. But these issues typically self-correct and if the action is re-triggered, it’s likely to succeed. In such situations, applications need to handle these transient failures without impacting the end-user experience.

Solution — Try and try again

Stop and Report exception: If a fault isn’t transient or cannot succeed when repeated, the application could raise an alert and log the exception

Retry immediately: If a fault is rare, the application could retry the failing request immediately and the request may be successful

Retry with a delay: If a fault is caused by connectivity issues or issues that may need a short period, the application could retry the failing request after a reasonable amount of time has passed

Let us simplify with an example


5. Circuit Breaker

Problem Statement

There are situations where failures can be caused by unexpected situations and take relatively longer to fix. Retry or waiting for the request to timeout may not be the best option as it may cause further cascading issues such as resource contention and/or blocked threads.

Solution — Fail fast

Prevent the application from retrying an operation likely to fail

Let us simplify with an example


6. Sidecar

Problem Statement

Peripheral tasks such as Monitoring, Logging etc are critical to most applications and often integrated within them. However, these tasks run alongside the same process as the application which is potentially inefficient and points to improper separation of concerns. Plus, outages caused in these monitoring and logging components could severely impact the entire application functions.

Solution: Co-locate as Sidecar

Let us simplify with an example


While we’ve only barely scratched the surface here, I do hope this list was helpful to you.

Which design patterns do you find yourself employing constantly? — I ‘d love to hear more about them.

Please feel free to post your recommendations in the comments below and I’ll do my best to try and update this list to include them.

Rahat Shaikh

Written by

Software Engineer | Enthusiastic Learner

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade