6.7: Microservices and Serverless Architectures in a Layered Model

Introduction to Cloud Computing · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    Read aloud

    How

    Speed: 1×
    Light up
    Highlight

    Symbols: Mulberry Symbols, © 2018–2026 Steve Lee, CC BY-SA 4.0 (licence, the set), the site's own copies.

    From LibreTexts, under CC BY 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    6.7: Microservices and Serverless Architectures in a Layered Model

    Modern Cloud Applications

    Modern cloud applications often adopt microservices architecture and increasingly leverage serverless computing. These approaches represent a shift in how we design the application layer and how it interacts with underlying layers. In a layered cloud architecture, microservices and serverless can be seen as architectural patterns that sit on top of (and take advantage of) the lower layers (IaaS/PaaS) in specialized ways. This section explains microservices and serverless, and how they fit into the layering model.

    Microservices Architecture

    Microservices architecture is a design approach where an application is broken into many small, independent services (microservices), each focusing on a specific business capability. Each microservice runs in its own process (which could be a container or a VM, etc.) and communicates with others via lightweight mechanisms (often HTTP/REST or messaging queues). This is in contrast to a traditional monolithic architecture, where the entire application (all modules or functionalities) run as a single unified unit.
    Monolithic vs Microservices Architecture. Details in caption.

    Figure \(\PageIndex{1}\): Monolithic vs Microservices Architecture (CC BY 4.0; Felix Amoruwa) Access to a detailed description of Figure \(\PageIndex{1}\)

    In a microservices architecture, each service can be developed, deployed, and scaled independently. This offers several advantages especially suited to cloud environments: scalability (you can scale only the services that need it, rather than the whole app), fault isolation (if one service fails, it doesn’t necessarily bring down the entire system), and agility (different teams can work on different services simultaneously, potentially using different technologies). For example, Netflix famously transformed its monolithic application into a suite of hundreds of microservices running in the cloud, to achieve massive scale and resilience. In August 2008, Netflix experienced a major outage in its monolithic DVD-rental application that took it offline for days. That failure prompted Netflix to re-architect into microservices and move to AWS cloud, so that each piece of functionality (user profiles, recommendations, streaming, billing, etc.) became a separate service that could be deployed across multiple servers and even multiple regions – ensuring that no single database or component failure would take down everything. Today, Netflix runs over a thousand microservices on AWS, enabling them to deploy updates many times a day and automatically scale each service to handle over 300 million users globally [6].

    Microservices in the cloud layering: Where do microservices sit in our layered model? Microservices primarily reside at the application layer, as they implement application logic. However, to run microservices, you leverage lower layers: typically microservices are packaged in containers, so you need either IaaS (VMs to run containers) or CaaS/PaaS (managed container services or serverless) to host them. A microservice might use a database (could be a DBaaS at the platform layer) or call another microservice (over the network). So microservices architecture spans horizontally across multiple services at the top layer, and vertically it drives usage of multiple underlying cloud services.

    One way to view microservices in layered terms is to think of each microservice as a mini-application with its own stack: one might have its own data storage (a microservice might have a dedicated database or table – the “database per service” pattern), its own runtime (running in an isolated container/VM), and well-defined interface (often a REST API). In a layered picture, you’d see many small stacks side by side, possibly sharing the common infrastructure layer. For example, Microservice A might run on one VM (IaaS) with a Node.js runtime (PaaS layer abstraction) connecting to an Amazon DynamoDB table (DBaaS). Microservice B might run on Kubernetes (CaaS) in a container with a Python runtime and use AWS S3 for storing objects. The microservices communicate over the network (calls that go through the cloud network layers).

    Microservices architectures also often bring additional components that reside at various layers: - An API Gateway or edge service at the application layer (Layer 7) often fronts the microservices, routing external requests to the correct service and aggregating where needed. This gateway might be a managed service (like Amazon API Gateway) which is a layer 7 construct but uses underlying cloud infra. - A Service Mesh (like Istio or Linkerd) can operate at the network layer (L3-L4) and above, managing communication between microservices, handling things like service discovery, retries, and monitoring (this can be thought of as a distributed L5/L7 layer specifically for inter-service communications). - Message brokers or streaming systems (like Kafka, or cloud equivalents) might be used (those would be PaaS data services) to enable asynchronous communication – effectively adding an integration layer for microservices.

    From a development perspective, microservices align well with cloud because teams can containerize each service and deploy on cloud infrastructure that automatically handles scaling and distribution. It encourages using CI/CD pipelines (DevOps tools at management layer) to rapidly and continuously deploy each service. Each microservice can even use different tech stacks – cloud PaaS offerings support polyglot environments easily, and container orchestration doesn’t mind if one service is Java and another is Go.

    Why microservices in cloud: The cloud’s ability to provision resources quickly and scale on demand complements microservices. For instance, if one particular service in your application becomes a bottleneck (say the “recommendation service” experiences high load), in a cloud environment you can just scale out more instances of that microservice rather than scaling the whole app. This granular scaling is cost-efficient and is one reason microservices are popular for large-scale cloud-native systems. Netflix’s microservices approach, for example, allows it to scale without extra work on monoliths – additional servers are automatically used for the particular service under load. It also meant a problem in one microservice (like a bug causing high CPU) would degrade just that functionality, not the entire site, thanks to fault isolation.

    Another aspect is update agility – microservices can be deployed independently. In cloud terms, you might deploy Microservice A as a separate container image update on Kubernetes without redeploying others. This reduces risk and downtime (small changes, small blast radius). It fits with cloud deployment practices like blue-green or canary deployments at the service level.

    Challenges of microservices include the added complexity of distributed systems – you need robust monitoring (observability layer must capture metrics from many components), network reliability handling (as calls go over network instead of in-process), and often a DevOps maturity to manage many moving parts. Cloud platforms provide many aids here: e.g., distributed tracing systems (AWS X-Ray, etc.) to trace calls between microservices (Layer 7 tracing), and managed orchestration to keep services available.

    Serverless Architectures

    Serverless architecture is an approach where developers build applications by using fully managed services for all the heavy lifting, such that no traditional servers (VMs) are explicitly managed by the development team [9]. In practice, serverless often refers to using Function as a Service (FaaS) for the application logic combined with various Backend as a Service (BaaS) components (cloud services for things like authentication, databases, etc.). In a serverless architecture, you focus purely on code and configuration of managed services, and the cloud platform automatically handles provisioning, scaling, and operating the infrastructure.

    Serverless can be seen as the next step in abstraction beyond PaaS – even more granular and event-driven. We discussed FaaS (like AWS Lambda) earlier. A serverless architecture often uses FaaS as the compute glue and other managed services for stateful parts. For example, consider a simple web application built serverless-ly on AWS: You could have Amazon API Gateway handle HTTP requests (no server), which triggers an AWS Lambda function to run your custom code, which then reads/writes data to Amazon DynamoDB (a serverless NoSQL database), and maybe stores files on S3. The entire pipeline has no server that you maintain – API Gateway, Lambda, DynamoDB, S3 are all managed. The app will scale automatically: if there’s a surge in traffic, API Gateway and Lambda will scale concurrency to handle it (spinning up more function instances), and the database will scale throughput as configured. The user is oblivious to any servers, and you as the developer never think about OS, patching, or even process management.

    Serverless within layered model: In a fully serverless approach, much of the traditional infrastructure and platform layers are completely hidden. They are still there (the provider is running servers and OSes underneath), but they become an internal implementation detail of the services. So you could say in a serverless architecture, the cloud provider is managing layers 1-6 entirely, and the user only provides the application logic at layer 7 (and configurations). Serverless is thus like operating at a higher plane of abstraction within the application layer. It relies on the platform’s capabilities: e.g., AWS Lambda uses containers under the hood (so there’s a containerization and virtualization layer, but it’s fully provider-managed).

    In terms of layering, each serverless component is effectively a specialized PaaS: - The FaaS runtime is a platform that runs your code on demand. - The database (DBaaS like DynamoDB or Firebase) is a platform that stores your data without DB server management. - Authentication can be done via a service like Amazon Cognito or Auth0 (which is effectively SaaS for auth). - If background tasks are needed, one might use a service like AWS Step Functions (a workflow service – which orchestrates functions and other services in a state machine, again no server). - For scheduling, instead of a cron on a VM, you’d use a service like Cloud Scheduler or EventBridge.

    Designing a serverless architecture means orchestrating these pieces. Event-driven design is key: you define how events flow (HTTP request -> triggers function -> function writes to DB -> DB update triggers another function or notification, etc.). This is a different paradigm than a continuously running server handling a queue – the cloud platform itself becomes the “application server”, invoking your code only when needed.

    The benefits of serverless architecture include:

    • No server management – this frees developers to focus on business logic. This can speed up development and reduce ops burden dramatically.
    • Automatic scaling – by default, serverless functions and services scale out when demand increases and scale in to zero (in many cases) when demand is gone, which can be highly cost-efficient (you aren’t paying for idle capacity). For example, if no one is using your API, you pay $0 with Lambda/API Gateway (aside from maybe a minimal always-on cost in some services). This elasticity is perfect for spiky workloads or variable usage patterns.
    • High availability – managed services typically run across availability zones, etc., so a serverless app is inherently highly available without explicit multi-AZ coding.

    There are trade-offs and challenges:

    • Performance: Functions might have a “cold start” latency (a slight delay when a function is invoked after being idle, as the platform has to spin up a container). This may or may not be noticeable depending on the use case.
    • Execution time limits: FaaS often limits how long a function can run (e.g., AWS Lambda max 15 minutes). Long-running tasks might need different design (split into smaller tasks or use a different service).
    • State management: Serverless is inherently stateless in the compute layer (a function execution doesn’t carry state to the next invocation). So you rely on external storage for state (databases, caches). This is good practice anyway, but it means you often need to redesign some algorithms to be stateless or use workflow engines.
    • Monitoring & debugging: With many managed pieces, tracing through a serverless architecture can be complex. Observability tools must capture logs from multiple services (e.g., your function logs, plus any errors from other services). Cloud providers have improved this (like AWS X-Ray can trace through Lambda and other services, and managed logs are available), but it’s a shift from attaching a debugger to a monolithic process.

    A reference example of serverless architecture could be a news website: static content served from Amazon S3 and CloudFront (so no web servers), dynamic interactions (like submitting a comment) go through API Gateway to Lambda functions which use DynamoDB to store/retrieve data, and maybe trigger notifications via Amazon SNS (Simple Notification Service). Another example is an IoT data processing backend: IoT devices send messages to a cloud endpoint (like AWS IoT Core or Azure IoT Hub – those are managed endpoints), which then triggers serverless functions to process data and store results in a database or data lake. No persistent servers are running, yet the system can handle thousands of device messages per second by scaling out functions.

    From a cost perspective, serverless can be extremely efficient because you essentially pay per use. For example, Capital One (a case study we’ll discuss later) has championed a “serverless-first” strategy for many of their applications, using AWS Lambda and managed services to reduce operational complexity and cost – engineers only write small functions, and the platform does the rest. This was part of how they increased innovation velocity (deploying more frequently and scaling easily) while controlling cost.

    In terms of layering: it’s interesting to note that serverless kind of compresses our view of layers – the developer mostly deals at the top (Application logic), and implicitly relies on the platform’s infrastructure and orchestration layers which they don’t see. The cloud provider’s internal architecture for serverless is of course layered (they have an orchestration layer that launches containers on an infrastructure layer upon events), but to the user it appears as if those layers don’t exist – hence “server-less” from the user’s perspective.

    Combining microservices and serverless, one can even implement a microservices architecture in a serverless way: each microservice can be a set of Lambda functions and supporting services that together provide a bounded context. For instance, an e-commerce system’s “Order” service could be composed of a few functions (PlaceOrder, CancelOrder, GetOrderStatus) and a DynamoDB table and perhaps an SNS topic for notifications – all managed, no servers.

    To conclude this section: Microservices and serverless are not mutually exclusive – microservices is an architecture style (break into services), serverless is an execution model (fully managed, event-driven). Many microservices can be deployed on FaaS if stateless and triggered by events. The common theme is both embrace cloud’s strengths: microservices embrace distributed scaling and independent deployment, serverless embraces managed infrastructure and pay-per-use scaling. Both require rethinking traditional monolithic designs and usually go hand-in-hand with DevOps practices for continuous deployment and cloud-native observability. They represent the application layer evolution enabled by cloud computing. The layered cloud architecture supports them: robust infrastructure and platform services at lower layers make it feasible to have dozens of microservices or to quickly spin up ephemeral functions. In turn, microservices and serverless maximize the benefits of those layers – fine-grained scaling, resilience, and agility.


    This page titled 6.7: Microservices and Serverless Architectures in a Layered Model was last modified on Tue, 22 Sep 2026 23:31:59 GMT and is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Felix Amoruwa.