Professional Documents
Culture Documents
In monolithic architecture, all the components are tightly coupled and run as a single service. Here, the
entire architecture has to be scaled if any one component of the application experiences a spike in
demand. This architecture type increases the difficulty level to implement new ideas in the application.
In Microservices architecture, each component is a small application that has its own hexagonal
architecture. It is an architectural style that structures an application as a collection of services that are
loosely coupled and independently deployable.
FEATURES OF MICROSERVICES ARCHITECTURE
Independent
• In Microservices architecture, each component can be changed, upgraded or replaced
individually without affecting the functionality of other components.
Decentralized
• Microservices architecture follows the decentralized data management, where each
service has its own view on data models.
Autonomous
• In Microservices architecture, there is no need to share any of the component code or
implementation with other components. Any communication between components can
be done via well-defined APIs.
Black Box
• Microservices architecture behaves like a black box because each component hide the
details of complexity from other components.
ADVANTAGES OF MICROSERVICES ARCHITECTURE
Quality
• Microservices architecture can also improve the quality of code as the whole application
is running into small and well-defined components
Scalability
• In Microservices architecture, each component is properly decoupled so it can be scaled
horizontally and independently from each other and it never faces the downtime during
the Scaling process because in horizontal scaling more components are added to the
existing pool instead of increasing the capacity of each component
Easy Development
• Microservices architecture makes it easy to try out new ideas and roll it back with the help
of continuous integration and continuous delivery, if something undesired happens.
Resilience
• With Microservices architecture, applications can handle total service failure by degrading
the functionality instead of crashing the entire application.
CHALLENGES OF MICROSERVICES ARCHITECTURE
Migration
• The Process of migration from a Monolithic architecture to
Microservices architecture is complex and requires to release
code dependencies going down to the database layer.
Testing
• In a Microservices environment, testing is complex due to
different services and their integrations.
Monitoring
• In Microservices architecture application is broken down into
small components. It is difficult to find the root cause of the
problem when something goes wrong because issue may not lie
within the component that fails, but a dependency.
SERVERLESS MICROSERVICES ARCHITECTURE
SERVERLESS MICROSERVICES
ARCHITECTURE
• The diagram shows the Serverless Microservices architecture where the complete solution is built
without managing any server. This also eliminates the operational efforts of running and monitoring the
servers.
• Lambda will handle everything required to run and scale the execution to meet actual demand with high
availability. Lambda supports several programming languages and it can be called directly from any web
or mobile applications.
• In the architecture diagram, Lambda is integrated with API Gateway. Synchronous calls from API gateway
to AWS Lambda enables the application to operate as serverless. AWS Lambda will store all the data in a
fully managed NoSQL database called DynamoDB and all the static data will be stored in S3 Bucket.
• It can be said that Microservices architecture is designed to overcome the challenges of traditional
monolithic architectures seen in enterprise applications. It allows collaboration between operations and
development teams of any organization leading to devops and is a preferred choice nowadays.
• AWS offers multiple managed services that can help engineers build Microservices architectures and
minimize architectural and operational complexity.
How to start with designing Micro services-based
Solution Architecture
• Microservices-based solution architecture is not always the best fit for all use-cases, and using
a one size fits all approach has several drawbacks. Before designing a microservices-based
solution architecture, enterprise solution architects must address the following questions.
• Is Microservices architecture a good fit for the solution?
• How should one define the Microservices Architecture?
1. Decomposition of the application into services
Microservices architecture is a set of loosely coupled services and decomposition of the
application into services plays a key role in microservices architecture implementation,
deployment, and CI/CD.
Solution architects can define the decomposition methods based on need & solution, there are
no “best” methods for decomposition but there are common methods, which can help you to
decompose your solution in several services as mentioned below. To apply decomposition, you
need to understand the need & role of each component, weight/links between several
components and more factors for each component of the entire solution.
Decomposition Strategies:
Decompose by module/business capability: This method suggests defining each component for
each module or feature i.e. messaging, logging, device communication, user management. This
helps you to assign an entire feature/module to separate teams, where respective teams will be
responsible for a module/feature
Decompose by domain: This method suggests defining the region where your solution is going
to be deployed, and further defining the services to that region. Define services corresponding
to Domain-Driven Design (DDD) subdomains. DDD refers to the application’s problem space –
the business – as the domain. A domain consists of multiple subdomains. Each subdomain
corresponds to a different part of the business. E.g. User Management, Device Management,
Device Communication
2. Microservices Discovery and Registration
CICD Strategies:
• Multiple services per instance: Run multiple services on the same host (physical or virtual). E.g.
deploy all NodeJS services on an EC2 instance as separate services. This will work when you are in
development or you have a small number of users accessing your application. As users grow, this
method leads to problems like resource conflicts, Memory & CPU utilization issues, and insufficient
monitoring of service behavior
• Service instance per host: Deploy a single service on each host. This overcomes issues of multiple
services per instance with an effective way to balance the load, such as when the load is high for a
particular service. In such cases, you can scale your deployment to multiple instances for a single
service. This pattern also has one drawback; consider you have one service which does not have
frequent usage i.e dispute of orders, still, this will be deployed on one instance and you can’t utilize
CPU & memory resources from here for another service
• Serverless deployment: Use deployment services which remove server and infrastructure
management. It allows you to zip your package, deploy it on application services and charge you on a
request basis. In this method, you need not worry about resource management and load
management. Design your service to run without the server using public resources like S3 or Azure
storage for file storage, Dynamodb or Azure database as a database, SNS or Event Grid for
communicating between two services, SES as email service. Popular framework components include
AWS lambda, Google Cloud function, Azure functions
9. Microservices Deployment platform
• You can also use a deployment platform to automate the deployment of your
microservices for both serverless & server based models.
• If you have a huge system with multiple integrated services which self-manages
server instances & services, is generally a cost-effective solution. You can use AWS
cloud formation & task definitions with Docker swarm mode & Kubernetes to
automating deployment, scaling & manage all applications centrally. AWS cloud
formation allows you to use a single file to model & provision infrastructure, and
task definition allows you to define several Docker images for your environment.
Once the environment is up, task definition takes care of all services i.e if your
service crashes it would launch anew Docker instance automatically.
• If your solution is small but requires a service, then you can deploy your services
to PaaS platforms like AWS Elastic Beanstalk which allows you to deploy and scale
web applications and services developed with Java, .NET, PHP, Node.js, Python,
Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and
IIS. It charges based on the resources you use.
• To deploy your serverless code you can use several tools like claudia.js which
allows you to automate AWS lambda and api-gateway deployments
Example Implementation:
• Let’s Imagine we are building an IoT solution using a microservice
architecture which includes device connectivity, user management,
alerts & rules engines. In addition to this, the solution must expose
REST API details to third-party applications like Android and iOS.
• As our solution uses microservices architecture, it divides the
solution across multiple services like:
1. API Gateway (e.g. express gateway which provides the secure gateway
(using API key) including several features like rate limit, routes the
request to microservices)
2. Express for API microservices
3. Seneca microservice tool for inter-service communication
4. MongoDB cluster as a database.
5. Redis for service registry & event store
6. Docker, Jenkins & cloud formation for deployment
IoT solution using a micro service architecture