0% found this document useful (0 votes)
16 views15 pages

Devops Ut2

The document discusses monolithic applications and microservice architecture, highlighting their characteristics, advantages, and disadvantages. Monolithic applications are tightly coupled and deployed as a single unit, while microservices are independent, decentralized services that enhance scalability and resilience. It also covers best practices for microservices implementation and cloud computing concepts, including deployment models and service models.

Uploaded by

Tejas jundre
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views15 pages

Devops Ut2

The document discusses monolithic applications and microservice architecture, highlighting their characteristics, advantages, and disadvantages. Monolithic applications are tightly coupled and deployed as a single unit, while microservices are independent, decentralized services that enhance scalability and resilience. It also covers best practices for microservices implementation and cloud computing concepts, including deployment models and service models.

Uploaded by

Tejas jundre
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Monolithic Applications

A monolithic application is a traditional software development model where an entire application


is built as a single, unified unit. All its components—such as the user interface (UI), business logic,
and data access layer—are tightly coupled and run as a single process.

Architecture and Characteristics:

1. Single Codebase: The entire application's source code is managed in a single repository.

2. Tightly Coupled: Modules are highly interdependent. A change in one part of the
application often requires rebuilding and deploying the entire system.

3. Single Deployment Artifact: The application is deployed as a single file (e.g., a WAR, JAR,
or EXE file). To update any part of the application, the entire monolith must be redeployed.

4. Shared Database: Typically, all features and services within the application share a single,
large database schema.

5. Technology Stack: The entire application is usually built using a single technology stack
(e.g., a Java Spring application with an Angular front-end and a MySQL database).

For example, a traditional e-commerce website could be a monolith where user management,
product catalog, shopping cart, and payment processing are all part of the same codebase, run in
the same process, and share one database. While simple to develop and deploy initially,
monoliths become difficult to scale, maintain, and update as they grow in complexity.

Introduction to Microservice Architecture


Microservice architecture is an architectural style that structures an application as a collection
of small, autonomous, and loosely coupled services. Each service is self-contained, built around
a specific business capability, and can be developed, deployed, and scaled independently.

Core Concepts:

• Decentralization: Unlike a monolith where everything is centralized, microservices


decentralize responsibility. Each service is a mini-application with its own architecture and
data.

• Business Capability Alignment: Services are modeled around business domains. For an e-
commerce app, this could mean separate services for 'User Authentication', 'Product
Catalog', 'Shopping Cart', and 'Payment Gateway'.
• Independent Deployment: Since services are independent, a change to one service
doesn't require redeploying the entire application. This enables faster and more frequent
updates.

• Communication: Services communicate with each other over a network using well-
defined, lightweight protocols like HTTP/REST APIs or asynchronous messaging queues
(e.g., RabbitMQ, Kafka).

• Technology Heterogeneity: Teams can choose the best technology stack (programming
language, database) for their specific service, rather than being locked into a single stack.

This approach promotes agility, scalability, and resilience, allowing large, complex applications to
be managed more effectively by smaller, independent teams.

Implementing a Microservices Architecture


Implementing a microservices architecture involves decomposing a large system into smaller,
manageable services and managing their interactions. This requires careful planning and
addressing several key challenges.

Key Steps and Considerations:

1. Service Decomposition: The first step is to break down the application into services. The
most common approach is decomposition by business capability, where each service
owns a specific business function (e.g., 'Inventory Management'). Another pattern is the
Strangler Fig Pattern, where new microservices are gradually built around an existing
monolith, which is eventually "strangled" out.

2. Database Management: A core principle is decentralized data management. Each


microservice should own its own private database to ensure loose coupling. This is known
as the Database per Service pattern. Sharing databases between services is an anti-
pattern as it creates tight coupling.

3. Service Communication: You must decide how services will communicate.

o Synchronous: Using REST APIs over HTTP is common for request/response


interactions.

o Asynchronous: Using a message broker (like RabbitMQ or Kafka) is ideal for event-
driven communication, which improves resilience and decouples services.
4. API Gateway: An API Gateway acts as a single entry point for all client requests. It routes
requests to the appropriate microservice, handles cross-cutting concerns like
authentication and rate limiting, and can aggregate results from multiple services.

5. Service Discovery: In a dynamic environment, services need a way to find each other's
network locations. A Service Discovery mechanism (e.g., Eureka, Consul) acts as a registry
where services register themselves and discover others.

6. Observability: With many moving parts, you need robust monitoring, logging, and tracing
to understand system behavior and diagnose issues that span multiple services.

Pros and Cons of a Microservice Architecture


Microservice architecture offers significant advantages in flexibility and scalability but also
introduces operational complexity.

Pros (Advantages):

1. Improved Scalability: Individual services can be scaled independently based on their


specific resource needs, rather than scaling the entire application.

2. Technology Heterogeneity: Teams are free to choose the most appropriate technology
stack (language, database) for their service, fostering innovation.

3. Enhanced Resilience (Fault Isolation): If one service fails, it doesn't necessarily bring
down the entire application. The rest of the system can continue to function, degrading
gracefully.

4. Faster Deployment Cycles: Services can be deployed independently, enabling continuous


integration and continuous delivery (CI/CD) and speeding up time-to-market for new
features.

5. Better Organization Alignment: Small, autonomous teams can take full ownership of a
service, from development to deployment and maintenance, increasing accountability
and speed (Conway's Law).

Cons (Disadvantages):

1. Operational Complexity: Managing a distributed system with many services is much more
complex than managing a monolith. It requires sophisticated automation and tooling for
deployment, monitoring, and management.
2. Distributed System Challenges: Developers must deal with the complexities of distributed
computing, such as network latency, fault tolerance, and data consistency across services.

3. Testing Complexity: End-to-end testing is more challenging as it requires multiple services


to be running and communicating correctly.

4. Increased Resource Overhead: Running many services, each with its own runtime
environment, can consume more memory and CPU resources than a single monolithic
application.

Characteristics of Microservice Architecture


Microservice architecture is defined by a set of key characteristics that distinguish it from
monolithic and other service-oriented architectures.

1. Componentization via Services: Services are out-of-process components that


communicate over a network (e.g., via HTTP APIs), rather than being in-process libraries
linked into a program.

2. Organized around Business Capabilities: Each service is designed to fulfill a specific


business need, such as 'shipping logistics' or 'user profile management'. This aligns the
architecture with the business domain.

3. Decentralized Governance: Teams have the freedom to choose their own technology
stacks and tools. There is no single, mandated standard, allowing for the best tool to be
used for each job. This is in contrast to the centralized governance of a monolith.

4. Decentralized Data Management: Each microservice is responsible for its own data and
typically has its own dedicated database. This ensures loose coupling and allows each
service's data model to evolve independently.

5. Smart Endpoints and Dumb Pipes: Microservices themselves contain the domain logic
("smart endpoints"), while the communication channels between them are simple and
passive ("dumb pipes"), like basic HTTP requests or messages in a queue. Complex
communication logic is avoided in the transport layer.

6. Design for Failure: Microservice-based applications are built with the understanding that
services can and will fail. They incorporate patterns like circuit breakers, timeouts, and
bulkheads to ensure that the failure of one component doesn't cascade and take down
the entire system.
7. Infrastructure Automation: Due to the large number of services, a high degree of
automation is required for building, testing, deploying, and operating the system.
Continuous Integration (CI) and Continuous Delivery (CD) are essential.

Monolithic Applications and Microservices Compared


Here is a comparison between monolithic and microservice architectures across several key
factors:

Feature Monolithic Architecture Microservice Architecture

A single, tightly coupled unit. All


A collection of small, independent, and
Architecture components are part of one large
loosely coupled services.
application.

The entire application is deployed as a Services are deployed independently. A


Deployment single artifact. A small change requires change only requires redeploying the
redeploying everything. specific service.

Scaling is done by replicating the entire


Individual services can be scaled
application on multiple servers
Scalability independently based on their specific
(horizontal scaling), which can be
needs, which is more efficient.
inefficient.

Limited to a single, homogeneous Polyglot architecture. Different services


Technology
technology stack for the entire can be written in different languages
Stack
application. and use different databases.

Slower to set up initially due to


Initially fast, but slows down
Development distributed complexity, but maintains
significantly as the codebase grows and
Speed development velocity as the system
becomes more complex.
grows.

High. Failure in one service is isolated


Low. A failure in a single component can
Fault Tolerance and typically does not affect the rest of
bring down the entire application.
the application.
Feature Monolithic Architecture Microservice Architecture

Simple to develop and manage initially. High operational complexity. Managing


Complexity Complexity is managed within the a distributed system of services,
codebase. networks, and data is challenging.

Export to Sheets

Microservices Best Practices


To successfully build and maintain a microservices architecture, teams should adhere to a set of
best practices that promote resilience, scalability, and maintainability.

1. Single Responsibility Principle (SRP): Each microservice should be small and focused on
doing one thing well. It should be built around a specific business capability and have a
single reason to change.

2. Loose Coupling, High Cohesion: Services should be loosely coupled, meaning a change in
one service should not require changes in others. Logic within a single service should be
highly cohesive, meaning all its internal parts are closely related and work together to
provide its functionality.

3. API-First Design: Define the service's API (its "contract") first, before writing the
implementation. This contract should be stable. This allows teams to develop services that
depend on it in parallel.

4. Decentralize Everything: Embrace decentralization not just for technology stacks and data
(database per service), but also for decision-making. Empower individual teams to own
their services fully.

5. Automate Everything: The complexity of microservices demands automation. Implement


robust Continuous Integration/Continuous Delivery (CI/CD) pipelines to automate testing,
building, and deploying services.

6. Design for Failure: Assume services will fail. Implement resilience patterns like:

o Circuit Breakers: To prevent a client from repeatedly trying to call a failing service.

o Timeouts and Retries: To handle slow or temporarily unavailable services.

o Bulkheads: To isolate resources used by one service call from others.


7. Embrace Observability: You can't fix what you can't see. Implement comprehensive
logging, monitoring, and distributed tracing to get a clear view of how the entire system
is behaving and to quickly diagnose problems that span multiple services.

Deployment Strategies
Deployment strategies are methods for releasing new software versions into a production
environment. Choosing the right strategy is crucial for minimizing downtime and risk, especially
in microservices and cloud environments.

1. Blue-Green Deployment:

o How it works: You maintain two identical production environments, "Blue" (the
current live version) and "Green" (the new version). Traffic is directed to the Blue
environment. To deploy, you install the new version in the Green environment, test
it, and then switch the router to direct all traffic from Blue to Green.

o Pros: Instantaneous rollback (just switch traffic back to Blue), no downtime.

o Cons: Requires double the infrastructure resources, which can be expensive.

2. Canary Deployment:

o How it works: You gradually roll out the new version to a small subset of users (the
"canaries") before making it available to everyone. You monitor the new version
for errors or performance issues. If it performs well, you gradually increase the
percentage of traffic it receives until all users are on the new version.

o Pros: Low-risk, allows for real-world testing, easy to roll back if issues arise.

o Cons: Can be slow to roll out completely, more complex to manage traffic routing.

3. Rolling Deployment:

o How it works: The new version is slowly deployed by replacing instances of the old
version one by one (or in small batches) with instances of the new version. During
the process, a mix of old and new versions will be running simultaneously.

o Pros: No downtime, no need for duplicate infrastructure.

o Cons: Rollback is more difficult than with Blue-Green. The application must
support running old and new versions at the same time, which can be complex.
Introduction to Cloud Computing
Cloud computing is the on-demand delivery of IT resources over the Internet with pay-as-you-go
pricing. Instead of buying, owning, and maintaining physical data centers and servers, you can
access technology services, such as computing power, storage, and databases, from a cloud
provider like Amazon Web Services (AWS), Google Cloud, or Microsoft Azure.

According to the National Institute of Standards and Technology (NIST), cloud computing has five
essential characteristics:

1. On-demand Self-service: A user can unilaterally provision computing capabilities, such as


server time and network storage, as needed automatically without requiring human
interaction with each service provider.

2. Broad Network Access: Capabilities are available over the network and accessed through
standard mechanisms that promote use by heterogeneous client platforms (e.g., mobile
phones, tablets, laptops).

3. Resource Pooling: The provider's computing resources are pooled to serve multiple
consumers using a multi-tenant model, with different physical and virtual resources
dynamically assigned and reassigned according to consumer demand.

4. Rapid Elasticity: Capabilities can be elastically provisioned and released, in some cases
automatically, to scale rapidly outward and inward commensurate with demand. To the
consumer, the capabilities available for provisioning often appear to be unlimited.

5. Measured Service: Cloud systems automatically control and optimize resource use by
leveraging a metering capability. Resource usage can be monitored, controlled, and
reported, providing transparency for both the provider and consumer.

Cloud Computing Deployment Models


Cloud computing deployment models define how cloud services are made available to users. The
four main models cater to different security, management, and business requirements.

1. Public Cloud:

o Description: The cloud infrastructure is owned and operated by a third-party cloud


service provider (e.g., AWS, Azure, GCP) and is made available to the general public
over the internet. Resources are shared among multiple organizations (multi-
tenancy).
o Use Case: Best for businesses that need to scale rapidly, have fluctuating demand,
or want to offload infrastructure management.

2. Private Cloud:

o Description: The cloud infrastructure is provisioned for exclusive use by a single


organization comprising multiple consumers. It can be located on-premises or
hosted by a third-party provider. The organization has complete control over the
environment.

o Use Case: Ideal for government agencies, financial institutions, or any organization
with strict security, data privacy, and regulatory requirements.

3. Hybrid Cloud:

o Description: This model combines a private cloud with one or more public cloud
services, with proprietary technology enabling data and application portability
between them.

o Use Case: Allows organizations to leverage the scalability of the public cloud for
non-sensitive operations while keeping sensitive data and applications on-
premises in a private cloud. This offers the "best of both worlds."

4. Community Cloud:

o Description: The cloud infrastructure is provisioned for exclusive use by a specific


community of consumers from organizations that have shared concerns (e.g.,
mission, security requirements, policy, and compliance considerations).

o Use Case: Suitable for collaboration between different organizations in the same
industry, such as a group of universities or healthcare providers sharing a common
platform.
Cloud Computing Service Models
Cloud service models define the different levels of service and management offered by a cloud
provider. They are often visualized as a pyramid, with each layer abstracting away more of the
underlying complexity.

1. Infrastructure as a Service (IaaS):

o Description: This is the most basic category. The provider offers fundamental
computing resources like virtual machines, storage, and networking. The user is
responsible for managing the operating system, middleware, and applications.

o Analogy: You get the land and utilities; you have to build your own house.

o Examples: Amazon EC2, Google Compute Engine, Microsoft Azure Virtual


Machines.

2. Platform as a Service (PaaS):

o Description: The provider offers a platform that allows customers to develop, run,
and manage applications without the complexity of building and maintaining the
underlying infrastructure. The provider manages the OS, servers, and networking,
while the user manages their applications and data.

o Analogy: You rent a furnished house; you just bring your personal belongings.

o Examples: Heroku, Google App Engine, AWS Elastic Beanstalk.

3. Software as a Service (SaaS):

o Description: The provider offers ready-to-use software applications over the


internet, typically on a subscription basis. The provider manages everything—the
infrastructure, platform, and the software itself. The user simply consumes the
service.

o Analogy: You book a hotel room; everything is managed for you.

o Examples: Google Workspace, Salesforce, Microsoft 365, Dropbox.


Why to Use Cloud
Organizations adopt cloud computing for a wide range of strategic benefits that go beyond simple
cost savings. The key reasons include:

1. Cost Efficiency: The pay-as-you-go model eliminates the need for large upfront capital
expenditure (CapEx) on hardware and data centers. Companies convert CapEx to
operating expenditure (OpEx) and only pay for the resources they consume.

2. Scalability and Elasticity: The cloud allows businesses to scale resources up or down
almost instantly in response to changing business demand. This elasticity prevents over-
provisioning and ensures performance during peak loads.

3. Agility and Speed: Developers can provision resources in minutes, drastically reducing the
time it takes to get applications up and running. This accelerates innovation and shortens
development cycles, providing a competitive advantage.

4. Global Reach: Major cloud providers have data centers located all around the world. This
allows businesses to deploy their applications closer to their end-users, reducing latency
and improving user experience.

5. Enhanced Reliability and Disaster Recovery: Cloud providers offer robust, built-in backup
and disaster recovery solutions. By replicating data across multiple geographic locations,
they ensure high availability and business continuity even if a primary site fails.

6. Focus on Core Business: By outsourcing infrastructure management to a cloud provider,


businesses can free up their IT teams to focus on strategic initiatives and developing
applications that add direct value to the business, rather than managing hardware.

Principle of Container-Based Application Design


Container-based application design revolves around packaging an application and all its
dependencies into a standardized, isolated, and portable unit called a container. This approach is
guided by several key principles to maximize its benefits.

1. Single Concern per Container: Each container should have a single responsibility and run
a single process. For example, a web application container should not also run the
database. This makes containers lightweight, easier to manage, and simple to replace or
scale.

2. Immutability: Containers should be treated as immutable artifacts. Once a container


image is built, it should not be changed. To update the application, you build a new image
with the desired changes and deploy new containers from it, replacing the old ones. This
ensures consistency across all environments (dev, test, prod).

3. High Observability: Applications running in containers must be designed to be easily


monitored. They should expose health checks, write logs to standard output (stdout) and
standard error (stderr), and export metrics in a format that can be consumed by
monitoring tools.

4. Lifecycle Conformance: The application inside the container should be aware of and
respond to lifecycle events from the container runtime or orchestrator. For example, it
should handle the SIGTERM signal to shut down gracefully, finishing any in-progress work
before exiting.

5. Image Layering: Containers are built from images, which are composed of read-only
layers. This principle encourages reusing common layers (like the base OS) across different
images, which makes builds faster and storage more efficient.

6. Portability: Containers encapsulate the application and its dependencies, ensuring that it
runs consistently regardless of the host environment. The design principle is "build once,
run anywhere."

Introduction to Docker
Docker is an open-source platform that automates the deployment, scaling, and management of
applications within lightweight, portable units called containers. It allows developers to package
an application with all its dependencies—libraries, system tools, code, and runtime—into a single
object.

Key Components of the Docker Ecosystem:

• Docker Engine: This is the core component, a client-server application that builds, runs,
and manages containers. It consists of a daemon process (the server), a REST API, and a
command-line interface (CLI) client.

• Dockerfile: A text file that contains a set of instructions on how to build a Docker image.
It specifies the base image, commands to install dependencies, files to copy, and the
command to run when the container starts.

• Docker Image: A read-only, immutable template used to create containers. It is built from
the instructions in a Dockerfile. Images are stored in a Docker registry.
• Docker Container: A runnable, live instance of a Docker image. It is a lightweight,
standalone, executable package that is isolated from the host system and other
containers. You can create, start, stop, move, and delete containers.

• Docker Registry: A repository for storing and distributing Docker images. Docker Hub is
the default public registry, but organizations can also host their own private registries.

By containerizing applications, Docker solves the "it works on my machine" problem, ensuring
consistency from development to production.

Serverless Computing
Serverless computing is a cloud execution model where developers can build and run applications
without having to manage the underlying servers. The term "serverless" is a misnomer; servers
are still used, but they are completely abstracted away from the developer. The cloud provider is
responsible for provisioning, managing, and scaling the server infrastructure required to run the
code.

The most common form of serverless computing is Function as a Service (FaaS).

Key Characteristics and Concepts:

1. No Server Management: Developers focus solely on writing application code (as


individual functions) and do not need to worry about provisioning, patching, or managing
servers, operating systems, or runtimes.

2. Event-Driven Execution: Code is executed in response to specific triggers or events. An


event could be an HTTP request from an API gateway, a new file upload to cloud storage,
a new message in a queue, or a scheduled timer.

3. Automatic and Fine-Grained Scaling: The platform automatically scales the application by
running the function for each trigger. It can scale from zero instances (when there is no
traffic) to thousands of parallel instances to handle peak loads.

4. Pay-per-Execution Pricing: You are billed only for the resources consumed while your code
is actually running, measured in milliseconds. You do not pay for idle time, making it
extremely cost-effective for applications with intermittent or unpredictable traffic.

Examples of serverless platforms include AWS Lambda, Google Cloud Functions, and Microsoft
Azure Functions.
Orchestration
Orchestration is the automated configuration, coordination, and management of complex
computer systems, services, and software. In the context of modern cloud-native applications
(especially microservices), orchestration specifically refers to the automation of the entire
lifecycle of containers at scale.

An orchestration tool, such as Kubernetes or Docker Swarm, acts like the conductor of an
orchestra, ensuring all the individual containers (the musicians) work together harmoniously to
run a complex application (the symphony).

Key Responsibilities of a Container Orchestrator:

• Provisioning and Deployment: Automating the deployment of containerized applications


based on declarative configuration files.

• Scaling: Automatically scaling the number of running containers up or down based on CPU
utilization or other custom metrics.

• Service Discovery and Load Balancing: Helping containers discover each other and
distributing network traffic among them to ensure no single container is overloaded.

• Health Monitoring and Self-Healing: Continuously monitoring the health of containers


and automatically restarting or replacing any that fail, ensuring application availability.

• Configuration and Secret Management: Managing application configuration and sensitive


data (like passwords and API keys) securely and injecting them into containers at runtime.

• Storage Orchestration: Automatically mounting and managing storage systems, whether


on-premises or from cloud providers.

Difference Between Orchestration and Automation


While often used interchangeably, orchestration and automation are distinct concepts, where
orchestration is a broader, more strategic application of automation.

Automation:

• Definition: Automation refers to making a single, specific task or a linear sequence of


tasks repeatable without human intervention.

• Scope: It is tactical and focuses on one component or system.

• Nature: It answers the question, "How do I perform this one task automatically?"
• Example: Writing a shell script that automatically installs and configures a web server on
a virtual machine. The script executes a defined set of steps from start to finish.

Orchestration:

• Definition: Orchestration is the process of coordinating multiple automated tasks across


different systems to execute a complex, end-to-end workflow or business process.

• Scope: It is strategic and holistic, involving many moving parts and decision-making logic.

• Nature: It answers the question, "How do I connect all these automated tasks to achieve
a larger goal?"

• Example: Deploying a complete microservices-based e-commerce platform. This involves


orchestrating several automated tasks: provisioning a Kubernetes cluster (Task 1),
deploying the product catalog service (Task 2), deploying the payment service (Task 3),
configuring the API gateway and load balancers (Task 4), and setting up monitoring
dashboards (Task 5).

Key Distinction: The primary difference lies in the scope and intelligence. Automation is about
making a single task hands-free. Orchestration is the "brain" that pieces together multiple
automated tasks, adding logic, sequencing, and coordination to deliver a complete service or
application. In essence, automation is a tool, while orchestration is the process that uses that
tool (and many others) to achieve a complex outcome.

You might also like