WHAT IS MICROSERVICES
In?software engineering, a?microservice?architecture is a variant of the?service-oriented architecture?structural style. It is an?architectural pattern?that arranges an application as a collection of?loosely coupled,?fine-grained?services, communicating through?lightweight protocols. One of its goals is that teams can develop and?deploy?their services independently of others. This is achieved by the reduction of several?dependencies?in the code base, allowing developers to evolve their services with limited restrictions from users, and for additional complexity to be hidden from users.[1]?As a consequence, organizations are able to develop software with fast growth and size, as well as use off-the-shelf services more easily. Communication requirements are reduced. These benefits come at a cost to maintaining the decoupling. Interfaces need to be designed carefully and treated as a public?API. One technique that is used is having multiple interfaces on the same service, or multiple versions of the same service, so as to not disrupt existing users of the code.
Introduction[edit]
There is no single definition for microservices. A consensus view has evolved over time in the industry. Some of the defining characteristics that are frequently cited include:
A microservice is not a layer within a monolithic application (for example, the web controller or the backend-for-frontend).[8]?Rather, it is a self-contained piece of business functionality with clear interfaces, and may, through its own internal components, implement a layered architecture. From a strategical perspective, microservice architecture essentially follows the?Unix philosophy?of "Do one thing and do it well".[9]?Martin Fowler?describes a microservices-based architecture as having the following properties:[2]
It is common for microservices architectures to be adopted for?cloud-native applications,?serverless computing, and applications using lightweight?container?deployment. According to Fowler, because of the large number (when compared to monolithic application implementations) of services, decentralized continuous delivery and?DevOps?with holistic service monitoring are necessary to effectively develop, maintain, and operate such applications.[13]?A consequence of (and rationale for) following this approach is that the individual microservices can be individually scaled. In the monolithic approach, an application supporting three functions would have to be scaled in its entirety even if only one of these functions had a resource constraint.[14]?With microservices, only the microservice supporting the function with resource constraints needs to be scaled out, thus providing resource and cost optimization benefits.[15]
History[edit]
There are numerous claims as to the origin of the term microservices. Whilst vice president of?ThoughtWorks?in 2004,?Fred George?began working on prototype architectures based on what he called the "Baysean Principles" named after Jeff Bay.[16]
As early as 2005, Peter Rodgers introduced the term "Micro-Web-Services" during a presentation at the Web Services Edge conference. Against conventional thinking and at the height of the?SOAP?service-oriented architecture?(SOA) hype curve he argued for "REST-services" and on slide #4 of the conference presentation, he discusses "Software components?are Micro-Web-Services".[17]?He goes on to say "Micro-Services are composed using?Unix-like pipelines?(the?Web?meets Unix = true?loose-coupling). Services can call services (+multiple language run-times). Complex service assemblies are abstracted behind simple?URI?interfaces. Any service, at any granularity, can be exposed." He described how a well-designed microservices platform "applies the underlying architectural principles of the?Web?and REST services together with Unix-like scheduling and pipelines to provide radical flexibility and improved simplicity in service-oriented architectures.[18]
Rodgers' work originated in 1999 with the Dexter research project at?Hewlett Packard Labs, whose aim was to make code less brittle and to make large-scale, complex software systems?robust?to change.[19]?Ultimately this path of research led to the development of?resource-oriented computing?(ROC), a generalized computation abstraction in which REST is a special subset.
In 2007, Juval L?wy in his writing[20]?and speaking[21][22]?called for building systems in which every class was a service. L?wy realized this required the use of a technology that can support such granular use of services, and he extended?Windows Communication Foundation (WCF)?to do just that,[23][24]?taking every class and treating it as a service while maintaining the conventional programming model of classes.
In 2005?Alistair Cockburn?wrote about?hexagonal architecture?which is a software design pattern that is used along with the microservices. This pattern makes the design of the microservice possible since it isolates in layers the business logic from the auxiliary services needed in order to deploy and run the microservice completely independent from others.
A workshop of software architects held near Venice in May 2011 used the term "microservice" to describe what the participants saw as a common architectural style that many of them had been recently exploring.[25]?In May 2012, the same group decided on "microservices" as the most appropriate name. James Lewis presented some of those ideas as a?case study?in March 2012 at 33rd Degree in Kraków in Microservices - Java, the Unix Way,[26]?as did Fred George[27]?about the same time. Adrian Cockcroft, former director for the Cloud Systems at Netflix,[28]?described this approach as "fine-grained SOA", pioneered the style at web-scale, as did many of the others mentioned in this article - Joe Walnes, Dan North, Evan Bottcher, and Graham Tackley.[29]
Microservices is a specialization of an implementation approach for service-oriented architectures used to build flexible, independently deployable?software systems.[5]?The microservices approach is the first realisation of SOA that followed the introduction of?DevOps?and is becoming more popular for building?continuously deployed?systems.[30]
In February 2020, the Cloud Microservices Market Research Report predicted that the global microservice architecture market size will increase at a?CAGR?of 21.37% from 2019 to 2026 and reach $3.1 billion by 2026.[31]
Service granularity[edit]
A key step in defining a microservice architecture is figuring out how big an individual microservice has to be. There is no consensus or litmus test for this, as the right answer depends on the business and organizational context.[32]?For instance,?Amazon?uses a service-oriented architecture where service often maps 1:1 with a team of 3 to 10 engineers.[33]?Generally, the terminology goes as such: services that are dedicated to a single task, such as calling a particular backend system or making a particular type of calculation, are called?atomic services. Similarly, services that call such atomic services in order to consolidate an output, are called?composite services.
It is considered bad practice to make the service too small, as then the runtime overhead and the operational complexity can overwhelm the benefits of the approach. When things get too fine-grained, alternative approaches must be considered - such as packaging the function as a library, moving the function into other microservices.[5]
If the?domain-driven design?is being employed in modeling the domain for which the system is being built, then a microservice could be as small as an aggregate or as large as a bounded Context.[34]
In the granularity of microservices discussion, there is a spectrum, in one end there are the Anaemic Services, which do not have a large number of responsibilities, and on the other end, the Modular Monolith, which are large modules of a system.
Benefits[edit]
The benefit of decomposing an application into different smaller services are numerous: