Thursday, November 10, 2016

Microservices (& SOA)

Service Oriented Architecture:

- Check this http://martinfowler.com/bliki/ServiceOrientedAmbiguity.html
- A way of structuring many related applications to work together, rather than trying to solve all problems in one application.
- SOA means so many different things to different people
    - For some SOA is about exposing software through web services and  expect the various WS-* standards and those that will accept any form of XML over http
    - For some SOA implies an architecture where applications disappear.
      Instead core services  supply business functionality and data separated by UI aggregators - That apply presentations that aggregate together the stuff that core services provide.
     - For some SOA is about allowing systems to communicate over some form of standard structure (usually XML based) with other applications - like CORBA
     - For some SOA is all about using (mostly) asynchronous messaging to transfer documents between different systems.
     Essentially this is EAI without all the expensive EAI (Enterprise Application Integration))vendors locking you in.                 

  - ESB (Enterprise Service Bus)
                - Actually a communication system between mutually interacting software applications in a service-oriented architecture (SOA).
     - https://en.wikipedia.org/wiki/Enterprise_service_bus
     - Primary duties of an ESB are:
          - Monitor and control routing of message exchange between services
          - Resolve contention between communicating service components
          - Control deployment and Versioning of services
          - Marshal use of redundant services
          - Cater for commodity services like
                    - Event handling,
                    - Data transformation and mapping,
                    - Message and event queuing and sequencing,
                    - Security or exception handling,
                    - Protocol conversion and
                    - Enforcing proper quality of communication service               

Understanding Microservice Architecture:

In short,
 - 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 centralised management of these services, which may be written in different programming languages and use different data storage technologies.

In Detail:
First,
Software built as microservices can, by definition, be broken down into multiple component services.
-   So that each of these services can be deployed, tweaked, and then redeployed independently without compromising the integrity of an application.
Its downsides, includes expensive remote calls (instead of in-process calls), coarser-grained remote APIs, and increased complexity when redistributing responsibilities between components.

Second,
- Microservices style is usually organized around business capabilities and priorities and not project
Unlike a traditional monolithic development approach — where different teams each have a specific focus on, say, UIs, databases, technology layers, or server-side logic— Microservice architecture utilizes cross-functional teams. 
The responsibilities of each team are to make specific products based on one or more individual services communicating via message bus.

Third,
Microservices act somewhat like the classical UNIX system: they receive requests, process them, and generate a response accordingly.
This is opposite to how many other products such as ESBs (Enterprise Service Buses) work, where high-tech systems for message routing, choreography, and applying business rules are utilized.  You could say that microservices have smart endpoints that process info and apply logic, and dumb pipes through which the info flows

Fourth,
Decentralized governance is favored since involvement of a variety of technologies and platforms, old-school centralized governance aren’t optimal. 
Microservice encourage developers to save time by always using code libraries established by others, while also giving them the freedom to flirt with alternative solutions when needed.
Monolithic systems use a single logical database across different applications.  In a microservice application, each service usually manages its unique database

Fifth,
Like a well-rounded child, microservices are designed to cope with failure.
Since several unique and diverse services are communicating together, it’s quite possible that a service could fail, for one reason or another.  In these instances, the client should allow its neighbouring services to function while it bows out in as graceful a manner as possible

Finally,
Microservices architecture is an evolutionary design and, again, is ideal for evolutionary systems where you can’t fully anticipate the types of devices that may one day be accessing your application.

 To sum up: Microservice architecture
  - Uses services to componentize and is usually organized around business capabilities;
  - Focuses on products instead of projects;
  - Has smart end points but not-so-smart info flow mechanisms;
  - Uses decentralized governance as well as decentralized data management;
  - Designed to accommodate service interruptions;
  - Last but not least, is an evolutionary model

Pros:
- Easily be broken down into multiple component services - I.E. Deployed, tweaked, and then redeployed independently 
- Easy integration and automatic deployment (using open-source continuous integration tools such as Jenkins, Hudson, etc.)
- Usually organized around business capabilities and priorities and not project 
- Better fault isolation: if one micro-service fails, the other will continue to work
- Can be developed by a fairly small team
- Code for different services can be written in different languages 

- Easy to scale and integrate with third-party services


Cons:
 - Partitioning the application into micro-services is very much an art
 - Additional effort into implementing communication between the services (ESB)
 - Integration and managing whole products can become complicated
 - Handling use cases that span more than one service is tough
 - Due to distributed deployment, testing can become complicated 

 - Additional complexity of a distributed system


SOA vs. Microservices
-          Some advocates reject the SOA tag altogether.
-          While others consider microservices to be simply an ideal, refined/special form of SOA.

   Note: SOA Tenents
-          Boundaries are explicit
-          Services are autonomous
-          Services share schema and contract, not class
-          Service compatibility is based on policy
               
- Microservices fulfill at least the first two tenets (with a real emphasis on the second), but it's questionable whether they fulfil the third & fourth.
   The reason the third tenet may not hold for microservices is that one of the characteristics of microservices is that they are generally exposed over a RESTful API, which, one could argue, does not expose contract and schema at all (over and above the regular HTTP verbiage).

- Few differences:
-          SOA usually has more dependent ESBs, with microservices using faster messaging mechanisms. 
-          SOA also focuses on imperative programming, whereas microservices architecture focuses on a responsive-actor programming style.
-          SOA models tend to have an outsized relational database, while microservices frequently use NoSQL or micro-SQL databases
-          Microservices is opposite to how many other products such as ESBs (Enterprise Service Buses) work, where high-tech systems for message routing,  choreography, and applying business rules are utilized.  You could say that microservices have smart endpoints that process info and apply logic, and dumb pipes through which the info flows

Well still the real difference has to do with the architecture methods used to arrive at an integrated set of services in the first place.

Hope this helps.

Reference: https://smartbear.com/learn/api-design/what-are-microservices/

Arun Manglick

















1 comment: