Microservices
Microservices
Microservices
Microservices
The term "Microservice Architecture" has sprung up over the last few years to describe a
particular way of designing software applications as suites of independently deployable
services. While there is no precise definition of this architectural style, there are certain
common characteristics around organization around business capability, automated
deployment, intelligence in the endpoints, and decentralized control of languages and
data.
25 March 2014
James Lewis
James Lewis is a Principal Consultant at Thoughtworks and member of the Technology Advisory Board.
James' interest in building applications out of small collaborating services stems from a background in
integrating enterprise systems at scale. He's built a number of systems using microservices and has
been an active participant in the growing community for a couple of years.
Martin Fowler
Martin Fowler is an author, speaker, and general loud-mouth on software development. He's long been
puzzled by the problem of how to componentize software systems, having heard more vague claims
Table of Contents
than he's happy with. He hopes that microservices will live up to the early promise its advocates have
found.
POPULAR
APPLICATION ARCHITECTURE
MICROSERVICES
CONTENTS
Characteristics of a Microservice Architecture
Componentization via Services
Organized around Business Capabilities
Products not Projects
Smart endpoints and dumb pipes
Decentralized Governance
Decentralized Data Management
Infrastructure Automation
Design for failure
Evolutionary Design
Are Microservices the Future?
SIDEBARS
How big is a microservice?
Microservices and SOA
Many languages, many options
Battle-tested standards and enforced standards
Make it easy to do the right thing
The circuit breaker and production ready code
Synchronous calls considered harmful
My Microservices Resource Guide provides links to the best articles, videos, books, and
podcasts about microservices.
Characteristics of a Microservice
Architecture
We cannot say there is a formal definition of the microservices
architectural style, but we can attempt to describe what we see as
common characteristics for architectures that fit the label. As with any
definition that outlines common characteristics, not all microservice
architectures have all the characteristics, but we do expect that most
microservice architectures exhibit most characteristics. While we
authors have been active members of this rather loose community, our
intention is to attempt a description of what we see in our own work and
in similar efforts by teams we know of. In particular we are not laying
down some definition to conform to.
For as long as we've been involved in the software industry, there's been a
desire to build systems by plugging together components, much in the
way we see things are made in the physical world. During the last couple
of decades we've seen considerable progress with large compendiums of
common libraries that are part of most language platforms.
One main reason for using services as components (rather than libraries)
is that services are independently deployable. If you have an application
[4] that consists of a multiple libraries in a single process, a change to any
single component results in having to redeploy the entire application. But
if that application is decomposed into multiple services, you can expect
many single service changes to only require that service to be
redeployed. That's not an absolute, some changes will change service
interfaces resulting in some coordination, but the aim of a good
microservice architecture is to minimize these through cohesive service
boundaries and evolution mechanisms in the service contracts.
Using services like this does have downsides. Remote calls are more
expensive than in-process calls, and thus remote APIs need to be
coarser-grained, which is often more awkward to use. If you need to
change the allocation of responsibilities between components, such
movements of behavior are harder to do when you're crossing process
boundaries.
Although “microservice” has become a popular name for this architectural style, its
name does lead to an unfortunate focus on the size of service, and arguments about
what constitutes “micro”. In our conversations with microservice practitioners, we see
a range of sizes of services. The largest sizes reported follow Amazon's notion of the
Two Pizza Team (i.e. the whole team can be fed by two pizzas), meaning no more than a
dozen people. On the smaller size scale we've seen setups where a team of half-a-
dozen would support half-a-dozen services.
This leads to the question of whether there are sufficiently large differences within this
size range that the service-per-dozen-people and service-per-person sizes shouldn't
be lumped under one microservices label. At the moment we think it's better to group
them together, but it's certainly possible that we'll change our mind as we explore this
style further.
There's no reason why this same approach can't be taken with monolithic
applications, but the smaller granularity of services can make it easier to
create the personal relationships between service developers and their
users.
When we've talked about microservices a common question is whether this is just
Service Oriented Architecture (SOA) that we saw a decade ago. There is merit to this
point, because the microservice style is very similar to what some advocates of SOA
have been in favor of. The problem, however, is that SOA means too many different
things, and that most of the time that we come across something called "SOA" it's
significantly different to the style we're describing here, usually due to a focus on ESBs
used to integrate monolithic applications.
Certainly, many of the techniques in use in the microservice community have grown
from the experiences of developers integrating services in large organisations. The
Tolerant Reader pattern is an example of this. Efforts to use the web have contributed,
using simple protocols is another approach derived from these experiences - a reaction
away from central standards that have reached a complexity that is, frankly,
breathtaking. (Any time you need an ontology to manage your ontologies you know you
are in deep trouble.)
This common manifestation of SOA has led some microservice advocates to reject the
SOA label entirely, although others consider microservices to be one form of SOA [6],
perhaps service orientation done right. Either way, the fact that SOA means such
different things means it's valuable to have a term that more crisply defines this
architectural style.
-- Ian Robinson
Microservice teams use the principles and protocols that the world wide
web (and to a large extent, Unix) is built on. Often used resources can be
cached with very little effort on the part of developers or operations folk.
Decentralized Governance
Of course, just because you can do something, doesn't mean you should -
but partitioning your system in this way means you have the option.
The growth of JVM as a platform is just the latest example of mixing languages within a
common platform. It's been common practice to shell-out to a higher level language to
take advantage of higher level abstractions for decades. As is dropping down to the
metal and writing performance sensitive code in a lower level one. However, many
monoliths don't need this level of performance optimisation nor are DSL's and higher
level abstractions that common (to our dismay). Instead monoliths are usually single
language and the tendency is to limit the number of technologies in use [9].
It's a bit of a dichotomy that microservice teams tend to eschew the kind of rigid
enforced standards laid down by enterprise architecture groups but will happily use
and even evangelise the use of open standards such as HTTP, ATOM and other
microformats.
The key difference is how the standards are developed and how they are enforced.
Standards managed by groups such as the IETF only become standards when there are
several live implementations of them in the wider world and which often grow from
successful open-source projects.
These standards are a world apart from many in a corporate world, which are often
developed by groups that have little recent programming experience or overly
influenced by vendors.
This issue is common between applications, but can also occur within
applications, particular when that application is divided into separate
components. A useful way of thinking about this is the Domain-Driven
Design notion of Bounded Context. DDD divides a complex domain up
into multiple bounded contexts and maps out the relationships between
them. This process is useful for both monolithic and microservice
architectures, but there is a natural correlation between service and
context boundaries that helps clarify, and as we describe in the section
on business capabilities, reinforce the separations.
Infrastructure Automation
Circuit Breaker appears in Release It! alongside other patterns such as Bulkhead and
Timeout. Implemented together, these patterns are crucially important when building
communicating applications. This Netflix blog entry does a great job of explaining their
application of them.
Since services can fail at any time, it's important to be able to detect the
failures quickly and, if possible, automatically restore service.
Microservice applications put a lot of emphasis on real-time monitoring
of the application, checking both architectural elements (how many
requests per second is the database getting) and business relevant
metrics (such as how many orders per minute are received). Semantic
monitoring can provide an early warning system of something going
wrong that triggers development teams to follow up and investigate.
Any time you have a number of synchronous calls between services you will encounter
the multiplicative effect of downtime. Simply, this is when the downtime of your system
becomes the product of the downtimes of the individual components. You face a
choice, making your calls asynchronous or managing the downtime. At
www.guardian.co.uk they have implemented a simple rule on the new platform - one
synchronous call per user request while at Netflix, their platform API redesign has built
asynchronicity into the API fabric.
Evolutionary Design
Our main aim in writing this article is to explain the major ideas and
principles of microservices. By taking the time to do this we clearly think
that the microservices architectural style is an important idea - one
worth serious consideration for enterprise applications. We have recently
built several systems using the style and know of others who have used
and favor this approach.
Microservice Trade-Offs
Read more…
MICROSERVICES
Those we know about who are in some way pioneering the architectural
style include Amazon, Netflix, The Guardian, the UK Government Digital
Service, realestate.com.au, Forward and comparethemarket.com. The
conference circuit in 2013 was full of examples of companies that are
moving to something that would class as microservices - including Travis
CI. In addition there are plenty of organizations that have long been
doing what we would class as microservices, but without ever using the
name. (Often this is labelled as SOA - although, as we've said, SOA comes
in many contradictory forms. [14])
Another issue is If the components do not compose cleanly, then all you
are doing is shifting complexity from inside a component to the
connections between components. Not just does this just move
complexity around, it moves it to a place that's less explicit and harder to
control. It's easy to think things are better when you are looking at the
inside of a small, simple component, while missing messy connections
between services.
One reasonable argument we've heard is that you shouldn't start with a
microservices architecture. Instead begin with a monolith, keep it
modular, and split it into microservices once the monolith becomes a
problem. (Although this advice isn't ideal, since a good in-process
interface is usually not a good service interface.)
So we write this with cautious optimism. So far, we've seen enough about
the microservice style to feel that it can be a worthwhile road to tread.
We can't say for sure where we'll end up, but one of the challenges of
software development is that you can only make decisions based on the
imperfect information that you currently have to hand.
Footnotes
2: The term monolith has been in use by the Unix community for some
time. It appears in The Art of Unix Programming to describe systems that
get too big.
5: We can't resist mentioning Jim Webber's statement that ESB stands for
"Erroneous Spaghetti Box".
14: And SOA is hardly the root of this history. I remember people saying
"we've been doing this for years" when the SOA term appeared at the
beginning of the century. One argument was that this style sees its roots
as the way COBOL programs communicated via data files in the earliest
days of enterprise computing. In another direction, one could argue that
microservices are the same thing as the Erlang programming model, but
applied to an enterprise application context.
References
While this is not an exhaustive list, there are a number of sources that
practitioners have drawn inspiration from or which espouse a similar
philosophy to that described in this article.
Books
Release it
Rest in practice
Web API Design (free ebook). Brian Mulloy, Apigee.
Enterprise Integration Patterns
Art of unix programming
Growing Object Oriented Software, Guided by Tests
The Modern Firm: Organizational Design for Performance and Growth
Continuous Delivery: Reliable Software Releases through Build, Test,
and Deployment Automation
Domain-Driven Design: Tackling Complexity in the Heart of Software
Presentations
Papers
Further Reading
Significant Revisions
© Martin Fowler | Privacy Policy | Disclosures