Every company that is in the process to migrate its application(s) to the cloud faces challenges on multiple ends. Since a simple “lift and shift” approach would not always satisfy the business’ needs, those companies need to refactor their applications and infrastructure components to fit the best cloud solution. Many DevOps teams need to learn how to implement these solutions. Sometimes based on (initial) experiments and/or with trial and error. This is time-consuming and not the best approach since it can also lead to frustration and (security) issues later on in the development process.
Here design patterns come into play. They help to select the best-proven approach including best practices to tackle specific problems. In this article, we’ll explore some of these to help those teams accelerate and thrive. Five inspirational design patterns for your next cloud project.
The design patterns in this article are selected based on a number of criteria:
- It needs to fit a clear purpose or use case which is easy to recognize by potential users.
- The design pattern needs to be recent enough so that it still applies to the actual cloud platform.
- There should be a clear context and problem, users should understand when to use this pattern and preferable when not.
- Include multiple cloud providers so there is no narrow focus on only a single cloud provider.
- Supporting images or schemas as well as sample source code and additional resources are a plus.
With these criteria in mind, the reader has a solid foundation to interpret the presented design patterns.
1. Dealing with connection failures
Nearly every application in the cloud is connected to external services. Connections are not always stable and predictable so applications need to be designed to handle (connection) failures and other issues which negatively affect those services.
Azure provides the retry pattern to handle transient failures to services and network resources. It tries to improve the stability of the application by retrying a failed operation “behind the scenes” of the end-user. This design pattern has a solid description of the problem area and potential solutions. A simple scheme that shows the interplay of the application itself, the connections, and the (external) service makes the pattern clear. Besides this, the pattern includes several issues and considerations to take into account when designing your application.
There are some code snippets in the C# language which also Java developers would understand since the syntax resembles each other pretty well. Developers do not need to write custom retry logic immediately, there are references to general frameworks for .NET as well as Java.
The design pattern concludes with retry guidance for a huge number of Azure services. This makes it practical to select the right feature based on the (other) services which are in scope.
2. Cloud APIs
Modern applications communicate through APIs and avoid legacy-based integration points. This brings extra challenges if those applications are run in the cloud. Google Cloud offers a great number of common design patterns for applications that expose or consume data through APIs.
Most of the tips and tricks in this article apply to APIs in general, not specifically to Google Cloud itself. The design patterns are very practical since they’re written from the architect’s or developer’s perspective. Almost every pattern has a source code snippet that shows how a particular implementation would work in practice.
The following list shows common patterns which are applied in every cloud situation:
- Reduce network traffic by carefully selecting which parts of the requested resources are shown to the client. This decreases response times significantly.
- Data retention: provide guidance on how to offer data retention options (both free and via a paid plan) and an undelete function.
- Long-running operations. This becomes handy in case the application requests large chunks of data from the API or a big number of (concurrent) requests which should all be handled successfully before the actual operation can be concluded.
- Request duplication. In this pattern, you can learn how to avoid processing duplicate requests in case of previous failures. This is also related to the design pattern of dealing with connection failures.
Among these patterns, there are many more practical guidelines such as naming conventions, versioning, and directory structures which can also be applied to other cloud providers.
3. Database migration
Open Source solutions are on the rise as well as the number of companies that terminate their commercial database solutions like Oracle and IBM. A common use case is to migrate an on-premises Oracle database to PostgreSQL using the Amazon RDS service. These kinds of projects eliminate the need to manage the database yourself and it reduces license costs. Besides these benefits, it also reduces the (potential) vendor lock-in for important data assets.
AWS experts wrote an extended design pattern to re-architect an Oracle workload to fit their solutions: host it on the AWS cloud using Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL. The design pattern is intended for PoC environments and it focuses on minimum database downtime.
There is a clear section of the prerequisites and limitations of this design pattern. Furthermore, the product versions which are supported are clearly lined up and up to date. This makes it very to quickly validate if this design pattern fits your use case.
In this design pattern, you will find information about the tools which are needed for the migration. This includes AWS DMS (Database Migration Service) and a Schema Conversion Tool (SCT). Both can work with a great number of commercial and open-source-based database solutions. This makes the design pattern applicable to a large user group.
Large database migrations can take up a long time. The design pattern offers Epics to help you plan this project. These epics act as milestones that can be executed in parallel. Besides the tasks and the description of these, you will also find the required skills so you can prepare this project by allocating the right professionals.
And last but not least: there are several other design patterns to cover similar use cases to migrate other database solutions to AWS.
No one can ignore Kubernetes nowadays. Since this container platform continues to evolve at a rapid pace, it’s good to know the most important design patterns. This statement is underscored by the wide variety of different structures like Windows, Linux, and others. On top of that, you’ll find stateful and stateless applications as well as serverless technologies. At the website of wallarm.com, the authors put together a list of top design patterns which help every cloud-native developer push their workload to Kubernetes. It’s fascinating to notice that many of these design patterns are evolved from a previous research topic that explores the design patterns around container-based distributed systems.
The patterns range from the essentials that apply to every workload to advanced behavioral design patterns like batch job designs, stateful services, and service discovery. One of the great things about this page is that every pattern has a very clear image/diagram of the components and how they relate to each other. This makes them very clear also in respect to the different layers of the given tech stacks.
A great example is operator design. Citing the text on the website, an operator is:
…a regulator that watches out for accommodating data in an algorithmic and modernized arrangement for a given application utilizing CustomResourceDefinitions.
The supporting diagram shows how shared resources, configmaps, custom resource definitions, and aggregated APIs are related to each other in terms of increased flexibility & complexity. Without this diagram, it would be much harder to understand.
Their advice is to study every design pattern carefully and also to experiment with it. Once developers understand their true functionality of them, they can choose to pick one or more of them to fit their use case.
5. Serverless technology
As more and more teams adopt serverless technologies, it’s vital to also understand at least the basics of common design patterns for it. Based on the website of Infoq, there are multiple viewpoints looking at the problem area.
According to the subject matter experts, the design patterns are listed based on the requirements perspective: event workflows, application ecosystems, mobile, and IoT applications, web applications, and event-driven data processing.
Another perspective is based on more common design patterns like pipes and filters, priority queues, messaging, commands, and fan-out. These patterns are described later on in the article. All of them include a detailed description of how the patterns work, there are images/diagrams that support the text as well as code snippets to give you a proper start.
Since this technological landscape grows every day and new (cloud native) services are offered now and then, it’s difficult to define a “one solution fits all” approach for serverless. Be sure to check out the excellent article on The New Stack that explains the implementation details of the before-mentioned design patterns in AWS.
Another must-read resource if you’re developing for Azure is the (free) e-book called “Serverless apps: Architecture, patterns, and Azure implementation). This e-book is packed with information about architecture approaches, serverless architecture, the Azure serverless platform, Azure functions, and business scenarios + use cases. For sure this gives you a thorough understanding of numerous design patterns with are dedicated to the Azure cloud.
Design patterns act as fundamental building blocks to create powerful software applications. They help to make the right decisions based on specific use cases and challenges. They often include best practices and other tips and tricks to avoid developers from making sub-optimal architectural choices. Solid design patterns clearly their purpose, and are surrounded with images/schemas to explain the context and working of it. On top of that, code snippets help to give the developer a great start. In this article, we’ve seen a nice list of design patterns for different tech stacks and multiple domain areas that help speed up the software development activities of every company in the IT industry.
If you have questions related to this topic, feel free to book a meeting with one of our solutions experts, mail to firstname.lastname@example.org.