Cloud Computing
Cloud Computing
Anny Leema Associate Professor Sr, Department of Analytics, SCOPE, VIT Vellore
What is a Monolithic Architecture?
Easy deployment
Disadvantages:
Difficult to scale and maintain
12
Service Oriented Architecture (SOA)
SOA was created to solve problems in
monolithic applications.
It breaks a big application into smaller
parts called services.
These services talk to each other through a
central system called the Enterprise
Service Bus (ESB). It is like a central
manager or traffic controller. All
communication goes through the ESB.
Limitations: Services often shared the
same database, which made them
dependent on each other.
Too much control by ESB—if ESB fails,
everything can break.
Services were not always truly
independent.
Service Oriented Architecture (SOA) vs MicroServices
Architecture(MSA)
Microservices is a modern version or evolution of SOA (Service-Oriented
Architecture).It follows many ideas from SOA, but with more independence and less
dependency.
Concept SOA Microservices
SOA is a big service Microservices are tiny
Design
system (like a toolkit). independent tools.
Services talk through ESB Services talk directly to
Communication
(central manager). each other.
Services may share the Each service has its own
Database
same database. database.
Tightly connected (more Loosely connected (less
Dependency
dependencies). dependencies).
What is Microservices?
Each of these runs separately, can be updated on its own, and can
even be built in different programming languages.
Key Characteristics:
Loose coupling
Language-agnostic
Java/Spring Boot +
Customer Service Login, register, profile
MySQL
Show products,
Product Service Node.js + MongoDB
manage inventory
Instead of one big program, you have many small ones. Managing all these
services becomes difficult as the app grows.
Skilled developers are required to work with microservices architecture which
can identify the microservices and manage their inter-communications.
Independent deployment of microservices is complicated.
Microservices are costly in terms of network usage as they need to interact with
each other and all these remote calls results into network latency.
More communication between services means more chances for hackers to attack
if not secured properly.
Debugging is difficult as the control flows over many microservices and to point
out why and where exactly the error occurred is a difficult task.
Microservices Design Patterns and Principles
1. Scalability
2. Flexibility
3. Independent and autonomous
4. Decentralized governance
5. Resiliency
6. Failure isolation
7. Continuous delivery through the DevOps
Microservices design approach/principles
High Cohesion Combined With Loose Coupling
◼ When breaking down a monolithic architecture into smaller services or components, it is
important to combine similar functionalities.
◼ This combination of related logic into a single unit is known cohesion.
◼ The higher the cohesion, the better is the microservice architecture.
◼ A low cohesion would indicate too much communication between different services leading to a poor
system performance.
Unique Source Of Identification
◼ Each item (like Order, User, Product) has a unique ID.
◼ Systems rely on ID instead of full details.
◼ API Integration
◼ Microservices talk to each other using APIs.
◼ They don’t share code — they just send/receive data.
◼ Data Storage Segregation
◼ Any data stored for a specific service should be made private to that specific service and can
be shared with any other service only through an API
Traffic Management
◼ Traffic to different services will vary and a service may run slowly or may be flooded with calls.
Microservices design approach/principles
Automating The Process
◼ Microservices designed independently should be able to function in its
own accord.
◼ The automation would enable self-deployment and function without the
need for any intervention.
Minimal Database Tables
◼ To ensure that the microservice is focused towards business function, a
microservice design should have only a couple of tables even with data
entries running into millions.
Constant Monitoring
◼ establish a process for actively monitoring the storage of the data in a
central location
◼ frequent changes without affecting the performance of the system
While adhering to the principles there are some
standard sets of problems & complex scenarios that
architects and developers need to address.
To solve these problems, they use design patterns
— reusable templates or best practices.
Patterns are predefined solutions, act like
blueprints that save time and help avoid mistakes.
Microservices is not just about breaking an app into
small pieces.
It involves many design decisions: deployment,
communication, data, security, UI, testing, etc.
This diagram gives a complete view of all the key
parts of microservice architecture.
Three building blocks of microservice
architecture.
1. Application Patterns
What it is: How to design and organize microservices.
Discovery).
Use API Gateways to connect outside users.
Infrastructure Patterns
Deployment:
Multiple Services per Host: Deploy many services on one machine (not scalable).
Single Service per Host: Deploy one service per host for isolation and simplicity.
Service-per-Container: Use containers (like Docker) to run each service independently.
Service-per-VM: Run each service on a dedicated virtual machine.
Sidecar: Deploy support functionality like logging or monitoring alongside the main service.
Service Mesh: A layer to handle service-to-service communication, security, and observability.
Serverless Deployment: Deploy functions that run on demand without managing servers.
Service Deployment Platform: Tools to automate deployment, scaling, and updates (e.g., Kubernetes).
Discovery:
Service Registry: A directory of all available services and their locations.
Client-Side Discovery: Client queries service registry to find the service.
Server-Side Discovery: A proxy or load balancer finds the service on behalf of the client.
Self Registration: Services register themselves with the registry when they start.
3rd Party Registration: An external service registers instances with the registry.
1. Service Decomposition Patterns
2. Service Integration Patterns
3. Communication Patterns
4. Database and Transaction Patterns
5. Reliability and Resilience Patterns
6. Security Patterns
7. Observability and DevOps Patterns
Problem Faced in Microservices Solution (Pattern) Example in E-Commerce (ShopEZ)
Order Service asks: “Where’s the Inventory
Services need to talk to each other
Service Discovery Pattern Service?” — Uses a registry (like Eureka)
efficiently
to find it.
If Payment Service is down, Circuit Breaker
Too many requests may crash a weak
Circuit Breaker Pattern stops retrying and shows a fallback: “Try
service
again later.”
One API Gateway routes: /products →
Users must access multiple services API Gateway Pattern
Product Service, /orders → Order Service.
User Service uses MySQL, Catalog Service
Each service needs its own database Database per Service Pattern uses MongoDB. They manage data
separately.
First migrate Product Search into a
Slowly replacing a big old system with
Strangler Pattern microservice. Then migrate Payments,
microservices
Orders, etc.
Placing an order updates inventory,
Need to update multiple services in one go Saga Pattern (for long transactions) payment, shipping — all done step-by-
step with rollback support.
When an order is placed, Order Service
Sending real-time updates between
Event-Driven Pattern sends an event → Inventory Service
services
updates stock automatically.
Adding features like logging, security per Cart Service has a helper container that
Sidecar Pattern
service logs every update, runs security checks.
Circuit Breaker Pattern
The Circuit Breaker Pattern is used in Microservices to protect your system from failure and
overload.
It is a technique used in Microservices architecture to improve the resilience and reliability of
distributed systems.
Circuit Breaker Pattern in software protects your app from crashing when another service is slow
or failing.
The basic idea behind the circuit breaker is very simple. You wrap a function call in
a circuit breaker object, which monitors it for failures.
Once the failures reach a certain threshold, the circuit breaker trips and all further
calls to the circuit breaker return an error, with any further calls skipped.
The Circuit Breaker can also be configured to handle failures in different ways, such
as returning a default value or a cached response.
Function Explanation
If a service is failing, the circuit breaker blocks further
Stops repeated failed calls
calls to avoid wasting time and resources.
It monitors the number of failures (like timeouts, errors) in
Detects failures
service calls.
It waits for a while before trying the failed service again
Waits before retrying
(to see if it’s back).
It prevents one failing service from affecting the whole
Improves system stability
system.
It can return a default value, error message, or cached
Returns fallback responses
data instead of crashing.
Here are the basic steps involved in the Circuit Breaker Pattern:
3.Dynamic Scaling
You can scale (increase or decrease) the number of instances of a microservice independently,
based on demand.
This is a Microservices-based Architecture with the following key
parts:
Clients: Web, Mobile, and PC
API Gateway: Single entry point for all requests
Identity Provider: Manages authentication & authorization
Service Registry & Discovery: Keeps track of microservice locations
Microservices: Modular business logic units (Shopping, Billing, User
Profile, Push Notifications)
Databases: Each microservice has its own DB
In a microservices architecture, the API Gateway acts as a single entry point that receives all incoming
client requests (from web, mobile, or PC) and intelligently routes them to the appropriate microservices
such as billing, shopping cart, or user profile.
The API Gateway relies on an Identity Provider (IdP) such as Google, Keycloak, or Auth0 to manage
authentication (verifying who the user is) and authorization (what the user is allowed to do).
Authentication & Authorization (Login Check)
It checks:
Authentication = Is the user real?
Authorization = What is the user allowed to do?
IdPa token (like a digital ID card), which the gateway checks before sending the request to the
correct service.
Each microservice does one job , they are independent, so each can run, scale, or fail without
affecting the others.
Service Registry & Discovery-Keeps track of where all services are located. When the API
Gateway or another service needs to talk to a microservice, it asks this registry:“Where is the
Billing service running right now?”
Monitoring -Keeps track of how services are performing:Are they up or down?, Are they slow?.Is
there an error?
Three main types of APIs
Open APIs
◼ Publicly available with minimal restrictions to access them.
Partner APIs
◼ Need specific access rights to be able to use them and are typically
exposed via an API developer portal.
Internal APIs
◼ Hidden from external users and only exposed by internal systems.
Two different ways that APIs can be implemented
Simple APIs which are available separately.
Composite APIs, where multiple data or service APIs are
combined together, allowing developers to access several APIs at
a time
Three main types of API protocols
REST(REpresentational State Transfer ) APIs
◼ Provides a uniform interface, where a client and server communicate with
one another via HTTP using URIs, the common Create, Read, Update, and
Delete (CRUD) operations, and most often JavaScript Object Notation
(JSON) conventions for data exchange
SOAP APIs
◼ Simple Object Access Protocol is another type of heavy weight services
API.
RPCs
◼ Request-response protocol, where a client sends a request to a remote
server to execute a specific procedure, and then the client receives a
response back. However, RPC APIs are much more difficult to maintain
and update than REST APIs,
API development Styles
REST, OpenAPI, HTTP, gRPC, GraphQL, and Kafka
Tunnel (used in gRPC)
◼ The API is a collection of functions that can be called remotely
◼ The tunnel style is focused on making specific computer functions available
Resources (used in OpenAPI)
◼ API is a collection of resources that can be interacted with
◼ HTTP that calls an API that’s been written following the OpenAPI specification
Hypermedia
◼ the API is a collection of interlinked resources
◼ HTTP calls to an OpenAPI-described service, with the difference being that the data also includes
controls to link the resources together
Query (GraphQL)
◼ API exposes a structured data model that can be queried and updated by using a generic query
language
◼ API needs to query the large dataset and return just the data needed for that query
Event
◼ the communication pattern is reversed, and the API listens for events instead of asking for
information
Introduction to Java Micro Services
Java Micro services
In a Java-based microservices architecture, the interaction between Spring,
Spring Boot, Spring Cloud, Maven, and REST can be understood in layers,
each playing a specific role in the development, deployment, and
execution of microservices.
Spring Framework (Foundation)
What: A comprehensive framework that provides core features like Dependency
Injection, AOP, and MVC.
Role: Acts as the base layer. It manages bean life cycles, configurations, and
integrates components.
In Microservices: Handles core functionalities like creating REST controllers, data
access, and validation
Annotations: @Component, @Autowired
Java Micro services
Spring Boot (Auto-config & Easy Setup)
What: Built on top of Spring, it simplifies project setup using auto-
configuration, embedded servers, and minimal XML
configuration.
Role:
◼ Starts embedded servers like Tomcat using main() method.
◼ Reduces boilerplate code.
◼ Manages project dependencies via spring-boot-starter-* modules.
In Microservices: Each microservice is typically a standalone Spring
Boot application.
Annotations: @SpringBootApplication
Java Micro services
Spring Cloud (Distributed System Features)
What: Provides tools to manage distributed systems (like microservices) using
Spring Boot.
Features:
◼ Service Discovery with Eureka/Consul
◼ Load Balancing with Ribbon or Spring Cloud LoadBalancer
◼ Circuit Breaker with Resilience4j
◼ API Gateway with Spring Cloud Gateway
◼ Centralized Config with Spring Cloud Config
In Microservices: Helps microservices register, discover each other, and
communicate resiliently
Annotations: @EnableDiscoveryClient
Java Micro services
Spring Cloud (Distributed System Features)
What: Provides tools to manage distributed systems (like microservices) using
Spring Boot.
Features:
◼ Service Discovery with Eureka/Consul
◼ Load Balancing with Ribbon or Spring Cloud LoadBalancer
◼ Circuit Breaker with Resilience4j
◼ API Gateway with Spring Cloud Gateway
◼ Centralized Config with Spring Cloud Config
In Microservices: Helps microservices register, discover each other, and
communicate resiliently
Annotations: @EnableDiscoveryClient
Java Micro services
Maven (Build Tool & Dependency Manager)
What: A build automation tool that manages project structure,
builds, and dependencies.
Role: Defines the project via pom.xml Pulls libraries like Spring
Boot, Spring Cloud, and REST APIs from repositories.
In Microservices: Each service has its own pom.xml and
manages its dependencies independently.
Feature: pom.xml, <dependencies>
Java Micro services
REST (Communication Protocol)
What: An architectural style using HTTP methods (GET, POST,
PUT, DELETE) for communication.
Role: Defines how microservices talk to each other.
◼ Implemented using @RestController in Spring Boot with
@GetMapping, @PostMapping, etc.
In Microservices: Exposes APIs for CRUD operations between
services or with frontend apps.
Annotations: @RestController, @GetMapping
Interaction Flow (Example)
1. Let’s say you are building a Product Microservice:
2. Maven (pom.xml) pulls:
1. spring-boot-starter-web (for REST)
2. spring-cloud-starter-netflix-eureka-client (for service registry)
3. You define a @RestController to expose REST APIs (/products, /products/{id}).
4. You run the app using Spring Boot’s main() class → it launches an embedded
Tomcat server.
5. The microservice registers with Eureka (Spring Cloud) and becomes discoverable.
6. Another microservice (e.g., Order) calls the Product service via REST using the
registered name.
Different ways to implement Microservices
Approach Language Best For Pros Cons
Powerful, integrated
Spring Boot + Spring Cloud Java Enterprise apps Heavy, JVM overhead
ecosystem
Node.js + Express JavaScript Real-time apps Fast, lightweight Weaker type safety
Windows/Enterprise
.NET Core C# High performance Smaller community
systems