Notes on Microservices by Martin Fowler
Read a response article to Martin Fowler and James Jewis' article about microservices, and Martin Fowler's talk on microservices at XConf.
Join the DZone community and get the full member experience.Join For Free
i just watched martin fowler's talk about microservices at xconf. here are some of my notes and related thoughts. the talk is heavily based upon martin fowler and james lewis' article about microservices , so you can find and read most of the information there.
characteristics of microservices
in his article, fowler defines some characteristics that most of the already existing microservices architectures implement. in his talk he discusses some of them:
componentization via services -
what really is a component? the term often pops up as a "cooler" alternative to module or widget. but there's a vague definition: is it a class, an executable piece?
from fowler's perspective it is best to use some real world paradigm, like how a user refers to a "stereo system". they move it around, attach it somewhere else. move, remove and attach different speakers.
basically a component is something that is independently upgradeable and replaceable .
there are major ways about how components are being used or brought into a project: through libraries (jars, gems, node_modules,...) or through services. the difference is simply that services are not directly brought into your codebase, but rather be called through remote calls.
organized around business capabilities -
the organization of teams and people is a very important point. many organization structure their teams around technology:
rather, with microservices, people should be organized around the business capabilities within cross-functional teams: like the "shipping team", the "orders team",...
according to amazon these teams should be as big s.t. we're able to feed them with 2 (american) pizzas (a dozen of people). fowler highlights that an important fact is that these teams have a
direct communication line
to the end user or customer and get according feedback how the stuff they build is being used and how well or not it works.
microservices is much more about about team organization rather than software architecture. architecture and team organization is always heavily coupled together.
organizations which design systems....are constrained to produce designs which are copies of the communication structures of these organizations conway's law
smart endpoints and dumb pipes -
it is common practice to use smart network infrastructure like esbs that contain logic about how to treat certain network messages and how to route them around.
microservices instead facilitate dumb pipes and smart endpoints/applications . the problem is that smart pipes (i.e. esbs) lead to issues with continuous delivery as they cannot be easily version controlled or integrated into a large pipeline. moreover it creates dependencies with the application itself, meaning that when you decide to upgrade your endpoint/service, you often have to do some work on the esb as well.
decentralized data management -
normally, on a monolith system there's one huge database where all the data is being stored. often there are even multiple monoliths connecting to the same db.
in a service oriented approach, each service gets its own database and the data is not shared directly with others . sharing has to go through service that wraps the data. this leads to a lot of beneficial flexibility on the service's side as it can decide which technology to adopt, which dbms system etc. in this way, different programming languages and database systems can be used among services. it's decentralized decision making .
infrastructure automation - continuous delivery is a must have as well as automated mechanisms for machines provisioning, for deployment, testing etc.
design for failure -
you inevitably have to design for failure as the microservices will fail, even frequently. netflix is renowned for carrying this to the extreme. they have a
which runs over their production system during the day and randomly shuts down services. this gives them valuable feedback about how resistant their services are, how well they recover from outages and how the overall system is affected.
although many people tend to abstract and hide remote calls, you cannot expect them to perform like normal calls . expect them to fail rather than to succeed. a notable library released by netflix is hysterix , a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries.
others characteristics that haven't been mentioned explicitly in the talk are these:
- products not projects
- decentralized governance
- infrastructure automation
- evolutionary design
you find them explained in the microservice article on fowler's website.
are microservices really just soa?
a question i've posed myself as well a couple of times. the point is - and fowler mentions that as well - is how one defines soa. if soa is being seen as esbs, smart centralized management,... in that case microservices is very different.
fowler defines it as a subset of soa, one that refers to a particular style of implementing certain concepts.
having "micro" in its name, the question arises about how big a service should be? actually there's a lot of variation, from 15 people -> 10 services to 4 people -> 200 services. it's not yet exactly clear.
when to use a monolith and when a microservice?
fowler immediately emphasizes that with every new concept people tend to overuse it. so be cautious about that.
- simplicity: take into account that distributed services are a huge complexity booster
- inter-module refactoring is much easier. within a microservice architecture, if you fail to do a good service-cut it's much more difficult to move logic around.
- partial deployment
- good degree of availability (if good failure management has been implemented)
- preserve modularity: programming languages are bad in helping to preserve the modularity of systems as it is too easy to escape their structures (like packages and namespaces)
- multiple platforms as such architecture gives more flexibility in the technology choices such as os, programming language etc...
you must be this tall...
...to use microservices. as already mentioned in fowler's article about the prerequisites you should fulfill the following prerequisites:
- fast provisioning : be able to setup new machines in hours not days in order to avoid delays.
- good monitoring : to be quickly able to diagnose failures and trace them down to the place they occurred. if issues occur you should be able to quickly rollback to a previous version of the microservice.
- rapid application deployment through fully automated pipelines
- devops culture
that said, fowler says that when he's not sure he still prefers the monolith structure and eventually evolve to a microservices system later in the development cycle (although that might not be totally optimal).
the talk somehow confirms my impressions so far...
- high degree of automation at various levels (infrastructure, testing, dev, deployment)
- trend to empower the team, its responsibility and flexibility in the decision making (compatible with what agile already fosters)
- implementing best practices (fault tolerance, smart endpoints, monitoring, testing)
- know the trade-offs, don't overuse
as an architect and tech enthusiast this is the architecture of my dreams. but given the issues i regularly face when coaching teams, the difficulty at adopting good programming practices and rigid organizational structures...then adopting a microservices architecture is extremely difficult .
still, even if you're not ready yet, i think you should aim for such structure, without necessarily going it the whole way. like, structuring your application or product by following practices from the microservices architecture but deploying it as a monolith. i'm thinking about a modular architecture, good failure handling, logging and monitoring, automated deployment pipelines and a high degree of automated testing. from there, optimize incrementally.
Published at DZone with permission of Juri Strumpflohner. See the original article here.
Opinions expressed by DZone contributors are their own.