Cloud Architecture & Virtualization

Chapter 5
Cloud-Native and Application Architecture

Post Graduate Program in Information Technology
Cloud Architecture & Virtualization   •   Post Graduate

Cloud-Native and Application Architecture

Introduction and Context

Cloud computing has changed application architecture from a model centred on individually managed servers to one centred on continuously provisioned, observable and programmable services. Cloud-native architecture is not simply the migration of an existing application to a cloud provider. It is an approach to designing, building and operating software so that it can exploit elasticity, automation, distributed infrastructure and managed services while remaining reliable and governable.

The principal architectural choices in this chapter are closely related. A microservice may expose an API; services may communicate synchronously or through events; containers provide packaging and process isolation; orchestration schedules and manages containers; service discovery locates changing service instances; and a service mesh provides communication policies and telemetry. Serverless platforms abstract much of the infrastructure, while twelve-factor principles provide practical guidance for application construction. Domain-oriented design helps determine service boundaries. These technologies are valuable, but none is universally superior to a well-structured monolith.

Learning Objectives

By the end of this chapter, a learner should be able to:

  • distinguish monolithic, modular-monolithic, microservice, event-driven and serverless architectures;
  • decompose an application using domain-oriented design and bounded contexts;
  • design synchronous APIs and asynchronous event flows;
  • explain containers, orchestration, service discovery and service meshes;
  • apply twelve-factor principles to cloud applications;
  • evaluate reliability, security, cost, operational and organizational trade-offs;
  • select an architecture appropriate to business and technical constraints.

1. Architectural Foundations

1.1 Monoliths, modular monoliths and microservices

A monolithic application is deployed as one principal unit. Its components may be poorly separated, or they may be internally modular. The latter is a modular monolith: a single deployable system whose modules have explicit interfaces, separate ownership of data where appropriate, and controlled dependencies.

A microservice architecture decomposes an application into independently deployable services. Each service normally owns a coherent business capability and communicates through explicit contracts. Independent deployment can improve team autonomy and selective scaling, but it introduces distributed-systems problems: network failure, latency, partial availability, consistency challenges, version compatibility and operational overhead.

ArchitectureStrengthsPrincipal risksAppropriate when
MonolithSimple deployment, low communication overheadLarge change scope, weak internal boundariesProduct and team are small or requirements are stable
Modular monolithStrong internal structure with operational simplicityModules still share a deployment lifecycleDomain is understood but independent scaling is unnecessary
MicroservicesIndependent deployment and scaling; team autonomyDistributed failure, observability and data complexityCapabilities have clear boundaries and sufficient operational maturity
Serverless functionsElastic execution and low infrastructure managementPlatform coupling, runtime limits and distributed tracingWorkloads are event-driven, bursty or short-lived
Event-driven systemLoose temporal coupling and high fan-outDifficult tracing, ordering and duplicate handlingAsynchronous business reactions are important

The “distributed monolith” is an important anti-pattern. It consists of services that must all be deployed together, make numerous synchronous calls, share databases and cannot operate independently. It has the complexity of microservices without their intended autonomy.

1.2 Architecture as a set of trade-offs

Architecture should be evaluated against quality attributes rather than fashion. Relevant attributes include availability, latency, throughput, scalability, security, maintainability, recoverability, portability and cost. These attributes often conflict. For example, duplicating data may improve read latency and availability but increase consistency and governance costs.

A useful decision process is:

  1. identify business capabilities and quality-attribute priorities;
  2. assess team size, skills, delivery independence and operational maturity;
  3. estimate traffic variability, data volume and failure consequences;
  4. select the simplest architecture satisfying the constraints;
  5. validate the choice through prototypes, load tests and operational exercises.

2. Domain-Oriented Design and Service Boundaries

Domain-oriented design begins with the problem domain rather than with technical layers. Domain experts and engineers use domain language to identify capabilities, rules, events and boundaries. A bounded context is a boundary within which a domain model and its terminology have a consistent meaning. For example, “customer” may mean a buyer in Sales, an account holder in Billing and a delivery recipient in Fulfilment. Treating these meanings as one universal object often creates coupling.

A practical decomposition uses:

  • subdomains: areas of business capability, commonly classified as core, supporting or generic;
  • bounded contexts: explicit semantic and ownership boundaries;
  • aggregates: consistency boundaries within which invariants are enforced;
  • domain events: statements that something meaningful has occurred;
  • context maps: relationships such as partnership, conformist integration or anti-corruption layer.

A service boundary should be evaluated using cohesion, coupling, data ownership, change frequency, scaling profile and security responsibility. Splitting by database table or by user-interface screen is usually weaker than splitting by business capability.

An aggregate should be small enough to maintain transactional consistency without requiring frequent distributed transactions. A service should normally own the authoritative write model for its data. Other services may hold projections or caches, but ownership and update authority must be explicit.

3. APIs and Synchronous Communication

An API is a stable contract through which software components interact. A well-designed API communicates resource or capability semantics, validates input, returns meaningful status information, and defines authentication, authorization, error, versioning and observability behaviour.

Important API practices include:

  • use consistent resource names and representations;
  • make safe operations idempotent where possible;
  • use correlation identifiers for tracing;
  • define timeouts, retry rules and rate limits;
  • distinguish client errors from server and dependency failures;
  • publish schemas and compatibility rules;
  • avoid exposing internal database structures as the public contract.

Idempotency is especially important for retried commands. An operation is idempotent if applying it repeatedly has the same intended effect as applying it once. For example, PUT /payments/123 with a complete representation can be designed as idempotent, whereas an unprotected POST /payments may create duplicates when a client retries after a timeout. An idempotency key and durable request record can allow a service to recognize a repeated command.

Synchronous calls are appropriate when the caller needs an immediate answer and the dependency is part of the request’s critical path. Excessive call chains create latency and failure amplification. If a request makes sequential calls with latencies t₁, t₂ and t₃, its dependency-induced latency is approximately:

Ttotal ≈ Tnetwork + t₁ + t₂ + t₃

where T_network represents gateway and transport overhead. This is an approximation; parallel calls, queueing, retries and processing variability may change the observed result. Timeouts should be shorter than the business operation’s maximum acceptable response time, and retries should be bounded because retries can intensify overload.

4. Event-Driven Architecture

In an event-driven architecture, producers publish events and consumers react to them. An event records a fact, such as OrderPlaced, rather than requesting that another component perform an operation. A command expresses intent, such as PlaceOrder; an event expresses a completed or observed fact.

The principal components are producers, brokers or event streams, consumers, schemas and monitoring. Events may be delivered at most once, at least once or, in specialised systems, effectively once under defined conditions. At-least-once delivery is common and requires consumers to tolerate duplicates through idempotency, deduplication keys or transactional processing.

Event-driven systems reduce temporal coupling: a producer need not wait for every consumer. They also support fan-out, replay and independent scaling. Their costs include eventual consistency, schema evolution, ordering constraints, difficult end-to-end tracing and more complex failure recovery.

The transactional outbox pattern addresses a common consistency problem. A service writes its business change and an outbox event record in the same local database transaction. A separate publisher reads the outbox and sends the event to the broker. If publication fails, the record remains available for retry. Consumers must still be idempotent, because publication or acknowledgement can be repeated.

Distributed transactions should not be the default solution. Instead, long-running business processes can use sagas: a sequence of local transactions coordinated through events or an orchestrator. Each step has a compensating action where feasible. Compensation is not always a perfect reversal; for example, a shipped physical product cannot be made “unshipped” simply by issuing a database rollback.

5. Containers and Orchestration

A container packages an application and its dependencies while sharing the host operating system kernel. It is not a complete virtual machine: a virtual machine generally includes a guest operating system, whereas a container uses operating-system-level isolation. Containers improve consistency across development, testing and production, but they do not automatically provide security, resilience or good architecture.

A production container image should be minimal, reproducible, scanned for vulnerabilities, built from trusted sources and executed as a non-root user where possible. Configuration and secrets should be injected at runtime rather than embedded in images.

An orchestrator schedules workloads, maintains desired state, performs health checking, supports rolling deployment and enables service exposure. Kubernetes is a prominent example. Its conceptual resources include workloads, services, configuration objects, secrets, ingress or gateway components, and policies. Orchestration does not eliminate application responsibility: the application must expose meaningful health signals, handle termination, persist data appropriately and tolerate replacement.

A readiness check asks whether an instance can receive traffic; a liveness check asks whether it should be restarted. Confusing these checks can cause outages. A temporarily overloaded but recoverable instance should generally fail readiness, not liveness.

6. Service Discovery and Service Meshes

Service discovery maps a logical service name to currently available instances. Client-side discovery lets the caller select an instance; server-side discovery places selection in a load balancer, proxy or platform service. Registration may be explicit or derived from orchestrator state.

A service mesh moves common communication functions into infrastructure proxies, often called sidecars or node-level proxies. These functions may include mutual TLS, service identity, traffic splitting, retries, circuit breaking, authorization policy and telemetry. The application can therefore focus more on business logic.

A mesh is not a substitute for sound service design. It introduces proxy resource consumption, configuration complexity, new failure modes and a learning burden. Retry policies require particular caution: a mesh that retries every failed request can multiply load and duplicate non-idempotent operations. Mesh policies should be bounded, observable and aligned with application semantics.

Cloud-native request and event architecture Client API Gatewayauthentication Order service Payment service Event brokerevents Synchronous request path plus asynchronous event distribution
Cloud-native request and event architecture
Figure: Cloud-native request and event architecture

Figure: A gateway routes synchronous requests while services publish events through a broker.

7. Serverless Architecture

Serverless computing delegates server provisioning and much infrastructure management to a provider. Function-as-a-service platforms execute functions in response to HTTP requests, schedules, queues or events. Serverless also includes managed databases, workflow engines and other provider-operated capabilities.

Advantages include rapid deployment, automatic scaling, fine-grained billing and reduced infrastructure administration. Limitations include cold-start latency, execution-duration and memory limits, provider dependence, ephemeral execution, concurrency surprises and difficulty testing distributed workflows. Functions should be stateless between invocations, externalize durable state, use least-privilege identities and emit structured telemetry.

Serverless is particularly effective for sporadic workloads, file processing, integration tasks and event transformations. A continuously busy, latency-sensitive service may be cheaper and more predictable as a containerized workload. Cost analysis must include invocation charges, duration, data transfer, managed dependencies, observability and engineering effort—not only the headline function price.

8. Twelve-Factor Principles and Operational Design

The twelve-factor approach proposes principles for portable, independently deployable cloud applications:

  1. one codebase tracked in version control, with many deploys;
  2. explicitly declared dependencies;
  3. configuration stored in the environment;
  4. backing services treated as attached resources;
  5. build, release and run stages separated;
  6. stateless processes;
  7. services exposed through port binding;
  8. concurrency scaled through processes or instances;
  9. fast startup and graceful shutdown;
  10. development, staging and production kept similar;
  11. logs treated as event streams;
  12. administrative tasks run as one-off processes.

These principles are guidance, not a complete architecture. For example, state must not disappear merely because processes are stateless; it should be stored in an appropriate durable service. Modern practice extends the model with supply-chain security, infrastructure as code, policy as code, software bills of materials and explicit observability.

Observability combines logs, metrics and distributed traces. Useful service-level indicators include request latency, error rate, availability, saturation and queue age. A service-level objective specifies a target over a time window. If a service is available for 43,200 minutes in a 30-day month and unavailable for 30 minutes, availability is:

Availability = (43,200 − 30) ÷ 43,200 × 100% ≈ 99.93%

This calculation assumes the measurement window contains exactly 30 days and that downtime is measured consistently. Availability alone does not describe correctness, latency or data integrity.

9. Security, Governance and Responsible Architecture

Cloud-native security should be designed into identity, networks, workloads, software supply chains and data handling. Core practices include least privilege, short-lived credentials, encryption in transit and at rest, secret rotation, image signing and scanning, dependency management, network segmentation, admission policies and centralized audit logging.

API authorization must be checked at the service that owns the protected resource; gateway authentication alone is insufficient. Event payloads should minimize personal data and define retention, access and deletion policies. Regulations may impose requirements for data residency, breach notification, records retention and subject access. Event replay and replicated caches can unintentionally preserve data that a user expected to be deleted.

Governance should balance standardization and autonomy. Platform teams can provide approved templates, paved deployment paths and guardrails, while product teams retain responsibility for business outcomes. Automated policy enforcement is preferable to undocumented manual review, provided that exceptions are auditable.

10. Applied Case: Illustrative Retail Order Platform

Background

A fictional retailer operates a growing online store. Its original application is a monolith with a shared database. Releases are infrequent because changes to pricing, checkout and fulfilment require coordinated regression testing. During campaigns, checkout traffic increases sharply.

Problem

The retailer wants independent scaling and faster delivery, but it has a small platform team and limited distributed-systems experience. A wholesale decomposition into dozens of services would create unacceptable operational risk.

Analysis

Domain workshops identify bounded contexts for Catalog, Pricing, Orders, Payments, Inventory and Fulfilment. Orders and Payments require strong auditability. Inventory updates are frequent and can be eventually consistent for product browsing, but checkout must verify availability. The team also identifies regulatory requirements for payment data and a need for traceable customer actions.

Approach and solution

The retailer first creates a modular monolith with explicit modules and ownership boundaries. Catalog search is extracted as a separately scalable service because its workload differs significantly from checkout. Orders remain a service with an authoritative order store. Payment-provider integration is isolated behind an adapter so that sensitive payment data is tokenized and not stored unnecessarily.

The order service uses a local transaction to persist an order and an outbox record. A publisher emits OrderPlaced. Inventory and fulfilment consume the event using idempotency keys. A saga coordinates reservation, payment authorization and fulfilment initiation. If payment fails, the reservation is released through a compensating action. APIs use correlation identifiers, bounded timeouts and explicit idempotency keys. Containers are deployed through an orchestrator, and readiness checks prevent unready instances from receiving traffic.

Outcome

The retailer gains independent scaling for search and can deploy catalog changes without redeploying checkout. The modular core remains operationally simple. The organization postpones a service mesh because its service count and traffic patterns do not yet justify the additional complexity. Dashboards track latency, error rates, event lag, failed compensations and availability.

Learning points

The case demonstrates evolutionary architecture: boundaries are made explicit before deployment units are multiplied. Eventual consistency is accepted only where business rules permit it. The architecture is driven by domain ownership, quality attributes and organizational capability rather than by a requirement to “use microservices.”

11. Contemporary Developments and Critical Evaluation

Platform engineering increasingly provides internal developer platforms that standardize deployment, identity, observability and policy while hiding unnecessary infrastructure detail. GitOps uses version-controlled declarations and automated reconciliation to manage environments. Progressive delivery techniques—canary releases, blue-green deployment and feature flags—reduce release risk.

Confidential computing, workload identity, software supply-chain attestations and workload egress controls are gaining importance. AI-enabled applications add new architectural concerns: model serving, prompt and data governance, inference cost, nondeterministic outputs, evaluation, privacy and retrieval-system freshness. An AI component should be treated as a dependency with explicit quality, security and fallback requirements, not as an infallible service.

Research and practice continue to debate whether microservices improve productivity universally. Evidence is strongly context-dependent: team topology, architecture fitness, deployment automation and domain complexity mediate the outcome. Consequently, architecture decisions should be documented as hypotheses, measured through delivery and operational metrics, and revisited as system conditions change.

Best-Practice Checklist

  • Begin with business capabilities and bounded contexts.
  • Prefer a modular monolith when independent deployment or scaling is not justified.
  • Assign clear data ownership and avoid shared database writes.
  • Make APIs versioned, observable, secure and explicit about failure behaviour.
  • Design event consumers for duplicates, replay and schema evolution.
  • Use timeouts, bounded retries and circuit breaking deliberately.
  • Build small, reproducible and signed container images.
  • Treat orchestration health checks and graceful shutdown as application concerns.
  • Externalize configuration and secrets; never place credentials in images or source code.
  • Measure availability, latency, errors, saturation, event lag and cost.
  • Automate security and governance while preserving auditable exceptions.
  • Evolve architecture incrementally and retire unnecessary complexity.

Chapter Summary

Cloud-native architecture is an approach to exploiting automation, elasticity, managed services and distributed execution—not a synonym for microservices. Monoliths and modular monoliths remain appropriate when simplicity, rapid learning or limited operational capacity is more valuable than independent deployment. Microservices are justified when domain boundaries, team ownership, scaling needs and operational maturity support them.

Domain-oriented design supplies bounded contexts and business-oriented boundaries. APIs support explicit synchronous contracts, while events enable asynchronous fan-out and temporal decoupling at the cost of eventual consistency and more complex tracing. Containers package workloads; orchestration manages desired state; service discovery locates instances; and service meshes provide communication capabilities but add operational complexity. Serverless reduces infrastructure administration for suitable workloads, while twelve-factor principles guide portable, observable and deployable applications. Security, governance, cost, reliability and organizational capability must be considered throughout the lifecycle.

Key Terms

Cloud-native architecture: Architecture designed to exploit cloud elasticity, automation and managed services.

Modular monolith: A single deployable application with explicit internal modules and controlled dependencies.

Microservice: An independently deployable service organized around a cohesive business capability.

Bounded context: A boundary within which domain language and rules have consistent meaning.

Aggregate: A domain consistency boundary managed through an aggregate root.

API: A defined contract through which software components interact.

Idempotency: Property whereby repeated application of an operation has the same intended effect as one application.

Event: A record of a significant fact that has occurred.

Command: A request or instruction to perform an action.

Eventual consistency: A model in which replicas may temporarily differ but converge if updates stop.

Transactional outbox: Pattern storing a business change and its outgoing event in one local transaction.

Saga: A sequence of local transactions coordinated with compensating actions.

Container: An isolated process package sharing the host operating-system kernel.

Orchestration: Automated scheduling, health management and lifecycle control of workloads.

Service discovery: Mechanism for mapping logical service names to available instances.

Service mesh: Infrastructure layer managing service-to-service communication policies and telemetry.

Serverless: Cloud execution model that abstracts much infrastructure provisioning and management.

Observability: Ability to infer internal system state from logs, metrics and traces.

Twelve-factor application: Application following principles for configuration, deployment, statelessness and operational portability.

Review Questions

Short Answer Questions

  1. What distinguishes a modular monolith from an unstructured monolith?
  2. Define a bounded context and explain why terminology may differ between contexts.
  3. Why must at-least-once event consumers be idempotent?
  4. Distinguish readiness checking from liveness checking.
  5. State two advantages and two limitations of serverless computing.

Long Answer Questions

  1. Compare monolithic, modular-monolithic and microservice architectures using technical and organizational criteria.
  2. Explain the transactional outbox and saga patterns, including the problems they address.
  3. Describe how containers, orchestration, service discovery and service meshes interact in a cloud-native platform.
  4. Discuss the twelve-factor principles and explain how modern supply-chain and security practices extend them.
  5. Evaluate the security, governance and regulatory implications of event-driven architectures.

Analytical / Application Questions

  1. A university registration system has a small team, stable traffic and frequent changes to academic rules. Recommend an architecture and justify why a full microservice decomposition may be inappropriate.
  2. An order API creates duplicate orders when clients retry after timeouts. Design an idempotency and observability approach, including storage and failure considerations.
  3. A media platform experiences unpredictable bursts of image-processing work but has a continuously busy recommendation service. Select appropriate serverless, containerized or modular alternatives for each workload and justify the trade-offs.

Multiple Choice Questions with Answers

Question 1

Which architectural choice most directly reduces operational complexity while preserving strong internal boundaries?

A. Modular monolith

B. Distributed monolith

C. Mesh-only architecture

D. Database-per-function architecture

Correct Answer: A. Modular monolith

Question 2

A bounded context primarily defines:

A. A physical server boundary

B. A consistent domain model and vocabulary

C. A container image size

D. A network encryption algorithm

Correct Answer: B. A consistent domain model and vocabulary

Question 3

Which pattern stores a business change and an outgoing event in the same local transaction?

A. Circuit breaker

B. Saga

C. Transactional outbox

D. Blue-green deployment

Correct Answer: C. Transactional outbox

Question 4

At-least-once event delivery requires consumers to be designed to handle:

A. Only alphabetical ordering

B. Duplicate messages

C. Zero retries

D. Permanent network availability

Correct Answer: B. Duplicate messages

Question 5

A readiness check should normally indicate whether a workload:

A. Should be restarted immediately

B. Can receive traffic

C. Has a valid container image signature

D. Has completed a database backup

Correct Answer: B. Can receive traffic

Question 6

Which statement about containers is correct?

A. Each container necessarily includes a complete guest operating system

B. Containers share the host kernel while providing process isolation

C. Containers automatically provide application-level encryption

D. Containers eliminate the need for orchestration

Correct Answer: B. Containers share the host kernel while providing process isolation

Question 7

If a 30-day month has 43,200 minutes and 30 minutes of downtime, approximate availability is:

A. 90.00%

B. 96.93%

C. 99.93%

D. 99.99%

Correct Answer: C. 99.93%

Question 8

Which principle is central to the twelve-factor approach?

A. Embed production credentials in the application image

B. Store configuration in the environment

C. Require a shared filesystem for all processes

D. Deploy development and production as unrelated systems

Correct Answer: B. Store configuration in the environment

Question 9

A service mesh commonly provides:

A. Business-domain modelling

B. Database schema ownership

C. Service identity, traffic policy and telemetry

D. A replacement for all application tests

Correct Answer: C. Service identity, traffic policy and telemetry

Question 10

Which situation is generally a strong candidate for serverless execution?

A. A continuously busy, latency-sensitive workload with predictable capacity

B. A bursty event-triggered image-processing task

C. A workload requiring unrestricted execution duration

D. A system requiring complete provider independence

Correct Answer: B. A bursty event-triggered image-processing task

Cloud Architecture & Virtualization
Chapter 5 of 15