What is a Microservice?
Microservice Architecture (or Microservices) is a special form of Service-Oriented Architecture (SOA) in which applications are built in terms of distinct modular services, each responsible for a specific function in the larger application scheme.
In general terms, a microservice is a single piece or bundle of code that performs a discrete, well-defined role and is able to communicate with other microservices via an HTTP / REST API or similar standardized mechanism.
For example, one microservice may be employed to handle user authentication and account management, another to deal with orders and inventory, yet another for logs and monitoring, and so on.
What do Microservices Do?
The goal of Microservices is to ensure that an application's internal components remain loosely coupled so that the application can be easily deployed, maintained, automated, and continuously integrated alongside evolving business priorities (and amid new technologies).
Although each microservice should be responsible for only a small, related set of functionalities, it is up to the development team to decide how limited the functionality will be for any given microservice.
Microservices vs. Monolithic
The Microservices architectural pattern is directly contrasted with monolithic software architecture, in which the components of an application are tightly coupled to a single underlying codebase. With the monolithic approach, a minor code change may involve a redesign or redeployment of the entire application stack, whereas with Microservices there need only be an adjustment to the microservice in question, leaving the other parts of the application unaltered.
A typical Microservices application will take advantage of lightweight VMs, container technology, or ready-made PaaS engines to power the core infrastructure with minimal resources. Each microservice may also hold its own unique database to maintain independence from other microservices. This solves the problem of data consistency between different parts of the application and prevents the need for complex distributed transactions.