Apoorva 7th sem seminar Report
Apoorva 7th sem seminar Report
Apoorva 7th sem seminar Report
Report
Of
Seminar
On
“MICROSERVICES IN WEB APPLICATIONS”
This is to certify that the report of the seminar submitted is the outcome of the seminar
work entitled “Microservices in Web Applications” is Bonafide work carried out by
Apoorva Agarwal a student of B-Tech. in Computer Science & Engineering at
Jaipur Engineering College and Research Centre, during the year 2024-25 in
partial fulfillment of the requirements for the award of the Degree of Bachelor of
Technology in Computer Science & Engineering under my guidance.
Place: Jaipur
Date:
VISION OF THE CSE DEPARTMENT
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning of their broader text of technological
change in Computer Science and Engineering.
PROGRAM EDUCATIONAL OBJECTIVES (PEOs)
PSO1: Ability to interpret and analyze network-specific network purity issues, and
automation in the environment
PSO2: Ability to design and develop mobile and web-based applications under
realistic constraints.
7CS7-40 CO-1 3 3 3 2 2 2 1 1 2 2 2 3
Seminar CO-2 3 3 3 3 3 2 1 1 3 2 2 3
CO-3 3 3 3 2 2 2 2 2 3 3 3 3
ACKNOWLEDGEMENT
It has been a great honor and privilege to undergo training at JECRC. I am very
grateful to our guide for giving their valuable time and constructive guidance in
preparing the report for seminar. It would not have been possible to complete this report
in a short period of time without their kind encouragement and valuable guidance.
I wish to express our deep sense of gratitude to our Seminar Guide M. Shubham
Sharma, Jaipur Engineering College and Research Centre, Jaipur for guiding us from
the inception till the completion of the seminar report. We sincerely acknowledge
them for giving their valuable guidance, and support for the literature survey, critical
reviews, and comments for our seminar.
I would like, to, express our thanks to Mr. Arpit Agrawal Director of JECRC, for
providing us with such a great infrastructure and environment for our overall
development.
I express sincere thanks to Dr. V. K. Chandna, Principal of JECRC, for his kind
cooperation and extendible support towards the completion of our seminar. Words are
inadequate in offering our thanks to Dr. Vijeta Kumawat, HOD of the CSE
department, for consistent encouragement and support for shaping our seminar
report in the presentable form.
Also, our warm thanks to Jaipur Engineering College and Research Centre, who
provided us with this opportunity to enhance our learning in various technical fields.
Apoorva Agarwal
21EJCCS038
viii
ABSTRACT
The primary benefit of adopting microservices in web applications lies in their ability to promote scalability
and flexibility. Since each microservice is autonomous, it can be scaled horizontally to meet demand for
specific features or services, without impacting the entire application. This leads to more efficient resource
utilization and faster adaptation to changes in user behaviour or traffic patterns. Additionally, microservices
enable development teams to work independently on different services, allowing for faster development
cycles, streamlined testing, and more effective problem isolation.
Another key advantage is resilience. In a microservices-based system, failure in one service does not
necessarily mean the failure of the entire application. Microservices can be designed with fault tolerance in
mind, enabling other parts of the system to continue operating even if one service is experiencing issues.
This distributed nature makes microservices a suitable choice for mission-critical web applications were
uptime and reliability are paramount.
LIST OF FIGURES
1
1) INTRODUCTION
1.1) OVERVIEW
2
1.2) IMPORTANCE IN WEB APPLICATIONS
3
1.3) PURPOSE OF REPORT
Fig-1
4
The report aims to explain how microservices allow for modularization,
where individual components of a web application can evolve independently,
thus enabling faster development cycles and continuous deployment. It will
also explore how microservices improve the scalability and fault tolerance of
web applications, which are crucial for handling high traffic and ensuring
application uptime. Additionally, the report will examine real-world examples
and use cases where microservices have been successfully implemented,
providing evidence of their effectiveness in large-scale web applications.
Finally, it will highlight the challenges associated with microservices, such as
managing inter-service communication, ensuring data consistency, and
handling operational complexity, offering guidance on how to address these
issues. Ultimately, the goal is to inform decision-makers on whether
microservices are the right architectural choice for their web application
projects.
Fig-2
5
2) UNDERSTANDING
MICROSERVICES
6
2.2) EVOLUTION FROM MONOLITHIC TO MICROSERVICES
grows in size and complexity. Any change to one part of the system typically
As businesses began to face these scalability and agility challenges, the need
7
better fault tolerance—if one service fails, the others can continue
cloud-based applications
Fig-3
8
2.3) CORE PRINCIPLES OF MICROSERVICE ARCHITECTURE
7. Fault Isolation & Resilience: A failure in one microservice does not affect
the entire system. Microservices are designed to be resilient, with techniques
like circuit breakers ensuring minimal impact from failures.
9
8. Automation & DevOps: Microservices thrive in a DevOps environment
Fig-4
10
3) DESIGNING MICROSERVICES
4. User Journeys: For some applications, decomposition may align with user-
facing features or journeys. Microservices could be based on user flows, like a
checkout service or profile management service, focusing on specific parts of
the user experience.
5. Data Ownership: Each microservice should manage its own database to avoid
tight coupling between services. This decentralizes data management and
enhances the independence of each service.
11
7. Inter-Service Communication: Define clear communication methods between
microservices, often using APIs (REST, gRPC) or messaging queues. This
ensures that services remain decoupled while still interacting effectively.
1. Bounded Contexts: One of the core concepts of DDD, bounded contexts, is crucial
in microservices design. A bounded context defines the boundary within which a particular
domain model is valid. In microservices, each bounded context typically corresponds to a
separate microservice. This ensures that services have well-defined responsibilities and that
the complexity of the application is split into manageable, decoupled pieces.
o Example: In an e-commerce system, you might have bounded contexts like Order
Management, Inventory, and Customer. Each of these would become a separate
microservice, with its own data model and logic.
2. Entities and Aggregates: In DDD, entities are business objects with a distinct identity, and
aggregates are groups of entities that are treated as a single unit for consistency and
transactional boundaries. Microservices can model their business logic around these entities
and aggregates, ensuring that each service encapsulates its own business rules and data
consistency.
o Example: An Order microservice might treat an Order and its related Order Items
as an aggregate, ensuring consistency and encapsulating the rules for handling orders.
3. Ubiquitous Language: DDD promotes the use of a shared, ubiquitous language between
business and technical teams. In microservices, this ensures that everyone understands the
12
purpose and scope of each service, reducing ambiguity and promoting better collaboration.
Each microservice’s domain model uses the same terminology that business stakeholders
use, ensuring alignment between business needs and technical implementation.
4. Decentralized Data Management: DDD supports the idea of each bounded context
managing its own data. In a microservices architecture, this leads to decentralized
data management, where each microservice is responsible for its own database, ensuring
loose coupling and better scalability. This avoids the complexity of a shared database and
allows services to evolve independently.
o Example: The Order Management service may use a relational database, while the
Inventory service may use a NoSQL database, each optimized for its specific needs.
5. Domain Events: DDD encourages the use of domain events to communicate state changes
across different parts of the system. In a microservices architecture, services can use domain
events to decouple from one another, making the system more resilient and flexible.
For example, when an order is placed, an OrderPlaced event can be published, which other
services (like inventory and billing) can react to asynchronously.
6. Integration and Communication: DDD helps define clear contracts for communication
between services, typically through APIs (REST, gRPC) or messaging systems (e.g., Kafka).
Services communicate based on their domain models and defined business rules, ensuring a
consistent and well-structured integration between microservices.
1. Service Independence
Service independence means that each microservice is decoupled from others, with
13
minimal dependencies. This allows services to function independently without
affecting the operation of other services in the system. The goal is to ensure that
each service can evolve and be maintained separately, enabling faster development
cycles and reducing the risk of cascading failures.
• No Shared Databases: Each service should manage its own data store and not
rely on a shared database, which can create tight coupling and hinder scalability.
• Independent Deployment: Each microservice should be independently deployable,
meaning updates or changes to one service should not require redeploying the
entire system.
2. Service Autonomy
Service autonomy refers to the ability of a microservice to operate, scale, and recover
independently. Each service should have full control over its internal logic, data, and
dependencies, and should not rely on other services for its basic functionality. Autonomy
allows services to be scaled independently and enables quicker response to failures.
• Independent Scaling: A microservice can scale based on its own load or traffic,
without affecting other services. For instance, if a payment service experiences
high traffic, it can be scaled independently of other services, like the user service.
• Fault Isolation: If a microservice fails, it should not bring down other services.
Autonomy ensures that failures are contained within individual services, increasing
system resilience.
14
3.4) API DESIGN AND VERSIONING
16
not break client interactions. Implementing automated tests can help maintain
API stability over time.
1. Decentralized Data Ownership: Each microservice owns its own database, which
can be tailored to its needs (SQL, NoSQL, etc.). This independence allows services
to evolve and scale without affecting others but requires careful management of
cross-service data consistency.
2. Data Consistency: Microservices often follow eventual consistency, were data
across services is synchronized over time, rather than immediately. This allows for
flexibility but may require mechanisms like sagas or event-driven architectures
to manage distributed transactions. In some cases, strong consistency might be
necessary but can be more complex to implement.
3. Data Duplication: Data may be duplicated across services, with each microservice
maintaining a copy of relevant data. While this improves service independence, it
necessitates mechanisms (e.g., events or change data capture) to ensure data stays
consistent across services.
4. Data Communication: Microservices communicate data either synchronously
(via APIs like REST or gRPC) or asynchronously Asynchronous communication
is often used for decoupling services and maintaining performance.
5. Handling Distributed Transactions: Since microservices typically do not use
traditional ACID transactions across services, patterns like sagas are used to
manage distributed transactions and ensure consistency. If one service fails,
compensating actions are triggered to roll back changes in other services.
6. Data Sharding: To manage large data volumes, services can use data sharding,
splitting datasets across multiple databases or servers. This improves performance
and scalability by distributing data based on criteria like geographic region or
customer ID.
17
4) MICROSERVICE
COMMUNICATION
Use Case Suitable for real-time interactions (e.g., Suitable for background tasks, event-
user login, data queries). driven workflows, or processes that don’t
require immediate responses.
Response Time Immediate response required Delayed response, can continue execution
(blocking). before receiving the reply (non-blocking).
Fault Tolerance More susceptible to failures; if one More resilient; failures in one service do not
service fails, the request is blocked. block other services, retries can be managed.
RESTful APIs are the most common approach for communication between
microservices. They use HTTP as the communication protocol and are based on
standard HTTP methods like GET, POST, PUT, and DELETE to interact with
resources.
• Key Features:
• Advantages:
• Disadvantages:
19
that enables communication between microservices. It uses Protocol
• Key Features:
o Service Definition: APIs are defined using .proto files, which describe
• Advantages:
real-time applications.
• Disadvantages:
20
3. GraphQL
• Key Features:
• Use Cases: GraphQL is ideal for applications where the client needs
front-end applications with dynamic user interfaces (e.g., mobile apps, SPAs).
• Advantages:
o Flexible Queries: Clients can request only the data they need,
• Disadvantages:
querying.
21
4.3) EVENT DRIVEN ARCHITECTURE
can work independently without waiting for immediate responses, and if one
service fails, events can be queued and processed later. However, this
dependencies.
Fig-5
22
4.4) INTER-SERVICE COMMUNICATION PROTOCOL
Inter-service communication in microservices refers to the methods and
microservices.
Each protocol has its advantages, with REST suitable for most CRUD
23
5) TECHNOLOGY STACK
• Java: Popular with frameworks like Spring Boot and Spring Cloud for building
scalable services.
• Python: Frameworks like Flask and Django are used for building microservices with
REST APIs.
2. Service Communication
• GraphQL: Allows clients to request only the data they need, reducing unnecessary data
transfer.
3. Data Management
• NoSQL Databases: MongoDB and Cassandra are used for flexible, scalable data
storage.
• Event Stores: Kafka and EventStoreDB for event sourcing and processing.
• Jenkins and GitLab CI: Automate continuous integration and delivery pipelines.
7. Security
• Jaeger and Zipkin: Provide distributed tracing to monitor and debug requests across
services.
Fig-6 Fig-7
Fig-8 Fig-9
25
6) IMPLEMENTATION IN
WEB APPLICATIONS
6.1) INTRODUCTION
Fig-10
26
6.3) COMMUNICATION BETWEEN SERVICES
27
7) SECURITY IN MICROSERVICES
1. Authentication and Authorization: Use OAuth 2.0, JWT, and OpenID Connect for
secure authentication and authorization between services and clients. This ensures
2. API Security: Protect APIs with HTTPS (TLS), rate limiting, and API gateways
(e.g., Kong). API keys and tokens help authenticate and authorize access to
sensitive endpoints.
can interact. Service meshes like Istio can help manage mTLS and access control.
4. Data Encryption: Encrypt data in transit (via TLS) and at rest (using AES or similar
6. Identity and Access Management (IAM): Apply RBAC or ABAC to enforce least
privilege access and manage service identities with IAM tools like AWS IAM or
HashiCorp Vault.
for vulnerabilities using tools like Aqua Security or Twistlock to ensure secure
deployment
28
8) MONITORING AND MAINTAINANCE
Monitoring and maintenance are crucial for ensuring the performance, reliability,
effective monitoring helps detect issues early, while proper maintenance ensures
8.1) MONITORING
29
8.2) MAINTAINANCE
• Security Patching: Regular updates and patching of both the application and its
underlying infrastructure are essential for preventing vulnerabilities. Use vulnerability
scanners like Aqua Security and Twistlock to keep services secure.
Effective monitoring and ongoing maintenance are vital for the health of a microservices
architecture. By combining health checks, distributed tracing, centralized logging, and
automated deployments with proactive scaling and security patching, organizations can
ensure that microservices remain reliable, performant, and secure over time.
30
9) CHALLENGES
7. Monitoring and Troubleshooting: Gaining visibility into system health and identifying
issues across multiple services requires advanced monitoring and logging solutions.
8. Skill Gaps and Team Structure: Shifting to microservices requires new skill sets, tools,
and team structures, which can be difficult to implement.
9. Cost Overhead: Managing infrastructure for multiple services can lead to increased
resource consumption and operational costs.
31
10) BEST PRACTICE
1. Design for Loose Coupling: Ensure services are independently deployable with minimal
business function.
3. Decentralized Data Management: Each microservice should manage its own database,
following the Database per Service pattern to maintain service autonomy and reduce
coupling.
4. API-First Design: Define clear, versioned APIs for communication between services, using
RESTful APIs or other protocols like gRPC for efficiency and consistency.
(using tools like Kafka or RabbitMQ) to decouple services and improve scalability and
fault tolerance.
7. Centralized Logging and Monitoring: Use tools like ELK Stack, Prometheus, or Grafana
for end-to-end visibility, aggregation of logs, metrics, and traces to monitor service health
and performance.
8. Service Discovery and Load Balancing: Implement service discovery tools (e.g., Eureka,
Consul) for automatic service registration and efficient load balancing to ensure traffic is
evenly distributed.
9. Security Best Practices: Protect microservices with mutual TLS for secure communication,
and enforce OAuth 2.0 and JWT tokens for authentication and authorization.
32
11) FUTURE SCOPE AND CONCLUSION
Conclusion
Microservices have revolutionized the way web applications are developed, enabling faster
time-to-market, better scalability, and more manageable codebases. The architecture's modularity
allows development teams to work independently, deploy faster, and integrate with modern cloud
infrastructures seamlessly. As technologies like Kubernetes, serverless computing, service meshes,
and AI-driven automation continue to evolve, the role of microservices in building robust, scalable
web applications will only grow. While challenges such as data consistency, service orchestration,
and security remain, ongoing advancements will make microservices even more efficient and effective
in the future. Overall, microservices are poised to be a cornerstone of modern web application
development, offering solutions to the demands of high availability, real-time processing, and dynamic
user experiences.
33
12) REFERENCES
34