Thursday, April 30, 2015

Micro-Services: The Modern Modular Programming Paradigm

Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.
As Service Oriented Architecture (SOA) has become popular the modular programming definition could easily be rewritten to read:
The micro-services style of service oriented architecture is a software design technique that emphasizes separating the functionality of a service into  independent, interchangeable services, such that each contains everything necessary to execute only one aspect of the desired functionality.
The term modular programming was coined in the late 1960s. It has been a key part of good software engineering since.

Here are some positive points about micro-services style of SOA:
  • Small, easy to understand code base. Because micro-service application is responsible only for one thing, it requires less code, is easy to understand, is easy to reason about, is easy to test, and has less risk of changes.
  • Easy to scale. With a large, monolithic application you have to scale everything together. You have to scale the whole thing and waste resources. Whereas, if demand for a particular service temporarily increased then you would only need to scale the specific service.
  • Easy to Deploy. With monolithic applications even one line code change require redeployment and re-testing of the whole application. This could be a big problem for many organizations with its high degree of risk and disruption. Deploying micro-services is much simpler because the scope of deployment is much smaller. Plus you know where to look for problems if such arise.
  • Ability to use a different technology stack. With micro-services the approach should be to use the best tools and languages for the job, instead of one size fit’s all. The same goes for databases. For example, recommendation micro-services can use neo4j and python because python has a lot of machine-learning libraries; event-processing micro-services may use java and cassandra because of multithreading properties of jvm and high scalability of cassandra. It also allow teams to try new technologies on small services without major disruption.
    Smaller teams. It’s much easier and faster to work with a collocated, small team. Each small team can own micro-service and access other services via high level api. For example, a team in New York can be responsible for recommendation services and a team in India for content micro-service.
  • System resilience. If an monoliths application stop working, then a lot of functionality stop working. On the opposite side, If one of the micro-services stop working – only small, particular functionality will be lost. It’s much more simple to build some resilience around smaller service. For example, failure of the order-processing system can be mitigated with message queues.