Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Monoliths and Microservices

2,693 views

Published on

Should you choose a microservices architecture over a monolith? What are the pros and cons in reality.

Published in: Software

Monoliths and Microservices

  1. 1. Monoliths and microservices Bozhidar Bozhanov
  2. 2. Vanity slide • Senior software engineer @ TomTom • http://blog.bozho.net • http://techblog.bozho.net • http://twitter.com/bozhobg • some other stuff...
  3. 3. General architecture Source: Microsoft
  4. 4. Monoliths • single deployment • single runtime • single codebase • interaciton between classes is most often syncrhonous • most often every layer is in a separate package
  5. 5. Microservices • many small modules with specific functionality • more than one codebase • every microservice is a separate deployment • every microservices has its own DB • communication with web- services/protobuf/thrift/… • ensures module independence
  6. 6. Monoliths vs microservices Source: Martin Fowler
  7. 7. Downsides of monoliths…? • “spaghetti”, “big ball of mud” • you need a full redeploy • programmers often violate the layer boundaries • classes often “leak” their implementation • hard to work with multiple teams • hard to manage
  8. 8. Benefits of Microservices..? • modelled around the business domain • deployment automation culture • hides implementation details • decentralization • option to use multiple languages • separate deployment, separate monitoring • isolating problems
  9. 9. Source: Martin Fowler
  10. 10. Downsides of monoliths..? • “spaghetti”, “big ball of mud” • if you write bad code, architecture doesn’t matter • you need a full redeploy • so? It’s automated anyway • programmers often violate layers • see. 1 • classes “leak” their implementation • see 1
  11. 11. Benefits of microservices..? • all of them can be achieved with a monolith • modelled around the business domain • yes • deployment automation culture • nothing stops automated deployments of a monolith • hides implementation details • OOP 101
  12. 12. Benefits of microservices..? • separate deployment, separate мониторинг • monitoring of classes/components/layers with tools like statsd • isolating problems • when has a single exception broken your server? • if a whole machine dies – you have an HA cluster • graceful degradation - feature toggle in monolith
  13. 13. Microservices...downsides • network overhead • transaction coordination • you don’t have transaction? Congratulations. • need for duplicating common data • and keeping it in sync • complicated deployment pipeline • dependencies
  14. 14. Microservices...should we? “…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” Martin Fowler
  15. 15. “the design thinking and decomposition strategy required to create a good microservices architecture are the same as those needed to create a well structured monolith” Simon Brown
  16. 16. The middle way Source: Simon Brown
  17. 17. How to write monoliths • package by layer (small projects) • with sub-packages by component • package by components • logically the same as microservices, without the cons • one or several projects with module dependencies • project jigsaw - modules • good OOP • interfaces, encapsulation, composition, etc.
  18. 18. More best practices • Continuous delivery, automation • High availability • Log collection • Monitoring
  19. 19. Microservices use cases • multiple teams • short-lived, spawned workers • memory or CPU intensive parts • to ease development
  20. 20. Но като цяло... • common sense • добри практики • качествен код • не се доверявайте на “модерното” • не се “наархитектурчвайте” • a.k.a. KISS • загубите може да са повече от евентуалните ползи
  21. 21. Sources http://www.codingthearchitecture.com/2014/07/06/distributed_big_balls_of_mud.html http://www.codingthearchitecture.com/2013/07/03/aligning_software_architecture_and_code.html https://michaelfeathers.silvrback.com/microservices-until-macro-complexity http://techblog.bozho.net/in-defence-of-monoliths/ http://martinfowler.com/bliki/MicroservicePremium.html http://martinfowler.com/articles/microservices.html http://martinfowler.com/articles/microservice-trade-offs.html http://www.wired.com/2015/09/google-2-billion-lines-codeand-one-place/
  22. 22. Thank you!

×