Introudction to Microservices

What is a Microservice?

A microservice is a self contained process that provides a unique business capability. Different microservices act in concert as one larger system. Application functionality must be distributed into lightweight, discrete services, where every single service satisfies a particular business-focused interest.  Microservice architectural style is a method to create an application as a set of small services that runs its process and interact with lightweight mechanisms, usually an HTTP resource API. 

Microservice is developed based on business features and deployed independently by an automated deployment machinery. There is less centralized management of Microservices, that may be written in various programming languages and utilize diverse data storage technologies. For example: In an e commerce site, Payment Service could be written in C++, while Order Management Service could be written in Java.




  • Small focused.
  • Loosely coupled.
  • Language neutral.
  • Bounded Context.

Microservice Decomposition

The application is decomposed into microservices based on two categories.
  • Decompose by Business Capability. The services are created based on the business capabilities. For example, in Retailer e-commerce, billing, payment, order management, and promotions are different business capabilities which could be made into separate services.
  • Decompose by Sub-domain. Domain-driven design supports modeling based on the reality of business as akin to use cases.

Monolithic vs Microservice Architecture

Applications are broadly classified into two types:
  1. Monolithic Architecture, where an application is built as a single unit.
  2. Microservices Architecture, where many applications (microservices) handle a small portion of the functionality and data.

monolithic application is built as a single unit, i.e., one big application in a single language that handles all of the functionality, data, business logic, etc. A load balancer distributes requests from the end user, across multiple machines, each running one instance of our application. All logic for handling a request runs in a single process, allowing you to utilize the primary features of the language to divide up the application into classes, functions, and namespaces.

Advantages:
  • Faster Initial Development. With one application, it would be relatively easy to add additional features, especially when the application is relatively small.
  • Little User Confusion. Developers need not have to learn about different applications, but would be focused towards one application.
  • Improved Integration. Features could integrate with each other well and easily.

Disadvantages:
  • Single Point of Failure. If any single application function or component fails, then the entire application goes down. For example - a web application with separate functions handling tasks like payment, login, and history; a function begins to consume more memory or CPU. In this scenario, the entire application will come to a halt.
  • Horizontal Scaling. Scaling application can only be accomplished by deploying the same EAR/WAR packages in more servers. Every single copy of the application in different servers will use the same number of primary resources, which is usually not an effective way to design.
  • Development productivity. As application grows, the code base grows with it, which can overload IDE every time it loads the application. This definitely reduces developer productivity.
  • Substantially less iteration. A small change made to any part of the application, requires the entire monolith to be rebuilt and deployed.
  • Maintenance costs will shoot up exponentially with site size.
  • High set-up costs. In order to get each new volunteer up and running, the larger the application, the more difficult this would be.

microservice application is built as suites of services (Modular approach)
  • Each microservice exposes a common API accessed through the network (as opposed to inter-process communication or shared memory on the same machine).
  • API calls are stitched mostly on the server to produce a page, although few of this work is executed by the client querying individual microservices.

Microservices are independently deployable and scalable. Each service offers a secure module boundary, allowing different services to be written in different programming languages.

Advantages
  • Improved fault isolation: Larger applications can remain largely unaffected by the failure of a single module with microservice style adoption.
  • Removes Dependency: Eliminates long-term commitment to any single technology stack.
  • Easy Understanding: With the split of functionality, it gives more room for new developers to understand the functionality of a service and make enhancements easily.
  • Easy Deployment: Microservices-based applications are deployed inside containers providing better management.
  • Lowered Learning curve.
  • Scale bottlenecks
  • Quicker user acceptance testing.
  • Quicker to market changes.
  • Business Alignment.

Disadvantages:
  • Complexity: Deploying microservices can be a little complex, requiring coordination among multiple services, which may not be as straightforward as deploying a monolith.
  • Multiple DBs: Managing multiple databases and transaction management could be painful.
  • Testing: Testing could be little cumbersome, as each dependent service needs to be confirmed before one can start testing.
  • Coordination: Handling requests across multiple independent services requires proper workflow management. There can be a scenario where one of the services may not be responding or remote calls experiencing latency.
Despite few disadvantages, the benefits of adopting Microservices are a lot more, pushing many enterprise leaders towards this journey.

Microservices vs SOA


Microservice could be considered as a subset of SOA.
    
The 3 C's of Microservices

  • Componentization of single application into multiple serviceable components is the most important activity. Best would be to start by defining a RESTful API to access this service, then plan and create an implementation using comfortable development language and platform.
  • Collaborate. Communication among bigger teams becomes complex, which results in numerous mistakes and curbing the speed of development. Collaboration among teams focuses around API contracts and Technology standardization.
  • Connect. The final delivery of an application requires more than the development of the constituent components. These components must be connected, presentation layer and additional services must be layered in, then the completed application must be delivered to users. Given that microservices must communicate using APIs.

What makes a good Microservice?

  1. It focuses on a single business capability.
  2. Each microservice should have its own data store
  3. Stateless communication. Each pair of of request and response communication makes an independent transaction.
  4. Great microservices should be able to continue if another one fails.

Comentarios

Entradas populares de este blog

U3 - 5. Estrategia y técnicas de negociación integrativa

U3 - 1. Naturaleza de la negociación

U3 - Ensayo de la negociación