DEV Community

Cover image for what is micro-services architecture
mohamed ahmed
mohamed ahmed

Posted on

what is micro-services architecture

A micro-services architecture is a type of application architecture where the application is developed as a collection of services. each performing discrete and well-defined functions and being deployed independently. they are easier to understand, easier to deploy, and can be shared across different systems.

In terms of architecture, there are two sorts of application systems: the first is a monolith and the second is a distributed system like a micro-services.

Monoliths:
An application is composed of three components: a server, a client, and a database. the server processes client requests, implements business logic, collects or stores data in the database, and responds to the client.
A monolith is a straightforward approach to building a server application. they're made up of classes and functions that let you combine all of your business logic into one running process.

Monolithic systems are ideal for launching a business since they are self-sufficient, offer fast communications their requirements are easy to define and fast development cycle. however, when a business grows, monolithic systems become a challenge. they have low scalability, adaptability and require extensive maintenance. even small errors at any point cause the entire system to crash. they do not allow various teams to work independently and are constrained to be developed on a single technology.

Micro-services:
The micro-service architecture is the solution to the challenges faced by monolithic systems (scaling problems). this system consists of multiple micro-services serving unique services.
Each service is built on :-

  • Business domain centric.
  • High cohesion.
  • Automation (dev-ops cycle).
  • Observable.
  • Resilience.
  • Autonomy.

Micro-services are built on specialized business capabilities. they have their own running process and can even have their own data storage unit. different micro-services can employ different programming languages, different database approaches, and be deployed independently. different teams in the company work on specific services, and updates result in newer versions of the affected micro-services rather than the entire system. and at any point of error, only the affected service will fail. the rest of the programs will work just fine.

Why micro-service architecture?
lets take example:-
if we have e-commerce platform that receive two million request per second. after we did some analysis of this traffic we found 400K request reach the product page. 100K request reach cart page. only 20K reach checkout page. 1000 request that place the order.
in monoliths application we can do this scale if we design it to be stateless app but we scale whole the system at all. so this cost will be high. deployment will be challenge in this case.
in micro-services, we can scale each service standalone, product service not like the checkout service, so we can scale product horizontally with 50 replica. and checkout with 2 replica. note this number not real it just example.
in this case the cost of deployment will be fair.

Many large corporations, such as Amazon, Netflix, Twitter, and Paypal, which began as monolithic systems, were at the forefront of this transformation. its modular approach in application systems is widely being adopted to handle complex applications.

Benefits of using micro-services:-

  • You have the freedom to use different programming languages, tools, technologies, and data-storing strategies based on the requirements of your service.
  • Every micro-service is isolated, results in fast defect isolation too, failure in one micro-services won't affect the rest of the system.
  • You can easily integrate or transition to new technology for a specific micro-service without affecting the whole system.
  • Micro-services are simpler to understand for new developers as compared to understanding the whole system.
  • Different teams in an organization have the freedom to work independently without colliding with other teams.
  • A service can be shared among different products, this saves a lot of resources for an organization.

Drawbacks of using micro-services

  • Troubleshooting can be a very tedious task in micro-services architecture.
  • Handling the entire product might get difficult as the number of services increases.
  • Developer needs to design and develop a lightweight, robust and secure communication system for micro-services to communicate with each other.
  • Internal communication between micro-services increases the time taken by servers to respond to clients.
  • Micro-service add complexity to the project, if the project scope not scale like the above example dont move to micro-service.
  • Time of development, not good if we need to make a prototype to test the business demand for an idea. we can start monolithic and move to Micro-service letter on.
  • Communication between services is complex, everything is now an independent service, you have to carefully handle requests traveling between your modules. In one such scenario, developers may be forced to write extra code to avoid disruption. Over time, complications will arise when remote calls experience latency.
  • More services equals more resources, multiple databases and transaction management can be painful.
  • Use in large scale application if your problem not in scale dont move to it, to avoid adding alot of complexity to the project.

Micro-services development tools and technology:-
As micro-services architecture gained popularity, more and more tools and technologies have emerged to support this practice and improve the developer experience. here are some of the best technologies for developing micro-services:

  • Containerization:-
    one of the most key traits of a micro-service is that it operates independently, as autonomously as possible. To maintain their autonomy, they must be kept in an isolated environment with their own runtime environment. containerization services such as docker, Kubernetes, and others make this feasible. through autonomous container-based micro-service architecture, you have the freedom to add, remove, scale, and replicate components as required by your business.

  • Api management
    With an increasing group of micro-services comes the challenge of establishing safe connections between them. You certainly cannot risk exposing any of your micro-services to public networks. API management, using services like AWS API Gateway, Azure API Management, reduces the time required to build and manage API connections between micro-services. they have various capabilities like authentication services, API monitoring, and so on, which may save developers months of time and work.

  • Continuous integration, continuous deployment (CI/CD)
    If you're adopting micro-services architecture, you don't want a lengthy and costly release train where each team needs to wait their turn. You also don't want the release of one service to impact or be impacted by the release of another. You need to employ continuous integration and continuous deployment pipelines for your micro-services. You can use CI/CD platforms, such as Jenkins and AWS CodePipeline, that provide easy to set up automated but high-velocity releases for your micro-services.

  • Application performance monitoring (APM) tools
    your micro-service is up and running after you design, implement, test, and deploy it, but you're not done yet. You must monitor system performance in order to improve user retention and rid your systems of faults and bottlenecks. Application performance monitoring solutions, such as AWS Cloudwatch, Kibana, Grafana allow you to effortlessly monitor all of your micro-services, as well as increase your mean-time-to-repair by detecting problems sooner.

  • Cloud providers:-
    Managing multiple micro-service can be very challenging, you need a lot of containers, API management tools, host multiple databases, CI/CDs, Application performance monitoring tools, etc. But no worry, most cloud service providers like AWS, Azure, IBM, etc. provide all of this on their platform, which eventually makes managing micro-services lot simple.

Top comments (0)