Microservices concepts, Monolithic vs Microservices,
Docker deployment and Microservices source code in C#
https://github.com/KPCodeLearning/MicroservicesAPICoreDocker
https://www.linkedin.com/in/karmanjayverma/
2. INTRODUCTION
• Microservices is a architecture in which a large application is split up into a set of
smaller services.
• Each service runs in its own process and communicates with other processes by
using protocols like HTTP/HTTPS, WebSocket, or Advanced Message Queuing
Protocol (AMQP).
• Each microservice implements a specific, end-to-end domain or business
capability within a certain context boundary.
• Each microservice must be developed autonomously and must be independently
deployable. Finally, each microservice should own its related domain data model
and domain logic.
• Microservices can be based on different data storage technologies (SQL, NoSQL)
and different programming languages.
3. CHARACTERISTICS OF MICROSERVICES
• They're small, independent, scalable independently and loosely coupled.
• Each microservice has a separate code base that a small development team can
manage.
• They're deployed independently. A team can update an existing microservice without
rebuilding and redeploying the entire application.
• They persist their data or the external state in their respective databases. Unlike in a
monolithic architecture, microservices don't share databases.
• They communicate with each other by using well-defined APIs. Internal implementation
details of each service are hidden from other services.
• They support polyglot programming. For example, the microservices that make up a
web application don't need to share the same technology stack, libraries, or
frameworks.
4. MONOLITHIC ARCHITECTURE
• A monolithic architecture is a traditional model of a software program, which is built as a
unified unit that is self-contained and independent from other applications.
• Monolithic Architectures serve as a Large-Scale system, this can make things difficult. They
can be cumbersome to work on when it comes to adding new features, implementing
changes to existing functionality, or even removing some unnecessary functionality.
• This architecture is good option for the given below:
• Small scale applications
• There's no need to upgrade technology
• They take less time to hit the market
• Teams are familiar with Monolithic approaches
6. MICROSERVICES ARCHITECTURE
• Microservices architecture is not a good fit for Small-Scale applications that require
a single technology stack, deployment platform, domain area, etc.
• For a large-scale application, there's almost nothing better than this architecture thus far.
• Microservices architectures is good for:
• Large-scale applications
• Required updates of technology
• Different teams with different technical skills (programming languages, frameworks, etc.)
• If you have various domains to tackle
• Individual database connectivity
9. MICROSERVICES WORKING PROCESS
• Identity Provider : Manages the identity information and provides authentication services
within a distributed network.
• CDN : A content delivery network to serve static resources for e.g. pages and web content in
a distributed network.
• Static Content : The static resources like pages and web content.
• API Gateway : Serves as client’s entry point. Single point of contact from the client which in
turn returns responses from underlying microservices and sometimes an aggregated
response from multiple underlying microservices.
• Management : This component is responsible for placing services on nodes, identifying
failures, rebalancing services across nodes, and so forth. Typically this component is an off-
the-shelf technology such as Kubernetes, rather than something custom built.
• Service Discovery : Keeps track of services and service addresses and endpoints.
10. MICROSERVICES VS MONOLITHIC
Aspect Monolithic Architecture Microservices Architecture
Architecture Single-tier architecture Multi-tier architecture
Size Large, all components tightly coupled Small, loosely coupled components
Deployment Deployed as a single unit Individual services can be deployed
independently
DB Connection Single Database connection for all
services
Individual DB for each services
Flexibility Less flexible as all components are
tightly coupled
More flexible as components can be
developed, deployed, and scaled
independently
Communication Communication between
components is faster
Communication may be slower due
to network calls
11. MICROSERVICES VS MONOLITHIC
Aspect Monolithic Architecture Microservices Architecture
Scalability Horizontal scaling can be
challenging
Easier to scale horizontally
Technology Limited technology choices Freedom to choose the best
technology for each service
Fault Tolerance Entire application may fail if a
part fails
Individual services can fail
without affecting others
Real Example Shopify Netflix
13. DOCKER
• Docker is an open-source-platform that can use to automate the deployment of applications
as portable, self-sufficient containers that can run in the cloud or on-premises.
• Docker is also the company that promotes and evolves this technology. Docker as an
organization works in collaboration with cloud, Linux, and Windows vendors, including
Microsoft.
• Docker generally provides a container environment, in which any application can be hosted.
Docker Image
• An image is a static representation of the app or service and its configuration and
dependencies.
• The image, when it runs, becomes the container. The container is the in-memory instance of
an image.
• A container image is immutable. After you build an image, the image can't be changed.
14. DOCKER
• Because you can't change an image, if you need to make changes to the app or service and
its dependencies, create a new image.
• This feature guarantees that the image you use in production is the same image that's used
in development and testing.
Dockerfile
• A Dockerfile is a text file that contains instructions for how to build a Docker image.
• Dockerfiles are written in a minimal scripting language that's designed for building and
configuring images.
• Dockerfiles also document the operations that are required to build an image, starting with
a base image.
15. ORCHESTRATOR
• An orchestrator is an application management tool that helps you manage, scale, and
maintain a containerized application.
• Orchestrator tracks and logs everything every robot does, along with everything people do
with robots, so you can keep compliant and secure.
• Since, each microservice owns its model and data. The microservice is autonomous from a
development and deployment point of view. These kinds of systems are complex to scale
out and manage. Therefore, to have a production-ready and scalable multi-container
application, you absolutely need an orchestrator.
17. MONOLITHIC, SOA & MICROSERVICES
• Monolithic Architecture: It is "like a big container" where all the software components of an
application are bundled together tightly. It is usually built as one large system and is one
code-base.
• SOA (Service-Oriented Architecture): It is a group of services interacting or communicating
with each other. Depending on the nature of the communication, it can be simple data
exchange or it could involve several services coordinating some activity.
• Microservice Architecture: It involves structuring an application in the form of a cluster of
small, autonomous services modeled around a business domain. The functional modules can
be deployed independently, are scalable, are aimed at achieving specific business goals, and
communicate with each other over standard protocols.
18. COUPLING & COHESION
• Coupling refers to the degree of interdependence between software modules. High coupling
means that modules are closely connected and changes in one module may affect other
modules. Low coupling means that modules are independent, and changes in one module
have little impact on other modules.
• Cohesion refers to the degree to which elements within a module work together to fulfill a
single, well-defined purpose. High cohesion means that elements are closely related and
focused on a single purpose, while low cohesion means that elements are loosely related
and serve multiple purposes.
• Both coupling and cohesion are important factors in determining the maintainability,
scalability, and reliability of a software system. High coupling and low cohesion can make a
system difficult to change and test, while low coupling and high cohesion make a system
easier to maintain and improve.
19. VM VS DOCKER
• VMs
• Virtual machines (VMs) provide virtualization of an entire machine (server).
• A virtual machine emulates the hardware components of a physical machine, such as the
CPU, memory, network interface card, USB controllers, and sound cards.
• You can run a guest operating system and multiple applications in the virtual environment.
• Docker
• Docker lets you run an application on any operating system. It uses isolated user-space
instances known as containers.
• Docker containers have their own file system, dependency structure, processes, and
network capabilities.
• The application has everything it requires inside the container and can run anywhere.
Docker container technology uses the underlying host operating system kernel resources
directly.
20. THANK YOU FOR THE ATTENTION 😊
HAPPY CODING !!!
Sample Source Code for Microservices