Microservices architecture is a group of independent services which is the breakdown of the Monolithic architecture into several smaller independent units. These micro-services are independent of each other from their business logic, functions, processing and some time from data base stand point which facilitate flexibility to the developers to choose development languages, frameworks, code builds, integration processes and runtime infrastructure. It is more like suit of small lightweight program or a functions or RESTful service or can be a schedule job or an event based service, which interconnected using APIs that are used for internal communication.
Designing Microservices Architecture
Design of microservice architecture starts with by identifying services – services are identified majorly based on the business logic and functions such that a service can be independent as much possible, second factor that should be considered is the size of the service because size play a major role considering factors like cost, resources, maintenance etc and finally we need to think on future scope as there may be chances that a service would get enriched in terms of functionality, load, resources etc.
Communication in Microservices
In micro-service design communication happens using messaging, using a lightweight and straightforward mechanism. Communication between services can be Synchronous and Asynchronous in several message formats like JSON, XML, Thrift, Avro or ProtoBuf etc. that the Microservices could follow to communicate depending upon the purpose and requirements.
REST is one of the highly preferred synchronous messaging techniques used by the Microservices, in which the HTTP request and response that defines a set of controls based on the resource API. Rest APIs are used to do point to point communication where a request wait for a response to perform further action, this can leads to the issue of coupling, causing several dependencies within the Microservices.
AMQP, STOMP, MQTT
In the scenarios where immediate response in not needed we can use asynchronous messaging using AMQP, STOMP or MQTT. AMQP is an open standard application layer protocol which highly reliable and secure and has encryption capability, Rabbit MQ uses AMQP protocol to communicate by queuing messages and sending them to single or multiple subscriber programs that listen to the RabbitMQ server.