Cloud Architecture & Services

Chapter 7
Application Architecture and Cloud-Native Services

Certificate in Cloud Computing
Cloud Architecture & Services   •   Certificate

Application Architecture and Cloud-Native Services

Introduction

Cloud computing has changed application architecture from a concern primarily managed within a single data centre into a discipline involving distributed infrastructure, automated operations, elastic capacity, managed platforms, and globally accessible services. A cloud application is not simply a traditional program hosted on a remote server. Its architecture determines how components communicate, how failures are contained, how capacity changes with demand, how data is protected, and how efficiently teams can deliver new capabilities.

This chapter introduces the principal architectural styles used in cloud environments. It explains monolithic and distributed applications, microservices, application programming interfaces (APIs), containers, orchestration, event-driven systems, messaging, serverless computing, and service integration. The emphasis is on practical foundations appropriate to cloud practitioners: understanding trade-offs, selecting suitable services, and designing systems that are reliable, secure, observable, and maintainable.

Learning Objectives

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

  • distinguish monolithic, distributed, microservice, and event-driven architectures;
  • explain the purpose and design principles of APIs;
  • describe containers and the role of orchestration platforms;
  • compare synchronous messaging, asynchronous messaging, and event streams;
  • explain serverless computing and identify suitable use cases;
  • integrate cloud services while managing identity, reliability, data, and governance;
  • evaluate architectural trade-offs in a realistic application scenario.

1. Application Architecture as a System of Decisions

Application architecture is the planned structure of software components, data stores, interfaces, deployment units, and operational processes. It specifies responsibilities and relationships rather than merely listing technologies. Architectural decisions should be driven by business requirements and quality attributes such as:

  • Availability: the proportion of time a service is usable;
  • Performance: response time, throughput, and resource efficiency;
  • Scalability: the ability to handle increased workload;
  • Reliability: the ability to perform correctly over time;
  • Security: protection of confidentiality, integrity, and availability;
  • Maintainability: ease of modifying, testing, and operating the system;
  • Cost efficiency: achieving required outcomes without unnecessary expenditure.

These qualities can conflict. A highly distributed system may scale well but introduce network latency, operational complexity, and more failure points. A simple monolith may be inexpensive and easy to test but difficult to scale selectively. There is therefore no universally best architecture.

A useful architectural boundary is the service boundary: a unit with a clear responsibility, interface, ownership model, and data policy. Boundaries should reflect business capabilities and minimize unnecessary coupling. A component that changes for the same reasons as another component may reasonably remain together; components with different change rates or scaling requirements may deserve separation.

2. Monolithic and Distributed Architectures

2.1 Monolithic architecture

A monolithic application is deployed as one principal unit, even if its internal code is organized into modules. A typical web monolith contains presentation, business logic, and data-access functions in a single deployable application connected to a database.

Monoliths have important advantages:

  • local function calls are faster and simpler than network calls;
  • transactions across modules may be easier to implement;
  • testing and deployment can initially be straightforward;
  • operations require fewer moving parts;
  • development is often efficient for a small team and a new product.

Their limitations become more visible as the system grows. A small change may require redeploying the entire application. Components with high demand cannot easily be scaled independently. A defect or resource leak can affect the whole process. Large codebases can also produce organizational coupling, where many teams must coordinate every release.

A modular monolith addresses some of these problems by enforcing internal boundaries while retaining one deployment unit. It is often a strong starting point because it preserves operational simplicity and can later be decomposed where evidence justifies the change.

2.2 Distributed architecture

A distributed application divides functionality among multiple processes or machines that communicate over a network. Examples include a web front end, an authentication service, a product service, a payment service, and several managed data services.

Distribution enables independent scaling, technology choice, fault isolation, and team autonomy. However, a network call is less reliable than an in-process call. Messages can be delayed, duplicated, reordered, or lost; services can be unavailable; and partial failure becomes normal. Distributed design therefore requires explicit timeouts, retries, idempotency, monitoring, and recovery procedures.

The fallacies of distributed computing are assumptions such as “the network is reliable,” “latency is zero,” and “there is one administrator.” Cloud architects must reject these assumptions during design.

2.3 Monolith and distributed architecture compared

CriterionMonolithDistributed architecture
DeploymentOne principal unitMultiple independently deployed units
CommunicationIn-process callsNetwork protocols and messages
ScalingUsually scales as a wholeComponents can scale separately
Failure behaviorFailures may have broad impactFailures may be isolated, but coordination is harder
OperationsSimpler initiallyRequires observability and automation
Best fitSmall or cohesive systemsLarge, independently evolving capabilities

3. Microservices

Microservices architecture structures an application as a collection of small, independently deployable services. Each service normally owns a business capability and exposes a well-defined interface. The term “small” is less important than independent responsibility and deployability.

A good microservice commonly has:

  1. a focused business purpose;
  2. an explicit API or event contract;
  3. independent build and deployment automation;
  4. ownership of its operational behavior;
  5. controlled access to its data;
  6. monitoring for health, performance, and errors.

The principle of database per service does not necessarily mean a separate physical database for every service. It means that a service should control its data model and other services should not bypass its interface by directly modifying its tables. Shared databases create hidden coupling and make independent evolution difficult.

Microservices are not automatically superior. They increase network communication, deployment coordination, security surfaces, logging requirements, and the difficulty of testing end-to-end behavior. A certificate-level practitioner should first ask whether independent scaling, release, ownership, or fault isolation justifies this complexity.

3.1 Resilience patterns

Distributed services require resilience patterns:

  • Timeout: stop waiting after a defined period.
  • Retry: attempt a failed operation again, preferably with bounded exponential backoff and random jitter.
  • Circuit breaker: temporarily stop calls to a failing dependency, allowing it time to recover.
  • Bulkhead: isolate resources so failure in one workload does not exhaust all capacity.
  • Fallback: provide a reduced or cached response when appropriate.
  • Idempotency: make repeated processing produce the same intended result as one processing attempt.

Retries must be used carefully. Retrying a non-idempotent payment request may create duplicate charges unless the request includes an idempotency key and the service records the result.

4. APIs and Service Contracts

An application programming interface is a defined means by which one software component requests data or action from another. An API contract specifies operations, inputs, outputs, authentication, error behavior, limits, and compatibility expectations.

Common API styles include:

  • REST: uses resource-oriented HTTP operations such as GET, POST, PUT, PATCH, and DELETE. It is widely understood and suitable for many web integrations.
  • GraphQL: allows a client to request a shaped data response through a query schema. It can reduce over-fetching but requires careful authorization and query-complexity controls.
  • gRPC: commonly uses strongly typed contracts and efficient binary communication, making it useful for internal service-to-service calls.
  • Webhooks: allow a provider to send an HTTP notification when an event occurs.

A sound API should use meaningful resource names, consistent status and error codes, validation, authentication, authorization, rate limiting, and documentation. Versioning may be implemented through a URL, header, or compatible evolution of the contract. Additive changes are usually safer than removing or changing the meaning of existing fields.

API gateways provide a controlled entry point for cross-cutting capabilities such as TLS termination, authentication, routing, throttling, request logging, and sometimes response transformation. A gateway should not become an opaque location for excessive business logic.

5. Containers and Orchestration

A container packages an application and its dependencies into an isolated user-space environment that shares the host operating system kernel. It is lighter than a virtual machine because it does not normally include a separate guest kernel. Images should be immutable, versioned, reproducible, and built from trusted minimal base images.

Containers improve consistency between development, testing, and production. They do not automatically provide security. Risks include vulnerable dependencies, excessive privileges, exposed secrets, insecure images, and weak host isolation. Good practice includes non-root execution where possible, image scanning, signed artifacts, restricted permissions, and regular patching.

Running a few containers manually is possible, but large systems need orchestration. An orchestrator schedules workloads, restarts failed containers, performs service discovery, manages configuration, supports rolling deployments, and may scale replicas. Kubernetes is a prominent example; cloud providers also offer managed container platforms.

Important orchestration concepts include:

  • Desired state: the declared number and configuration of workloads;
  • Scheduler: selects suitable compute capacity;
  • Service discovery: gives clients a stable way to locate changing instances;
  • Health probes: distinguish whether a process is alive and ready to receive traffic;
  • Rolling deployment: replaces instances gradually;
  • Autoscaling: adjusts capacity in response to metrics or events.

A liveness check should identify whether a process must be restarted. A readiness check should identify whether it should receive traffic. Confusing these checks can cause cascading failures during dependency outages.

6. Event-Driven Architecture and Messaging

In an event-driven architecture, components communicate by producing and consuming events. An event records that something happened, such as OrderPlaced or ShipmentDispatched. The producer need not know every consumer, which supports loose coupling and asynchronous processing.

A message queue generally delivers work to one consumer or one consumer group. It is suitable for tasks such as image processing or sending email. A publish-subscribe system distributes a message to multiple subscribers. An event stream retains an ordered sequence for a period, allowing consumers to read at their own pace and replay data.

Key concepts include:

  • At-most-once delivery: a message is delivered zero or one time; loss is possible, but duplicates are avoided.
  • At-least-once delivery: a message is delivered one or more times; consumers must tolerate duplicates.
  • Exactly-once effects: the business outcome occurs once, usually through transactions or idempotent processing. This is stronger and more difficult than merely claiming exactly-once message delivery.
  • Dead-letter queue: stores messages that repeatedly fail processing.
  • Ordering: messages may be ordered only within a queue, partition, or key rather than globally.
  • Back-pressure: slowing producers or buffering work when consumers cannot keep up.

An event should contain a unique identifier, event type, occurrence time, producer, schema version, and relevant business data. Consumers should validate schemas and handle unknown fields to support evolution.

Synchronous APIs are appropriate when a caller needs an immediate response, such as checking an account balance. Asynchronous messaging is appropriate for long-running, interruptible, or independently scalable work. A common architecture combines both: an API accepts a request and places a durable command on a queue, while a worker performs the task and publishes an event.

7. Serverless Computing

Serverless computing is a cloud execution model in which the provider manages servers, runtime infrastructure, and much of the scaling. The customer supplies code, configuration, and usually a trigger. Function-as-a-service platforms run short-lived functions in response to HTTP requests, schedules, queues, or events. Serverless also includes managed services such as databases, object storage, workflow engines, and API gateways.

Benefits include rapid delivery, automatic scaling, reduced infrastructure administration, and payment commonly based on requests or execution. Limitations include cold-start latency, execution limits, provider-specific interfaces, distributed debugging, concurrency controls, and potentially unpredictable cost at high volume.

Serverless functions should generally be stateless. Persistent state belongs in a database, object store, cache, or message service. Functions should be small, idempotent where possible, secured with least privilege, and instrumented with correlation identifiers.

A simple cost model can support preliminary comparison. If a function is invoked N times, runs for t seconds per invocation, and consumes m gigabytes of memory, its billed compute quantity is approximately:

Compute quantity = N × t × m

Here, the unit is gigabyte-seconds. This is only a planning model; actual pricing may include request charges, free tiers, architecture differences, concurrency, provisioned capacity, and other services. It should not replace the provider’s current pricing documentation.

8. Service Integration and Cloud Architecture

Service integration connects application components, cloud-managed services, external systems, identity providers, and operational tools. Integration should be designed deliberately rather than created through ad hoc credentials and point-to-point calls.

A practical integration approach includes:

  1. Define ownership: identify which service owns each business decision and data set.
  2. Choose communication: use synchronous APIs for immediate queries and asynchronous messaging for decoupled work.
  3. Secure identities: use workload identities, short-lived credentials, encryption in transit, and least-privilege policies.
  4. Manage secrets: store them in a managed secret store and rotate them; never embed them in source code or images.
  5. Control network paths: use private connectivity where appropriate and restrict ingress and egress.
  6. Observe interactions: propagate correlation IDs and record structured logs, metrics, traces, and audit events.
  7. Plan failure: specify timeouts, retries, dead-letter handling, compensating actions, and recovery procedures.
  8. Manage contracts: document schemas, compatibility rules, ownership, and deprecation dates.

8.1 Reliability and capacity considerations

For a service with average arrival rate λ requests per second and average processing time S seconds, a basic estimate of concurrent work is:

Concurrency ≈ λ × S

This is an application of the relationship commonly known as Little’s Law, L = λW, under reasonably stable conditions. Here, L is the average number of items in the system, λ is the average arrival rate, and W is the average time in the system. The estimate assumes a stable long-run system and consistent units; it does not by itself determine required capacity or response-time percentiles.

For example, at 20 requests per second with an average processing time of 0.25 seconds, estimated concurrent work is 20 × 0.25 = 5 requests. Engineers still need capacity for bursts, failures, queues, and slow-tail requests.

Availability also depends on architecture. If two required components are independent and both must be available, the combined availability is approximately:

Asystem = A1 × A2

where A1 and A2 are component availability values expressed as proportions. If either component’s failure does not prevent service operation, this multiplication model is not applicable. Redundancy, shared dependencies, correlated failures, and maintenance arrangements must be considered in a real availability analysis.

9. Illustrative Case: Online Food Ordering Platform

Background

The following is a fictional illustrative case. FreshRoute is a growing online food-ordering platform. Its initial application is a modular monolith handling menus, customer accounts, orders, payments, and delivery updates. During evening peaks, order traffic rises sharply. Releases are becoming slow, and a failure in delivery integration sometimes affects checkout.

Problem and analysis

The business requires fast checkout, reliable payment processing, independent scaling of menu browsing, and timely delivery notifications. The team discovers that the monolith shares one database and makes synchronous calls to an external delivery provider. A provider timeout holds application threads, increasing the impact of the failure.

The team does not immediately rewrite the entire system. It identifies boundaries based on business ownership and operational need. Menu browsing is read-heavy and can scale independently. Payment requires strong control and idempotency. Notifications can be processed asynchronously.

Approach and solution

The team retains the modular monolith for customer accounts and core order administration. It introduces:

  • an API gateway for authentication, routing, throttling, and consistent external access;
  • a menu service with a read-optimized data store and cache;
  • a payment adapter that uses an idempotency key for each payment attempt;
  • a queue for delivery requests, preventing a delivery-provider delay from blocking checkout;
  • workers that consume delivery messages and publish DeliveryStatusChanged events;
  • a notification function triggered by those events;
  • container orchestration for the menu service and workers;
  • centralized logs, metrics, traces, and correlation IDs.

The queue uses at-least-once delivery, so the delivery worker records the event identifier before applying a non-repeatable action. Failed messages move to a dead-letter queue for investigation. Timeouts and bounded retries protect the platform from a slow external provider.

Outcome

Menu capacity can be increased independently during peak browsing periods. Checkout no longer waits synchronously for delivery confirmation. Operators can see where a request failed, and delivery messages can be replayed after correcting a defect. The architecture still contains a monolith, but the most urgent scaling and reliability problems have been addressed without an unnecessary full migration.

Learning points

The case demonstrates that cloud-native architecture is evolutionary. A modular monolith, selected managed services, containers, queues, and serverless functions can coexist. Decomposition should follow measurable business and operational needs, not fashion. Asynchronous integration improves isolation but requires idempotency, monitoring, schema management, and operational ownership.

10. Governance, Security, and Ethical Considerations

Cloud-native systems process personal, financial, and behavioral data. Architects must apply privacy principles such as data minimization, purpose limitation, retention control, and appropriate access restriction. Regulatory obligations vary by jurisdiction and industry; examples may include data-protection, payment, health, or financial requirements.

Security responsibilities include identity and access management, encryption, vulnerability management, secure software supply chains, audit logging, backup protection, and incident response. API rate limits can reduce abuse, while input validation and authorization checks prevent common attacks. Logs should avoid unnecessary personal data and should themselves be protected.

Managed services reduce infrastructure work but do not remove accountability. Organizations must understand provider responsibilities, service-level commitments, data locations, exit options, and dependency risks. Cost governance is also an ethical and operational concern: unbounded autoscaling or unused resources can create financial harm and environmental waste.

AI-enabled services may assist with code generation, log analysis, and operational recommendations. They should be used with human review, protected data handling, provenance checks, and testing. Generated code can contain vulnerabilities or unsuitable licenses; automated recommendations should not be treated as authoritative without validation.

11. Best Practices and Contemporary Direction

Effective cloud-native design commonly follows these practices:

  • begin with requirements and quality attributes rather than technology selection;
  • prefer the simplest architecture that meets current needs;
  • automate build, test, security scanning, deployment, and rollback;
  • design for failure and test recovery safely;
  • use immutable artifacts and infrastructure as code;
  • make interfaces explicit and backward compatible;
  • apply least privilege and short-lived credentials;
  • measure user-visible outcomes, not only infrastructure utilization;
  • use traces and correlation IDs across service boundaries;
  • establish ownership for every service, queue, schema, and alert.

Contemporary development includes platform engineering, internal developer platforms, managed Kubernetes, event streaming, workflow orchestration, confidential computing, and WebAssembly-based workloads. These technologies may improve productivity or isolation, but they also introduce new skills, costs, and governance requirements. Their adoption should be justified through measurable outcomes.

Chapter Summary

Application architecture defines how software responsibilities, data, interfaces, deployment units, and operational practices fit together. Monoliths provide simplicity and can be modularized before decomposition. Distributed architectures and microservices support independent scaling and ownership but introduce network failure, coordination, and observability challenges. APIs make service contracts explicit, while containers package applications consistently and orchestration platforms manage their lifecycle.

Event-driven systems and messaging decouple producers and consumers, but delivery semantics, ordering, duplication, back-pressure, and dead-letter handling must be designed explicitly. Serverless computing reduces infrastructure administration and suits event-triggered workloads, although cold starts, limits, portability, and cost require evaluation. Secure service integration depends on identity, secrets management, contract governance, observability, and failure planning. The most reliable cloud architecture is not the most fashionable one; it is the simplest design that meets justified business, technical, and governance requirements.

Key Terms

API: A defined interface through which software components communicate.

API gateway: A managed entry point that routes, secures, and governs API traffic.

Asynchronous messaging: Communication in which the sender does not wait for immediate processing completion.

Availability: The degree to which a service is usable when required.

Circuit breaker: A resilience mechanism that temporarily stops calls to a failing dependency.

Container: An isolated packaging and execution unit sharing the host operating system kernel.

Event: A record that a significant occurrence has happened.

Event stream: A retained sequence of events that consumers can process independently.

Idempotency: The property that repeating an operation produces the same intended result as performing it once.

Microservice: An independently deployable service focused on a business capability.

Monolith: An application deployed as one principal unit.

Orchestration: Automated scheduling, scaling, discovery, and lifecycle management of workloads.

Publish-subscribe: A communication model in which publishers send messages and multiple subscribers receive them.

Queue: A messaging structure that buffers work for consumers.

Readiness probe: A health check indicating whether a workload should receive traffic.

Serverless computing: Cloud execution in which the provider manages most server infrastructure and scaling.

Service contract: An agreement defining an interface’s inputs, outputs, behavior, and compatibility rules.

Timeout: A limit on how long an operation waits for completion.

Workload identity: An identity assigned to an application or service for controlled resource access.

Review Questions

Short Answer Questions

  1. What is the principal difference between a monolithic and a distributed application?
  2. Why is idempotency important when using at-least-once message delivery?
  3. State two responsibilities commonly performed by an orchestrator.
  4. What is the purpose of an API contract?
  5. Give one benefit and one limitation of serverless computing.

Long Answer Questions

  1. Compare monolithic, modular-monolithic, and microservices architectures for a small organization.
  2. Explain how containers and orchestration work together in a cloud environment.
  3. Describe the differences among queues, publish-subscribe systems, and event streams.
  4. Explain how timeouts, retries, circuit breakers, and dead-letter queues contribute to resilience.
  5. Discuss the security and governance responsibilities involved in integrating managed cloud services.

Analytical / Application Questions

  1. A service receives 40 requests per second and has an average processing time of 0.15 seconds. Estimate concurrent work using L ≈ λW. What additional information would be needed before selecting capacity?
  2. Design an architecture for a document-processing application in which users upload files, processing may take several minutes, and users should receive completion notifications. Justify your choices of storage, messaging, compute, and observability.
  3. A payment service is called synchronously by an order service, but payment-provider delays cause order requests to time out. Propose a revised integration design and explain how it handles duplicate requests, failures, and user-visible status.

Multiple Choice Questions with Answers

Question 1

Which characteristic most strongly distinguishes a microservice from merely a small software module?

A. It is written in a modern programming language

B. It is independently deployable and owns a focused business capability

C. It always has its own physical server

D. It never communicates over a network

Correct Answer: B. It is independently deployable and owns a focused business capability

Question 2

What is the primary purpose of a readiness probe?

A. To determine whether a workload should receive traffic

B. To encrypt all application data

C. To calculate cloud cost

D. To build a container image

Correct Answer: A. To determine whether a workload should receive traffic

Question 3

Which messaging model is most suitable when several independent consumers should receive the same notification?

A. Publish-subscribe

B. Single-consumer queue only

C. Local procedure call

D. Virtual machine snapshot

Correct Answer: A. Publish-subscribe

Question 4

Why should a payment operation commonly use an idempotency key?

A. To increase image size

B. To prevent repeated requests from creating repeated business effects

C. To eliminate the need for authentication

D. To guarantee zero network latency

Correct Answer: B. To prevent repeated requests from creating repeated business effects

Question 5

Which statement about serverless functions is correct?

A. They require the customer to patch the underlying host operating system

B. They are generally suitable for event-triggered, stateless processing

C. They cannot use persistent storage

D. They always have zero execution cost

Correct Answer: B. They are generally suitable for event-triggered, stateless processing

Question 6

A system receives 20 requests per second and each request takes 0.25 seconds on average. Using L ≈ λW, what is the estimated concurrent work?

A. 0.05 requests

B. 5 requests

C. 20.25 requests

D. 80 requests

Correct Answer: B. 5 requests

Question 7

What is a principal risk of using unbounded retries between distributed services?

A. They can amplify overload and cascading failure

B. They permanently remove all latency

C. They make authorization unnecessary

D. They guarantee exactly-once processing

Correct Answer: A. They can amplify overload and cascading failure

Question 8

Which statement best describes a container?

A. A complete physical data centre

B. A package containing an application and dependencies that generally shares the host kernel

C. A database transaction protocol

D. A replacement for all API contracts

Correct Answer: B. A package containing an application and dependencies that generally shares the host kernel

Question 9

What is the main architectural benefit of asynchronous messaging?

A. It guarantees that every message is processed instantly

B. It can decouple the sender from immediate availability of the consumer

C. It eliminates the need for monitoring

D. It prevents all duplicate messages

Correct Answer: B. It can decouple the sender from immediate availability of the consumer

Question 10

Which practice best supports secure cloud service integration?

A. Embedding long-lived credentials in source code

B. Using least-privilege workload identities and managed secret storage

C. Allowing every service administrative access

D. Disabling audit logs to improve performance

Correct Answer: B. Using least-privilege workload identities and managed secret storage

Cloud Architecture & Services
Chapter 7 of 14