By Admin , May 18, 2024

What are Microservices?

What are microservices? 

In the ever-changing world of software development. Microservice architecture is a pretty revolutionary approach to building complex apps. Unlike monolithic architectures, where all components are tightly coupled, microservices break down an app into smaller, independent services that communicate with each other.

 

Netflix and concept of microservices:

Adrian Cockcroft of Netflix introduced the concept of microservices in 2012. However, this idea has a much longer history. It is a detailed implementation of service-oriented architecture (SOA) combined with domain-oriented design (DDD).

microservices-diagram

This combines SOA and DDD to make components in a system work better together.

It’s easier to maintain a small microservice with one team that knows it well and is focused on a smaller domain.

What is SOA?

SOA is a software design that structures applications as a collection of loosely coupled, reusable services. Each service is a discrete unit of functionality that can be accessed independently and communicates with other services.

For example: 
Business processes within an organization need user authentication. Instead of coding it separately for each process, you can develop a single authentication service and use it across all applications.

Similarly, various financial systems within an organization, such as loan processing systems and investment management platforms, require customer identity verification. Instead of developing separate identity verification modules for each system, a single, centralized identity verification service can be created and utilized by all financial applications.

What Is DDD?

Domain-Driven Design (DDD) is a software development approach that focuses on understanding and modeling the business domain. 

This is a very broad topic regarding a strategic approach where we search for domains and divide them into smaller ones, and a tactical approach where we implement them so that we can easily introduce changes and extend the application using appropriate techniques.

We will cover this topic in another post.

What are the main components of Microservices Architecture?

  • Microservices: These are autonomous, self-contained units that encapsulate specific business functionalities.
  • API Gateway: The API Gateway is the main way for external clients to interact with the microservices. It handles incoming requests, authentication, etc.
  • Service Registry and Discovery:  This component keeps track of all microservices and their network addresses. Service discovery lets services find and talk to each other.
  • Load Balancer: Load balancers distribute network traffic across multiple microservice instances. This ensures an even distribution of workload, optimizing resource use and preventing bottlenecks.
  • Containerization: Docker and other container tools package microservices with their dependencies. Orchestration tools like Kubernetes manage the deployment, scaling, and operation of these containers, ensuring efficient resource utilization.
  • Event Bus/Message Broker: An event bus or message broker helps microservices communicate and coordinate. It lets services publish and subscribe to events, which lets them communicate asynchronously and reduces dependencies.
  • Centralized Logging and Monitoring:  Centralized logging and monitoring tools are essential for tracking the performance and health of microservices.
  • Database per Microservice:  Each microservice has its own database, so data is independent. This lets services manage and scale their data storage, tailored to their needs.
  • Caching:  Caching data near microservices speeds up performance by reducing the need to repeatedly retrieve data from databases.
  • Fault Tolerance and Resilience:  Components like circuit breakers and retry mechanisms let the system manage microservice failures and recover without affecting overall functionality.

What are the Anti-Patterns in Microservices?

  • Data Monolith: Sharing a centralized database among microservices undermines their independence and scalability. Each microservice should have its own database to maintain autonomy and avoid tight coupling.
  • Chatty Services: When microservices communicate excessively for small tasks, it leads to increased network overhead and latency. This can degrade performance and negate the benefits of a microservices architecture.
  • Overusing Microservices: Creating too many microservices for trivial functionalities introduces unnecessary complexity. This can make the system harder to manage and maintain, leading to inefficiencies.
  • Inadequate Service Boundaries: Poorly defined boundaries of microservices result in ambiguity and unclear responsibilities. Properly defining service boundaries is crucial for ensuring that each microservice has a clear and distinct role.
  • Ignoring Security: Neglecting security concerns in microservices can expose the system to vulnerabilities and data breaches. Security should be a top priority in the design and implementation of microservices.

Are Microservices Always the Right Approach?

Think of microservices as small, independent teams within a company. Each team has its own tasks, specialties, and goals. But, just like with teams, questions arise:

  • What are the dependencies between microservices? Which ones are crucial for the entire system to function? Which ones should be prioritized in development and maintenance?
  • How do you ensure smooth collaboration between microservices? Is communication effective? Is there a mechanism for conflict resolution and coordination?
  • Who plays the role of “manager”? In the case of microservices, it’s the system architecture, monitoring tools, and orchestration that must ensure everything runs smoothly.

Breaking down a system into microservices can bring many benefits, such as scalability, flexibility, and the ability to implement changes faster. But this approach also comes with challenges:

  • Complexity: Managing multiple microservices requires additional effort and specialized knowledge.
  • Cost of errors: Problems in one microservice can affect the entire system, which can be costly.
  • Communication: Ensuring effective communication between microservices is a significant challenge.
When to Start with Microservices?

Starting with microservices can be risky, especially for companies that don’t have experience with this architecture. This approach requires organizational and technical maturity. You should first consider a monolith or, preferably, an intermediate, modular monolith.

Microservices are good for large and complex applications if we have an organization with a properly chosen structure where appropriate teams can take care of their domain and services. Another important aspect may be the strong need for different parts of the application to scale differently.

Why Microservices are popular?

  • Scalability – Microservices allow each service to be scaled independently based on its specific needs. This means we can save costs by scaling only what we need.
  • Fault Isolation and Resilience – If one microservice fails, it does not bring down the entire application, which enhances system stability and reduces downtime.
  • Faster Development and Deployment – Microservices let you release new features faster because you can develop, test, and deploy each service separately.
  • Smaller Codebases & Focused Teams – Each microservice has a smaller, easier-to-manage, and understandable codebase.
  • Real-World Adoption – Leading companies like Amazon, Netflix, and Uber have adopted microservices to handle their complex applications, showing how effective the architecture is in real-world scenarios.
  • Business – Microservices let businesses adapt to changing market conditions and customer needs by developing and deploying new features quickly.

Bibiography:

  • https://aws.amazon.com/what-is/service-oriented-architecture/
  • https://en.wikipedia.org/wiki/Service-oriented_architecture
  • https://bykowski.pl/mikroserwisy-wprowadzenie-i-praktyczny-przyklad/
  • https://mindboxgroup.com/pl/mikroserwisy-czym-sa-i-czy-to-rozwiazanie-dla-kazdego/
  • https://pl.wikipedia.org/wiki/Mikroserwisy
  • https://microservices.io/
  • https://learn.microsoft.com/en-us/azure/architecture/guide/architecture-styles/microservices
  • https://www.geeksforgeeks.org/microservices/

Write your comment Here