Martin Fowler on the Microservice Premium
Learn about how the microservices architectural style could be negatively impacting teams where important obstacles haven't been considered.
Join the DZone community and get the full member experience.Join For Free
the microservices architectural style has been the hot topic over the last year. at the recent o'reilly software architecture conference , it seemed like every session talked about microservices. enough to get everyone's over-hyped-bullshit detector up and flashing. one of the consequences of this is that we've seen teams be too eager to embrace microservices, not realizing that microservices introduce complexity on their own account. this adds a premium to a project's cost and risk - one that often gets projects into serious trouble.
while this hype around microservices is annoying, i do think it's a useful bit of terminology for a style of architecture which has been around for a while, but needed a name to make it easier to talk about. the important thing here is not how annoyed you feel about the hype, but the architectural question it raises: is a microservice architecture a good choice for the system you're working on?
any decent answer to an interesting question begins, "it depends..." -- kent beck
"it depends" must start my answer, but then i must shift the focus to what factors it depends on . the fulcrum of whether or not to use microservices is the complexity of the system you're contemplating. the microservices approach is all about handling a complex system, but in order to do so the approach introduces its own set of complexities. when you use microservices you have to work on automated deployment, monitoring, dealing with failure, eventual consistency, and other factors that a distributed system introduces. there are well-known ways to cope with all this, but it's extra effort, and nobody i know in software development seems to have acres of free time.
so my primary guideline would be don't even consider microservices unless you have a system that's too complex to manage as a monolith . the majority of software systems should be built as a single monolithic application. do pay attention to good modularity within that monolith, but don't try to separate it into separate services.
the complexity that drives us to microservices can come from many sources including dealing with large teams , multi-tenancy , supporting many user interaction models, allowing different business functions to evolve independently, and scaling. but the biggest factor is that of sheer size - people finding they have a monolith that's too big to modify and deploy.
at this point i feel a certain frustration. many of the problems ascribed to monoliths aren't essential to that style. i've heard people say that you need to use microservices because it's impossible to do continuous delivery with monoliths - yet there are plenty of organizations that succeed with a cookie-cutter deployment approach: facebook and etsy are two well-known examples.
i've also heard arguments that say that as a system increases in size, you have to use microservices in order to have parts that are easy to modify and replace. yet there's no reason why you can't make a single monolith with well defined module boundaries. at least there's no reason in theory , in practice it seems too easy for module boundaries to be breached and monoliths to get tangled as well as large.
we should also remember that there's a substantial variation in service-size between different microservice systems. i've seen microservice systems vary from a team of 60 with 20 services to a team of 4 with 200 services. it's not clear to what degree service size affects the premium.
as size and other complexity boosters kick into a project i've seen many teams find that microservices are a better place to be. but unless you're faced with that complexity, remember that the microservices approach brings a high premium, one that can slow down your development considerably. so if you can keep your system simple enough to avoid the need for microservices: do.
1: it's a common enough problem that our recent radar called it out as microservice envy .
2: conway's law says that the structure of a system follows the organization of the people that built it. some examples of microservice usage had organizations deliberately split themselves into small, loosely coupled groups in order to push the software into a similar modular structure - a notion that's called the inverse conway maneuver .
i stole much of this thinking from my colleagues: james lewis, sam newman, thiyagu palanisamy, and evan bottcher. stefan tilkov's comments on an earlier draft were instrumental in sharpening this post. rob miles, david nelson, brian mason, and scott robinson discussed drafts of this article on our internal mailing list.
Published at DZone with permission of Martin Fowler, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.