Skip to main content
Microservices
A Developer’s Approach
Topics
• What is Microservices
• Why we need Microservices
• Design a single service
• Building blocks of a Microservice System
• What’s next
@Me
• Foyzul Karim
• Started journey on 2009
• Details on LinkedIn [linkedin.com/in/foyzul]
• Love to make videos [youtube.com/foyzulkarim]
• Love to contribute open source [github.com/foyzulkarim]
• Love to contribute on Facebook [facebook.com/foyzulsacademy]
Microservices
So… What is it?
Brief history
• The term "microservice" was discussed at a workshop of software architects near Venice in
May 2011 to describe what the participants saw as a common architectural style that many of
them had been recently exploring.
• In May 2012, the same group decided on "microservices" as the most appropriate name.
James Lewis presented some of these ideas as a case study in March 2012 at 33rd Degree in
Krakow in Microservices - Java, the Unix Way as did Fred George about the same time.
• Adrian Cockcroft at Netflix, describing this approach as "fine grained SOA" was pioneering the
style at web scale as were many of the others mentioned in this article - Joe Walnes, Daniel
Terhorst-North, Evan Botcher and Graham Tackley.
• Article link: https://martinfowler.com/articles/microservices.html
Microservices
• In short, the microservice architectural style is an approach to developing a single
application as a suite of small services, each running in its own process and
communicating with lightweight mechanisms, often an HTTP resource API.
• These services are built around business capabilities and independently
deployable by fully automated deployment machinery.
• There is a bare minimum of centralized management of these services, which may be
written in different programming languages and use different data storage
technologies.
-- James Lewis and Martin Fowler (2014)
[https://martinfowler.com/articles/microservices.html]
https://martinfowler.com/articles/microservices/images/sketch.png
Single executable project Project 1
Project 2
Project 3
Characteristics of a Microservice System
• Microservices - also known as the microservice architecture - is an architectural style
that structures an application as a collection of services that are
• Highly maintainable and testable
• Loosely coupled
• Independently deployable
• Organized around business capabilities
• Owned by a small team
• The microservice architecture enables the rapid, frequent and reliable delivery of
large, complex applications. It also enables an organization to evolve its technology
stack.
Why we need
Microservices?
And why now? Why we didn’t use this architecture 15 years ago?
Why we need Microservices? Why now?
• Single vendor lockdown era is over
• Different database for different purpose
• Different programming stack for different purpose
• Different software architecture for different purpose
• Scaling is not more multiplying the whole server
• Containers (Lxc, Lxd, Docker etc.)
• Orchestrators (Kubernetes)
• Cloud computing era is in full swing
• Can choose different cloud service in different microservice
• We don’t have luxury to go offline for a minute now a days
• No more outage because of a problematic service
Design a single
micro-service
How do we design a single service?
Designing a single micro-service
• Define the domain boundaries
• Follow Single Responsibility Principal in every level
• Select appropriate tech stack
• Choose programming stack
• Choose database
• Database can only be accessed by it’s parent service
• Expose the api endpoints to be consumed by other services
• Should independently handle the request
• Adapt the architecture for the whole microservices system
Service
DB
Microservices System
What are the building blocks of a microservices system
Building blocks of a Microservices System
• Service to service communication
• Client to service communication
• Service discovery
• Service security
• Service monitoring
• Service containerization
• Service orchestration
• Continuous integration
• Continuous delivery
Service to service communication
• Point to point communication
• HTTP request
• gRPC request
• Asynchronous message-based communication
• Queue
• Service Bus
Http / gRPC request
Service ServiceService
Messaging system
Client to service communication
• API Manager / API Gateways
• Directly call to the service
API
API
API
API
EventBus
API
GatewayClient
API
API
API
API
EventBus
Client
Service discovery
• Mainly applicable for container based architecture
• Register the service into a service registry
API
API
API
API
EventBus
Client/APIM
Service registry
Name: product, Ip: 10.0.0.15
Name: customer, Ip: 10.0.0.16
Name: sales, Ip: 10.0.0.17
Name: identity, Ip: 10.0.0.18
Get product service detail
Service security
• Authentication server
• Handles different types of authentication
• Token based
• Cookie based
• Authorization server
• Fully functional RBAC management system
• Returns true/false depending on the resource request
Service monitoring
• Paid
• Application insight
• Papertrail
• Datadog
• Free
• ELK (self hosted)
Service containerization
• Multiple service to use multiple types of resources
• Different operating system (Linux, Windows etc.)
• Different programming language (C#, Python, JavaScript etc.)
• Different database (SQL Server, MySQL, MongoDB, ElasticSearch etc.)
• Different package versions
• We need the runtime and a thin OS layer to execute the system calls
• Containers here to rescue
• Pack the service (containerize)
• Run it anywhere
• Docker
Service orchestration
• How to build the containers in multiple environments
• How to run the containers in multiple environments
• How to monitor the containers after deployment
• How to troubleshoot the containers
• Kubernetes, Docker Compose etc.
Where to go next?
• Build one from scratch
Questions?
Send email to foyzulkarim@gmail.com
Send message to ā€œFoyzul’s Academyā€ Facebook page