Trending
- Implementing Secure API Gateways for Microservices Architecture
- Self-Hosted Inference Doesn’t Have to Be a Nightmare: How to Use GPUStack
- Production-Grade RAG: Why Vector Search Isn't Enough (and How Hybrid Search Fills the Gaps)
- Run Gemma 4 on Your Laptop: A Hands-On Guide to Google's Latest Open Multimodal LLM
- DZone
- Data Engineering
- Databases
- Serverless Patterns: Web
Serverless Patterns: Web
Collate all serverless web and mobile architecture patterns with standard PoV on design, impact, motivation, and best practices. The patterns can co-exist.
Join the DZone community and get the full member experience.
Join For FreeThis article is a part of a series that looks at serverless from diverse points of view and provides pragmatic guides that help in adopting serverless architecture, tackling practical challenges in serverless, and discussing how serverless enables reactive event-driven architectures. The articles stay clear of a Cloud provider serverless services, only referring to those in examples (AWS being a common reference).
As discussed in the article, "Serverless Reference Architecture," serverless finds its footprint in diverse workload patterns. Web is the most common and ubiquitous application type, allowing the delivery of content and business journeys over the internet. This article details 5 patterns of serverless web architecture, with details on the motivation and impacts of using the pattern. The designs are presented in a cloud/vendor-neutral way with a supplementary AWS implementation. Given the range of services across all major cloud providers, the same pattern can be implemented across all. Finally, the details include a few potential pitfalls and best practices.
A few cross-cutting concerns across these patterns are:
- Idempotency of serverless functions
- Stateless workloads
- Potential issues and focus on cold start issues
- Use of message sidelining with concepts such as Dead Letter Queues
These patterns can co-exist within the same application depending on the context and requirements.
Pattern 1: Archetypical Web
| Name | Archetypical Web |
|---|---|
Primary Arch Focus Area |
Web |
Secondary Arch Focus Area |
UX |
Short Description (Problem and Approach) |
The serverless solution to the typical web/mobile application that provides a SPA/Microfrontends UI and a REST backend, with serverless compute and serverless data and messaging. |
Motivation (The big picture) |
Most of the applications today are SPA with an API backend that provides transactional, querying, reporting, and other information services (i.e., the erstwhile MVC architecture). This pattern is a decoupled, serverless avatar of the same. |
When to Use |
|
Impacts |
|
Design and Details |
The pattern is used in a microservices application that:
|
Hyper-Scaler Example |
AWS: |
Watchouts and Best Practices |
|
Pattern 2: Decoupled Web
| Name | Decoupled Web |
|---|---|
Primary Arch Focus Area |
Web |
Secondary Arch Focus Area |
Messaging, UX |
Short Description (Problem and Approach) |
A serverless web application, that decouples HTTP requests from the request processing and does not block a processed response. |
Motivation (The big picture) |
In many write-intensive applications:
|
When to Use |
|
Impacts |
|
Design and Details |
|
Hyper-Scaler Example |
AWS: A Single DynamoDB is shown: it can mean multiple tables.
|
Watchouts and Best Practices |
|
Pattern 3: Duplex Web
Name |
Duplex Web |
|---|---|
Primary Arch Focus Area |
Web |
Secondary Arch Focus Area |
UX, Messaging |
Short Description (Problem and Approach) |
A serverless web application, that uses a full duplex, WebSocket channel for communication. As opposed to “Archetypical Web” and “Reactive Web”, this pattern does not use REST over HTTP for any microservices operation. The reads and writes are initiated via the same socket, which is alive until the client doesn’t terminate it. |
Motivation (The big picture) |
|
When to Use |
|
Impacts |
|
Design and Details |
|
Hyper-Scaler Example |
AWS:
|
Watchouts and Best Practices |
Some of the best practices mentioned in the archetypical web are also applicable here. |
Pattern 4: Scatter-Gather Web
Name |
Scatter-Gather Web |
|---|---|
Primary Arch Focus Area |
Web |
Secondary Arch Focus Area |
UX, API |
Short Description (Problem and Approach) |
In a modern microservices architecture, information and processing are distributed. A logical flow for an end-user needs an accumulation of information from different services. So, an API contract can be composed of information across aggregates. A serverless scatter-gather pattern puts the responsibility of this orchestration on a single component to avoid multiple sequential, parallel, or concurrent requests from the clients. A typical orchestrator is a serverless GraphQL service. A channel-specific scatter-gather component fulfills a BFF (Backend For frontend) pattern requirements. |
Motivation (The big picture) |
Use multiple resolvers to fulfill a data request spanning across services, without needing to make clients chatty over multiple calls. Enable a customer-driven query scheme to limit the data needs of per client; an implementation of BFF pattern. It is possible to use a serverless function to orchestrate calls to microservices as a means to scatter-gather, but that is limited in performance and scaling and does not provide customer-driven queries and subscriptions, as a GraphQL-based implementation of this pattern. |
When to Use |
|
Impacts |
|
Design and Details |
|
Hyper-Scaler Example |
AWS:
|
Watchouts and Best Practices |
|
Pattern 5: Strangled Web
Name |
Strangled Web |
|---|---|
Primary Arch Focus Area |
Web |
Secondary Arch Focus Area |
UX, Hybrid, Migration |
Short Description (Problem and Approach) |
Two modernization drivers – Cloud migration and microservices transformation are best advised to be done incrementally. A big-bang modernization may result in a big-bang disaster owing to the sheer complexity of domain, technology, and skills. A strangler approach to migration allows hedging of risks and focus on parts of the system for modernization. The strangled web pattern enables co-existing of a legacy web application with modernized services that continue to deliver value to customers. |
Motivation (The big picture) |
When a system is seen as a whole, made from cohesive parts, migration and modernization are focused exercises. For legacy monoliths running on-premises, migration paths can be that of re-platform, re-host, or re-architecture. When these strategies are applied to a small set of services, the migration is strangled with better control and planning. To enable strangling, an orchestrator, or a router component with integrations with cloud and on-premises legacy applications are proposed by strangled-web pattern based on serverless. |
When to Use |
|
Impacts |
|
Design and Details |
|
Hyper-Scaler Example |
AWS:
|
Watchouts and Best Practices |
Technically it is possible that UI makes calls on two different domains – one for legacy and another for the cloud.
|
Opinions expressed by DZone contributors are their own.
Related
-
API Testing With Cypress
-
Microservices Decoded: Unraveling the Benefits, Challenges, and Best Practices for APIs
-
What Is API-First?
-
Serverless at Scale
