Kick Starting your Microservices (Part 2)
Welcome to the second part of the series! If you haven’t visited the part 1, I would advise you to visit that and then come back.
So, till now we have discussed the difficulties in scaling in the monolithic world, let’s start with a very aggressive advantage of microservice architecture.
If you have for example 5 microservices within an application, you are free to choose what coding language to use according to your need. That may or may not be the same! Yes Right, one in Java, other in Scala, Python or maybe even PHP(eww old). Till the microservices are interacting with each other in the same format you need not worry, just pick the best suited language for your use case. Example- Rest Api Java, for Big Data or Data Science maybe Scala/Python.
Just keep the interaction mechanism for each service same! For my case I kept the response and request body of each service as JSON.
To build a full proof web app that meets the industry standards, good code base and security, one should go through https://12factor.net/ . This blog post is too brief to cover the 12 factors and won’t repeat what’s already there.
ADVANTAGES OF MICROSERVICE ARCHITECTURE:
- Highly maintainable and testable
- Loosely coupled
- Independently deployable
- Organised around business capabilities
- Owned by a small team (multiple agile teams, each one team will own the microservices)
- Fast release and deployment of new features.
Let’s take one more example, we discussed in the previous blog about scaling. Let’s see how this issue is solved here and why exactly we call microservice architecture easily scalable, loosely coupled and independently deployable!
When we expect load on any of functionality or any of the miocroservices created, then we can do horizontal scaling of that service. So let’s say the Search service expects a higher load than the other service, we scale(increase the running instances) for only the Search service which lead to low cost instead of scaling the whole application(scaling redundant service) incurring a higher cost!
Different team can work in an agile manner on a different service, making them responsible for their own services. This leads to having proper deliverables and each service can be separately deployed without being completely dependent on each other.
WHY LOOSELY COUPLED NOT COMPLETELY DECOUPLED?
Those who were asking this question while reading, give a pat to your back! Loosely coupled is basically minimising the dependencies between two or more components. While using simple code base or being dependent on just Rest Calls we may have linear dependencies on other service for data or interaction!
Though this can also be solved using Messaging System like Enterprise Message System, RabbitMQ, JMS or Apache Kafka. A brief example- we put message from one service into a messaging queue and the other service can pull out that message from the queue whenever available rather directly communicating with the other service!
This is a whole new topic to cover, so maybe I’ll write about messaging systems in one of my next blog!
If you can’t build a monolithic, what makes you think microservice is the answer
Simon Brown
WHEN TO USE MICROSERVICE ARCHITECTURE
There might be a scenario where building a monolithic application would be better. That would be the case when you have a small application with small code base and not much to scale! Like building a calculator?
When developing the first version of an application, you often do not have the problems that this approach solves. Moreover, using an elaborate, distributed architecture will slow down development. This can be a major problem for startups whose biggest challenge is often how to rapidly evolve the business model and accompanying application. Later on, however, when the challenge is how to scale and you need to use functional decomposition, the tangled dependencies might make it difficult to decompose your monolithic application into a set of services.
SUMMARY
The goal of Microservices is loose coupling. Carefully designed microservice architecture let you implement a project using a set of microservices, where each is managed, developed, and released independently.