Microservices 101: opportunities, dilemmas and problems

Łukasz Sowa
Łukasz SowaCo-founder, managing partner at Iterators
ITERATORSI T E R A T O R S @luksow
Microservices 101
opportunities, dilemmas and problems
Łukasz Sowa, 4Developers 2015
ITERATORSI T E R A T O R S @luksow
Hi, I'm Łukasz
●
Co-founder, engineer @ Iterators (http://iterato.rs)
●
Highly concurrent & distributed systems
●
Pizza, beer & football lover
●
http://luksow.com
●
contact@luksow.com
●
@luksow
ITERATORSI T E R A T O R S @luksow
What's in it for you?
●
Learn
– What are microservices?
– Why they might be useful?
– What questions do they bring up?
– What's hard about them?
●
Takeaways
– Feel enthusiastic but cautious about microservices
– Be able to design your next project using microservices
ITERATORSI T E R A T O R S @luksow
What are microservices?
●
Architectural style (MSA)
●
System is composed of multiple services
– Small*
– Independently deployed
– Communicate using (lightweight) protocols
– Organized around business capabilities
●
Bounded Context (DDD) or Single Responsibility
Principle (OO) implemented in architecture
ITERATORSI T E R A T O R S @luksow
Why? Why now?
●
Post-SOA (or SOA done right?)
●
DevOps revolution (provisioning, deployment)
●
Cheap hardware
●
Existing systems got too big and too boring?
●
Innovation market got immensely demanding
(Netflix, Gilt, Tumblr, Amazon, SoundCloud)
ITERATORSI T E R A T O R S @luksow
Let's design!
Design a system that allows users to login/register using FB, email-password or
codecard. Authenticated user can subscribe to different events from BTC
markets (ex. rate changed, volume over N, ask below M etc.) and get real-time alerts
about them. Make sure to gather relevant business metrics.
auth-fb auth-pass auth-codes
btc-users
btc-ws
identity
metrics
session
token
frontend
btc-market
load balancer
ITERATORSI T E R A T O R S @luksow
Opportunities
Why people love microservices?
ITERATORSI T E R A T O R S @luksow
Technical advantages
●
Horizontal scaling performance→
●
Designing for failure resilience→
auth-fb auth-pass auth-codes
btc-users
btc-ws
identity
metrics
session
token
frontend
btc-market
load balancer
btc-wsbtc-ws
Scaling
X
Resilience
ITERATORSI T E R A T O R S @luksow
Cultural advantages (1)
Any organization that designs a system (defined
more broadly here than just information systems)
will inevitably produce a design whose structure is
a copy of the organization's communication
structure.
Melvin Conway, How Do Committees Invent, 1968
ITERATORSI T E R A T O R S @luksow
Cultural advantages (2)
●
Siloed teams vs cross-functional teams
●
Less communication overhead
●
Business-oriented teams – microbusinesses
●
The True Way of (scrum) team scaling
●
Agility + autonomy → short time-to-market
MGR UX
FE
DEV
BE
DEV
DBA OPS QA vs
ITERATORSI T E R A T O R S @luksow
Cultural advantages (3)
●
Easy to understand
●
Dispose/rewrite vs refactor
●
Polyglot environment, better tools utilization
●
Mythical reusability?
●
Fun!
ITERATORSI T E R A T O R S @luksow
Dilemmas
Decisions, decisions, decisions...
ITERATORSI T E R A T O R S @luksow
Communication, protocols
●
Communication - most important MSA concern
●
Microservices ≠ REST
●
Plethora of possibilities
– Universal: REST+JSON/XML, MQs, binary TCP/UDP, ... simple, decoupled,→
polyglot but low-level, full of boilerplate, possible code duplication
– Platform-specifc: Akka, Finagle, … easier to code & maintain, code reuse→
but tightly coupled, platform-dependant, not polyglot
●
Prefer universal & lightweight (UNIX - smart endpoints, dumb pipes)
●
Microservices are mostly REST
●
Remember about Postel's law
ITERATORSI T E R A T O R S @luksow
Synchronous vs asynchronous
●
Request-response
●
ASAP response
●
“Asking”
●
Fail-fast
●
Easy to reason about
●
Timeouts?
●
Don't scale
Ex. REST, ...
●
Message passing
●
Deferred processing
●
“Telling”
●
Unnatural
●
Complicated, hard to debug
●
Recovering from failures
●
Scale
Ex. WebSockets, MQs, Akka,
UDP, ...
ITERATORSI T E R A T O R S @luksow
Protocols in action
auth-fb auth-pass auth-codes
btc-users
btc-ws
identity
metrics
session
token
btc-market
REST/JSON WebSockets
REST/JSON Akka
AkkaHTTP Keep-Alive
ITERATORSI T E R A T O R S @luksow
Guarantees
●
What guarantees do you need?
– What's the cost of a single message being lost?
– What happens if system is in inconsistent state?
– …
●
No ACID (atomicity, consistency, isolation, durability)
●
But CAP theorem (consistency, availability, partition tolerance)
●
Eventual consistency, 2PC, 3PC, Paxos & others are your friends
now
●
What do you need? What can/cannot you afford?
●
And no, you can't have everything
ITERATORSI T E R A T O R S @luksow
Shared vs private data stores
●
Source of truth
●
Strong
contract/protocol
●
Convenient
●
Coupling
●
Don't scale
●
Ownership issues
●
Service becomes an
abstraction over DS
●
Polyglot persistence
●
Decoupling
●
Scale
●
Truth is distributed
●
Façade issues
●
Recommended
ITERATORSI T E R A T O R S @luksow
Private data stores
auth-fb auth-pass auth-codes
btc-users
btc-ws
identity
metrics
session
token
btc-market
MongoDB
Redis PostgreSQL PostgreSQL
PostgreSQL
MongoDB
Event journal
ITERATORSI T E R A T O R S @luksow
Shared data stores
auth-fb auth-pass auth-codes
btc-users
btc-ws
metrics
session
btc-market
MongoDB
token
Redis PostgreSQL PostgreSQL
PostgreSQL
identity
MongoDB
Event journal
ITERATORSI T E R A T O R S @luksow
Size & structure
●
How big is microservice?
– ~100 lines rule is a lie
– Up to a couple of thousands LOC in most cases
– Rule: as short as possible but as big as necessary
●
Clean & structured vs short & hacky
Resources
Service
Domain
Repositories
Data mappers
Gateways
Applicationvs
●
Well-structured
●
Requires time to
analyse
●
Easy to maintain
●
Longer
●
Unstructured
●
Understandable
at a glance
●
Hard to maintain
●
Much shorter
ITERATORSI T E R A T O R S @luksow
Size & structure - example
Name Structured? LoC / eLoC
auth-fb Yes 215 / 189
auth-pass Yes 301 / 258
auth-codes Yes 337 / 299
identity No 77 / 66
session No 48 / 43
token Yes 182 / 167
metrics No 160 / 150
btc-ws No 155 / 140
btc-users Yes 153 / 141
btc-market No 51 / 40
TOTAL 5 Yes / 5 No 1679 / 1493
ITERATORSI T E R A T O R S @luksow
Code sharing
Sometimes the same code is required in two or
more services – how to share it?
●
Shared library coupling, not polyglot→
●
Nanoservice maintenance burden, performance→
●
Copy-paste duplication, more code to maintain→
No good answer here (3rd is the most popular)
ITERATORSI T E R A T O R S @luksow
Polyglot vs monoculture
●
Tower of Babel problem
●
Unmaintainable code rewrites costs→ →
●
Multiple platforms lots of ops costs→ →
●
But you want to use best tools and have fun
●
Make recommendations about defaults – and innovate from there
– “We use Scala for such tasks unless there's a better solution”
– “PostgreSQL is our default database because XYZ”
– “We prefer Redis with Rediscala library for caching”
ITERATORSI T E R A T O R S @luksow
Testing
●
Don't test
– “This big” correctness rule
– Run in production, rollback on problems
●
Test – good ol' style
– Unit tests, integration tests, component tests, contract tests, end-to-
end tests
– Favour black-box tests
●
Test – in a distributed system way
– No way to really do that
– Chaos monkey
ITERATORSI T E R A T O R S @luksow
Problems
Distributed systems are hard
ITERATORSI T E R A T O R S @luksow
Operations
●
Infrastructure, different machine utilization strategies
●
Provisioning
●
Deployment pipeline
●
Monitoring
●
Service discovery & confguration management
●
Code templates with boilerplate
●
Close collaboration of developers & operations DevOps→
●
Costs time & money
ITERATORSI T E R A T O R S @luksow
Complexity
●
Complexity never goes away
●
Code complexity communication complexity→
●
It's easy to make (worse) spaghetti there as well
●
MSA requires more code to be written (boilerplate)
●
More work at the initial stage (foundations)
●
Avoid nanoservices maintenance burden→
ITERATORSI T E R A T O R S @luksow
Distributed computing
●
Fallacies of distributed computing (Peter Deutsch, 1994)
– The network is reliable
– Latency is zero
– Bandwidth is infnite
– The network is secure
– Topology doesn't change
– There is one administrator
– Transport cost is zero
– The network is homogeneous
●
Ex. RPC (vs local call)
– It can fail
– It can timeout (and still execute successfully!)
– It is a couple of magnitudes slower
ITERATORSI T E R A T O R S @luksow
Contracts
●
What API should I have?
●
Who are my collaborators?
●
How can I contact them?
●
Make product owners defne API & protocols
●
Service discovery & confguration management (ex.
ZooKeeper, Consul.io)
●
Think about help from providers (libraries, stubs, ex.
Swagger, pact)
ITERATORSI T E R A T O R S @luksow
Versioning
●
How to handle changes?
●
How to handle external (ex. API) changes?
●
Keep multiple versions in production
●
Observe their behaviour
●
Let the load balancers do the heavy lifting
●
Embrace it to do A/B testing
ITERATORSI T E R A T O R S @luksow
Monitoring, metrics
●
Monitor/measure all the things!
●
(You should be doing it in monolith anyway)
●
System metrics, health monitoring
●
Business metrics
●
Keep yourself informed about anomalies
●
Observe analyse react→ →
ITERATORSI T E R A T O R S @luksow
Logging & debugging
●
How do you debug distributed system?
●
Next to impossible, completely different from
monolith
●
Centralized logging with correlation id and
efficient search (no, grep doesn't work anymore)
●
Tracing whenever possible
●
Again, monitor/measure everything (including
network traffic)
ITERATORSI T E R A T O R S @luksow
Security
●
Larger network larger attack surface→
●
Ex. internal API leakage
auth-fb auth-pass auth-codes
btc-users
btc-ws
identity
metrics
session
token
btc-market
Internal API
External API
ITERATORSI T E R A T O R S @luksow
Frontend
●
No microservices solution for frontend
●
Visual coherency coupling→
●
Monoliths (ex. SPA)
●
Fragments
ITERATORSI T E R A T O R S @luksow
Conclusions
tldr;
ITERATORSI T E R A T O R S @luksow
Is it worth it? When?
●
For problems that microservices likely solve
●
If you're working on a well-funded, innovative
products, in a big teams
●
If you have certain DevOps maturity
●
If you can write proper monoliths
●
If you're not expecting a free lunch
ITERATORSI T E R A T O R S @luksow
How to start?
●
Try gradually migrating from monolith, don't
start from scratch
●
Make sure you have DevOps capabilities
●
Reorganize teams around features
●
Think in microservices, not in monolith
●
Don't do “new architecture”, “new platform”,
“new languages” all at once
ITERATORSI T E R A T O R S @luksow
What to remember?
●
Microservices are hard
– Operations
– Complexity
– Distribution
●
But they can be very rewarding
– Team scaling & developer happiness
– Scaling
– Resilience
ITERATORSI T E R A T O R S @luksow
Thanks!
●
Łukasz Sowa
●
http://luksow.com
●
http://iterato.rs
●
contact@luksow.com
●
@luksow
Questions?
1 of 39

Recommended

Microservices in Scala: Spray by
Microservices in Scala: SprayMicroservices in Scala: Spray
Microservices in Scala: SprayŁukasz Sowa
1.9K views10 slides
Loki - like prometheus, but for logs by
Loki - like prometheus, but for logsLoki - like prometheus, but for logs
Loki - like prometheus, but for logsJuraj Hantak
533 views38 slides
RESTEasy Reactive: Why should you care? | DevNation Tech Talk by
RESTEasy Reactive: Why should you care? | DevNation Tech TalkRESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech TalkRed Hat Developers
3.8K views14 slides
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский by
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский Sigma Software
358 views81 slides
Samuel Bercovici - lbaaS for Havana by
Samuel Bercovici - lbaaS for HavanaSamuel Bercovici - lbaaS for Havana
Samuel Bercovici - lbaaS for HavanaCloud Native Day Tel Aviv
3.9K views21 slides
Introduction to Distributed Tracing by
Introduction to Distributed TracingIntroduction to Distributed Tracing
Introduction to Distributed Tracingpetabridge
1.1K views17 slides

More Related Content

What's hot

OpenTelemetry For Operators by
OpenTelemetry For OperatorsOpenTelemetry For Operators
OpenTelemetry For OperatorsKevin Brockhoff
930 views32 slides
Distributed tracing using open tracing & jaeger 2 by
Distributed tracing using open tracing & jaeger 2Distributed tracing using open tracing & jaeger 2
Distributed tracing using open tracing & jaeger 2Chandresh Pancholi
810 views19 slides
Opentracing 101 by
Opentracing 101Opentracing 101
Opentracing 101HungWei Chiu
354 views43 slides
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w... by
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...Yiran Wang
251 views31 slides
High-speed, Reactive Microservices 2017 by
High-speed, Reactive Microservices 2017High-speed, Reactive Microservices 2017
High-speed, Reactive Microservices 2017Rick Hightower
2.3K views59 slides
Distributed tracing with OpenTracing and Jaeger @ getstream.io by
Distributed tracing with OpenTracing and Jaeger @ getstream.ioDistributed tracing with OpenTracing and Jaeger @ getstream.io
Distributed tracing with OpenTracing and Jaeger @ getstream.ioMax Klyga
540 views20 slides

What's hot(20)

Distributed tracing using open tracing & jaeger 2 by Chandresh Pancholi
Distributed tracing using open tracing & jaeger 2Distributed tracing using open tracing & jaeger 2
Distributed tracing using open tracing & jaeger 2
Chandresh Pancholi810 views
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w... by Yiran Wang
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
Yiran Wang251 views
High-speed, Reactive Microservices 2017 by Rick Hightower
High-speed, Reactive Microservices 2017High-speed, Reactive Microservices 2017
High-speed, Reactive Microservices 2017
Rick Hightower2.3K views
Distributed tracing with OpenTracing and Jaeger @ getstream.io by Max Klyga
Distributed tracing with OpenTracing and Jaeger @ getstream.ioDistributed tracing with OpenTracing and Jaeger @ getstream.io
Distributed tracing with OpenTracing and Jaeger @ getstream.io
Max Klyga540 views
Tracing Micro Services with OpenTracing by Hemant Kumar
Tracing Micro Services with OpenTracingTracing Micro Services with OpenTracing
Tracing Micro Services with OpenTracing
Hemant Kumar1.8K views
Function Mesh for Apache Pulsar, the Way for Simple Streaming Solutions by StreamNative
Function Mesh for Apache Pulsar, the Way for Simple Streaming SolutionsFunction Mesh for Apache Pulsar, the Way for Simple Streaming Solutions
Function Mesh for Apache Pulsar, the Way for Simple Streaming Solutions
StreamNative100 views
Fluentd v1.0 in a nutshell by N Masahiro
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshell
N Masahiro9.3K views
FluentD for end to end monitoring by Phil Wilkins
FluentD for end to end monitoringFluentD for end to end monitoring
FluentD for end to end monitoring
Phil Wilkins1.1K views
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021 by StreamNative
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021
StreamNative124 views
Ractor's speed is not light-speed by SATOSHI TAGOMORI
Ractor's speed is not light-speedRactor's speed is not light-speed
Ractor's speed is not light-speed
SATOSHI TAGOMORI4.6K views
OpenDaylight OpenFlow clustering by OpenDaylight
OpenDaylight OpenFlow clusteringOpenDaylight OpenFlow clustering
OpenDaylight OpenFlow clustering
OpenDaylight2K views
Ekon21 Microservices - Event Driven Design by Arnaud Bouchez
Ekon21 Microservices - Event Driven DesignEkon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven Design
Arnaud Bouchez531 views
Fast SOA with Apache Synapse by Paul Fremantle
Fast SOA with Apache SynapseFast SOA with Apache Synapse
Fast SOA with Apache Synapse
Paul Fremantle6.2K views
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus... by StreamNative
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
StreamNative326 views
Grokking Techtalk #40: Consistency and Availability tradeoff in database cluster by Grokking VN
Grokking Techtalk #40: Consistency and Availability tradeoff in database clusterGrokking Techtalk #40: Consistency and Availability tradeoff in database cluster
Grokking Techtalk #40: Consistency and Availability tradeoff in database cluster
Grokking VN1K views
The Java Microservice Library by Rick Hightower
The Java Microservice LibraryThe Java Microservice Library
The Java Microservice Library
Rick Hightower9.3K views

Viewers also liked

Microservices in Scala - theory & practice by
Microservices in Scala - theory & practiceMicroservices in Scala - theory & practice
Microservices in Scala - theory & practiceŁukasz Sowa
1.6K views16 slides
Microservices 101 - The Big Why? by
Microservices 101 - The Big Why?Microservices 101 - The Big Why?
Microservices 101 - The Big Why?Yamen Sader
1.4K views39 slides
Practical Akka HTTP - introduction by
Practical Akka HTTP - introductionPractical Akka HTTP - introduction
Practical Akka HTTP - introductionŁukasz Sowa
8.5K views42 slides
Microservices in Scala: Play Framework by
Microservices in Scala: Play FrameworkMicroservices in Scala: Play Framework
Microservices in Scala: Play FrameworkŁukasz Sowa
8.2K views13 slides
Truly agile company by
Truly agile companyTruly agile company
Truly agile companyMarek Kirejczyk
1.7K views40 slides
Auckland API & Microservices Meetup 1: API led design by
Auckland API & Microservices Meetup 1: API led designAuckland API & Microservices Meetup 1: API led design
Auckland API & Microservices Meetup 1: API led designDamian Harvey
383 views16 slides

Viewers also liked(19)

Microservices in Scala - theory & practice by Łukasz Sowa
Microservices in Scala - theory & practiceMicroservices in Scala - theory & practice
Microservices in Scala - theory & practice
Łukasz Sowa1.6K views
Microservices 101 - The Big Why? by Yamen Sader
Microservices 101 - The Big Why?Microservices 101 - The Big Why?
Microservices 101 - The Big Why?
Yamen Sader1.4K views
Practical Akka HTTP - introduction by Łukasz Sowa
Practical Akka HTTP - introductionPractical Akka HTTP - introduction
Practical Akka HTTP - introduction
Łukasz Sowa8.5K views
Microservices in Scala: Play Framework by Łukasz Sowa
Microservices in Scala: Play FrameworkMicroservices in Scala: Play Framework
Microservices in Scala: Play Framework
Łukasz Sowa8.2K views
Auckland API & Microservices Meetup 1: API led design by Damian Harvey
Auckland API & Microservices Meetup 1: API led designAuckland API & Microservices Meetup 1: API led design
Auckland API & Microservices Meetup 1: API led design
Damian Harvey383 views
Microservices 101: From DevOps to Docker and beyond by Donnie Berkholz
Microservices 101: From DevOps to Docker and beyondMicroservices 101: From DevOps to Docker and beyond
Microservices 101: From DevOps to Docker and beyond
Donnie Berkholz2.3K views
Microservices architecture by Faren faren
Microservices architectureMicroservices architecture
Microservices architecture
Faren faren1.4K views
Securing Microservices using Play and Akka HTTP by Rafal Gancarz
Securing Microservices using Play and Akka HTTPSecuring Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTP
Rafal Gancarz8K views
Microservices - opportunities, dilemmas and problems by Łukasz Sowa
Microservices - opportunities, dilemmas and problemsMicroservices - opportunities, dilemmas and problems
Microservices - opportunities, dilemmas and problems
Łukasz Sowa3.8K views
eServices-Chp5: Microservices et API Management by Lilia Sfaxi
eServices-Chp5: Microservices et API ManagementeServices-Chp5: Microservices et API Management
eServices-Chp5: Microservices et API Management
Lilia Sfaxi6.4K views
Microservices = Death of the Enterprise Service Bus (ESB)? by Kai Wähner
Microservices = Death of the Enterprise Service Bus (ESB)?Microservices = Death of the Enterprise Service Bus (ESB)?
Microservices = Death of the Enterprise Service Bus (ESB)?
Kai Wähner35.5K views
REST and Microservices by Shaun Abram
REST and MicroservicesREST and Microservices
REST and Microservices
Shaun Abram20.3K views
Microservices: Where do they fit within a rapidly evolving integration archit... by Kim Clark
Microservices: Where do they fit within a rapidly evolving integration archit...Microservices: Where do they fit within a rapidly evolving integration archit...
Microservices: Where do they fit within a rapidly evolving integration archit...
Kim Clark5.8K views
Microservices Workshop All Topics Deck 2016 by Adrian Cockcroft
Microservices Workshop All Topics Deck 2016Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016
Adrian Cockcroft33.4K views
Journey to Cloud-Native: Where to start in your app modernization process by VMware Tanzu
Journey to Cloud-Native: Where to start in your app modernization processJourney to Cloud-Native: Where to start in your app modernization process
Journey to Cloud-Native: Where to start in your app modernization process
VMware Tanzu2K views
Principles of microservices velocity by Sam Newman
Principles of microservices   velocityPrinciples of microservices   velocity
Principles of microservices velocity
Sam Newman106.7K views

Similar to Microservices 101: opportunities, dilemmas and problems

A field guide to the Financial Times, Rhys Evans, Financial Times by
A field guide to the Financial Times, Rhys Evans, Financial TimesA field guide to the Financial Times, Rhys Evans, Financial Times
A field guide to the Financial Times, Rhys Evans, Financial TimesNeo4j
63.8K views72 slides
Leveraging Open Standards to Build Highly Extensible Autonomous Systems by
Leveraging Open Standards to Build Highly Extensible Autonomous SystemsLeveraging Open Standards to Build Highly Extensible Autonomous Systems
Leveraging Open Standards to Build Highly Extensible Autonomous SystemsICS
442 views48 slides
Software Engineering Primer by
Software Engineering PrimerSoftware Engineering Primer
Software Engineering PrimerGeorg Buske
46 views72 slides
2020 | Metadata Day | LinkedIn by
2020 | Metadata Day | LinkedIn2020 | Metadata Day | LinkedIn
2020 | Metadata Day | LinkedInDeepak Chandramouli
147 views14 slides
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor... by
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...Radovan Semancik
317 views48 slides
Everything We Learned About In-Memory Data Layout While Building VoltDB by
Everything We Learned About In-Memory Data Layout While Building VoltDBEverything We Learned About In-Memory Data Layout While Building VoltDB
Everything We Learned About In-Memory Data Layout While Building VoltDBjhugg
826 views65 slides

Similar to Microservices 101: opportunities, dilemmas and problems(20)

A field guide to the Financial Times, Rhys Evans, Financial Times by Neo4j
A field guide to the Financial Times, Rhys Evans, Financial TimesA field guide to the Financial Times, Rhys Evans, Financial Times
A field guide to the Financial Times, Rhys Evans, Financial Times
Neo4j63.8K views
Leveraging Open Standards to Build Highly Extensible Autonomous Systems by ICS
Leveraging Open Standards to Build Highly Extensible Autonomous SystemsLeveraging Open Standards to Build Highly Extensible Autonomous Systems
Leveraging Open Standards to Build Highly Extensible Autonomous Systems
ICS442 views
Software Engineering Primer by Georg Buske
Software Engineering PrimerSoftware Engineering Primer
Software Engineering Primer
Georg Buske46 views
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor... by Radovan Semancik
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...
Radovan Semancik317 views
Everything We Learned About In-Memory Data Layout While Building VoltDB by jhugg
Everything We Learned About In-Memory Data Layout While Building VoltDBEverything We Learned About In-Memory Data Layout While Building VoltDB
Everything We Learned About In-Memory Data Layout While Building VoltDB
jhugg826 views
#1 Calicut MuleSoft Meetup - Introduction to Enterprise Integration and MuleSoft by JohnMathewPhilip
#1 Calicut MuleSoft Meetup - Introduction to Enterprise Integration and MuleSoft#1 Calicut MuleSoft Meetup - Introduction to Enterprise Integration and MuleSoft
#1 Calicut MuleSoft Meetup - Introduction to Enterprise Integration and MuleSoft
JohnMathewPhilip424 views
AMW43 - Unba.se, Distributed database for human interaction by Daniel Norman
AMW43 - Unba.se, Distributed database for human interactionAMW43 - Unba.se, Distributed database for human interaction
AMW43 - Unba.se, Distributed database for human interaction
Daniel Norman476 views
Not my problem - Delegating responsibility to infrastructure by Yshay Yaacobi
Not my problem - Delegating responsibility to infrastructureNot my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructure
Yshay Yaacobi563 views
From prototype to production - The journey of re-designing SmartUp.io by Máté Lang
From prototype to production - The journey of re-designing SmartUp.ioFrom prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.io
Máté Lang118 views
The working architecture of NodeJS applications, Виктор Турский by Sigma Software
The working architecture of NodeJS applications, Виктор ТурскийThe working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор Турский
Sigma Software115 views
The working architecture of node js applications open tech week javascript ... by Viktor Turskyi
The working architecture of node js applications   open tech week javascript ...The working architecture of node js applications   open tech week javascript ...
The working architecture of node js applications open tech week javascript ...
Viktor Turskyi527 views
Wie Monolithen für die Zukuft trimmen by Anatole Tresch
Wie Monolithen für die Zukuft trimmenWie Monolithen für die Zukuft trimmen
Wie Monolithen für die Zukuft trimmen
Anatole Tresch751 views
Path dependent-development (PyCon India) by ncoghlan_dev
Path dependent-development (PyCon India)Path dependent-development (PyCon India)
Path dependent-development (PyCon India)
ncoghlan_dev424 views
The journey to container adoption in enterprise by Igor Moochnick
The journey to container adoption in enterpriseThe journey to container adoption in enterprise
The journey to container adoption in enterprise
Igor Moochnick1.9K views
Path Dependent Development (PyCon AU) by ncoghlan_dev
Path Dependent Development (PyCon AU)Path Dependent Development (PyCon AU)
Path Dependent Development (PyCon AU)
ncoghlan_dev959 views
From the South: building together a high-tech ecosystem by Nicolás Erdödy
From the South: building together a high-tech ecosystemFrom the South: building together a high-tech ecosystem
From the South: building together a high-tech ecosystem
Nicolás Erdödy142 views
What drives Innovation? Innovations And Technological Solutions for the Distr... by Stefano Fago
What drives Innovation? Innovations And Technological Solutions for the Distr...What drives Innovation? Innovations And Technological Solutions for the Distr...
What drives Innovation? Innovations And Technological Solutions for the Distr...
Stefano Fago1K views
Your data is in Prometheus, now what? (CurrencyFair Engineering Meetup, 2016) by Brian Brazil
Your data is in Prometheus, now what? (CurrencyFair Engineering Meetup, 2016)Your data is in Prometheus, now what? (CurrencyFair Engineering Meetup, 2016)
Your data is in Prometheus, now what? (CurrencyFair Engineering Meetup, 2016)
Brian Brazil9.4K views
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data by Voxxed Athens
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big DataVoxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
Voxxed Athens109 views

Recently uploaded

Playwright Retries by
Playwright RetriesPlaywright Retries
Playwright Retriesartembondar5
5 views1 slide
Fleet Management Software in India by
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India Fleetable
12 views1 slide
tecnologia18.docx by
tecnologia18.docxtecnologia18.docx
tecnologia18.docxnosi6702
5 views5 slides
Airline Booking Software by
Airline Booking SoftwareAirline Booking Software
Airline Booking SoftwareSharmiMehta
9 views26 slides
360 graden fabriek by
360 graden fabriek360 graden fabriek
360 graden fabriekinfo33492
162 views25 slides
Bootstrapping vs Venture Capital.pptx by
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptxZeljko Svedic
15 views17 slides

Recently uploaded(20)

Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable12 views
tecnologia18.docx by nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67025 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta9 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492162 views
Bootstrapping vs Venture Capital.pptx by Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic15 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P... by NimaTorabi2
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
NimaTorabi216 views
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik8 views
AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8714 views
How Workforce Management Software Empowers SMEs | TraQSuite by TraQSuite
How Workforce Management Software Empowers SMEs | TraQSuiteHow Workforce Management Software Empowers SMEs | TraQSuite
How Workforce Management Software Empowers SMEs | TraQSuite
TraQSuite6 views
Understanding HTML terminology by artembondar5
Understanding HTML terminologyUnderstanding HTML terminology
Understanding HTML terminology
artembondar57 views
ADDO_2022_CICID_Tom_Halpin.pdf by TomHalpin9
ADDO_2022_CICID_Tom_Halpin.pdfADDO_2022_CICID_Tom_Halpin.pdf
ADDO_2022_CICID_Tom_Halpin.pdf
TomHalpin95 views
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation by HCLSoftware
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook AutomationDRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation
DRYiCE™ iAutomate: AI-enhanced Intelligent Runbook Automation
HCLSoftware6 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski13 views
Generic or specific? Making sensible software design decisions by Bert Jan Schrijver
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions

Microservices 101: opportunities, dilemmas and problems

  • 1. ITERATORSI T E R A T O R S @luksow Microservices 101 opportunities, dilemmas and problems Łukasz Sowa, 4Developers 2015
  • 2. ITERATORSI T E R A T O R S @luksow Hi, I'm Łukasz ● Co-founder, engineer @ Iterators (http://iterato.rs) ● Highly concurrent & distributed systems ● Pizza, beer & football lover ● http://luksow.com ● contact@luksow.com ● @luksow
  • 3. ITERATORSI T E R A T O R S @luksow What's in it for you? ● Learn – What are microservices? – Why they might be useful? – What questions do they bring up? – What's hard about them? ● Takeaways – Feel enthusiastic but cautious about microservices – Be able to design your next project using microservices
  • 4. ITERATORSI T E R A T O R S @luksow What are microservices? ● Architectural style (MSA) ● System is composed of multiple services – Small* – Independently deployed – Communicate using (lightweight) protocols – Organized around business capabilities ● Bounded Context (DDD) or Single Responsibility Principle (OO) implemented in architecture
  • 5. ITERATORSI T E R A T O R S @luksow Why? Why now? ● Post-SOA (or SOA done right?) ● DevOps revolution (provisioning, deployment) ● Cheap hardware ● Existing systems got too big and too boring? ● Innovation market got immensely demanding (Netflix, Gilt, Tumblr, Amazon, SoundCloud)
  • 6. ITERATORSI T E R A T O R S @luksow Let's design! Design a system that allows users to login/register using FB, email-password or codecard. Authenticated user can subscribe to different events from BTC markets (ex. rate changed, volume over N, ask below M etc.) and get real-time alerts about them. Make sure to gather relevant business metrics. auth-fb auth-pass auth-codes btc-users btc-ws identity metrics session token frontend btc-market load balancer
  • 7. ITERATORSI T E R A T O R S @luksow Opportunities Why people love microservices?
  • 8. ITERATORSI T E R A T O R S @luksow Technical advantages ● Horizontal scaling performance→ ● Designing for failure resilience→ auth-fb auth-pass auth-codes btc-users btc-ws identity metrics session token frontend btc-market load balancer btc-wsbtc-ws Scaling X Resilience
  • 9. ITERATORSI T E R A T O R S @luksow Cultural advantages (1) Any organization that designs a system (defined more broadly here than just information systems) will inevitably produce a design whose structure is a copy of the organization's communication structure. Melvin Conway, How Do Committees Invent, 1968
  • 10. ITERATORSI T E R A T O R S @luksow Cultural advantages (2) ● Siloed teams vs cross-functional teams ● Less communication overhead ● Business-oriented teams – microbusinesses ● The True Way of (scrum) team scaling ● Agility + autonomy → short time-to-market MGR UX FE DEV BE DEV DBA OPS QA vs
  • 11. ITERATORSI T E R A T O R S @luksow Cultural advantages (3) ● Easy to understand ● Dispose/rewrite vs refactor ● Polyglot environment, better tools utilization ● Mythical reusability? ● Fun!
  • 12. ITERATORSI T E R A T O R S @luksow Dilemmas Decisions, decisions, decisions...
  • 13. ITERATORSI T E R A T O R S @luksow Communication, protocols ● Communication - most important MSA concern ● Microservices ≠ REST ● Plethora of possibilities – Universal: REST+JSON/XML, MQs, binary TCP/UDP, ... simple, decoupled,→ polyglot but low-level, full of boilerplate, possible code duplication – Platform-specifc: Akka, Finagle, … easier to code & maintain, code reuse→ but tightly coupled, platform-dependant, not polyglot ● Prefer universal & lightweight (UNIX - smart endpoints, dumb pipes) ● Microservices are mostly REST ● Remember about Postel's law
  • 14. ITERATORSI T E R A T O R S @luksow Synchronous vs asynchronous ● Request-response ● ASAP response ● “Asking” ● Fail-fast ● Easy to reason about ● Timeouts? ● Don't scale Ex. REST, ... ● Message passing ● Deferred processing ● “Telling” ● Unnatural ● Complicated, hard to debug ● Recovering from failures ● Scale Ex. WebSockets, MQs, Akka, UDP, ...
  • 15. ITERATORSI T E R A T O R S @luksow Protocols in action auth-fb auth-pass auth-codes btc-users btc-ws identity metrics session token btc-market REST/JSON WebSockets REST/JSON Akka AkkaHTTP Keep-Alive
  • 16. ITERATORSI T E R A T O R S @luksow Guarantees ● What guarantees do you need? – What's the cost of a single message being lost? – What happens if system is in inconsistent state? – … ● No ACID (atomicity, consistency, isolation, durability) ● But CAP theorem (consistency, availability, partition tolerance) ● Eventual consistency, 2PC, 3PC, Paxos & others are your friends now ● What do you need? What can/cannot you afford? ● And no, you can't have everything
  • 17. ITERATORSI T E R A T O R S @luksow Shared vs private data stores ● Source of truth ● Strong contract/protocol ● Convenient ● Coupling ● Don't scale ● Ownership issues ● Service becomes an abstraction over DS ● Polyglot persistence ● Decoupling ● Scale ● Truth is distributed ● Façade issues ● Recommended
  • 18. ITERATORSI T E R A T O R S @luksow Private data stores auth-fb auth-pass auth-codes btc-users btc-ws identity metrics session token btc-market MongoDB Redis PostgreSQL PostgreSQL PostgreSQL MongoDB Event journal
  • 19. ITERATORSI T E R A T O R S @luksow Shared data stores auth-fb auth-pass auth-codes btc-users btc-ws metrics session btc-market MongoDB token Redis PostgreSQL PostgreSQL PostgreSQL identity MongoDB Event journal
  • 20. ITERATORSI T E R A T O R S @luksow Size & structure ● How big is microservice? – ~100 lines rule is a lie – Up to a couple of thousands LOC in most cases – Rule: as short as possible but as big as necessary ● Clean & structured vs short & hacky Resources Service Domain Repositories Data mappers Gateways Applicationvs ● Well-structured ● Requires time to analyse ● Easy to maintain ● Longer ● Unstructured ● Understandable at a glance ● Hard to maintain ● Much shorter
  • 21. ITERATORSI T E R A T O R S @luksow Size & structure - example Name Structured? LoC / eLoC auth-fb Yes 215 / 189 auth-pass Yes 301 / 258 auth-codes Yes 337 / 299 identity No 77 / 66 session No 48 / 43 token Yes 182 / 167 metrics No 160 / 150 btc-ws No 155 / 140 btc-users Yes 153 / 141 btc-market No 51 / 40 TOTAL 5 Yes / 5 No 1679 / 1493
  • 22. ITERATORSI T E R A T O R S @luksow Code sharing Sometimes the same code is required in two or more services – how to share it? ● Shared library coupling, not polyglot→ ● Nanoservice maintenance burden, performance→ ● Copy-paste duplication, more code to maintain→ No good answer here (3rd is the most popular)
  • 23. ITERATORSI T E R A T O R S @luksow Polyglot vs monoculture ● Tower of Babel problem ● Unmaintainable code rewrites costs→ → ● Multiple platforms lots of ops costs→ → ● But you want to use best tools and have fun ● Make recommendations about defaults – and innovate from there – “We use Scala for such tasks unless there's a better solution” – “PostgreSQL is our default database because XYZ” – “We prefer Redis with Rediscala library for caching”
  • 24. ITERATORSI T E R A T O R S @luksow Testing ● Don't test – “This big” correctness rule – Run in production, rollback on problems ● Test – good ol' style – Unit tests, integration tests, component tests, contract tests, end-to- end tests – Favour black-box tests ● Test – in a distributed system way – No way to really do that – Chaos monkey
  • 25. ITERATORSI T E R A T O R S @luksow Problems Distributed systems are hard
  • 26. ITERATORSI T E R A T O R S @luksow Operations ● Infrastructure, different machine utilization strategies ● Provisioning ● Deployment pipeline ● Monitoring ● Service discovery & confguration management ● Code templates with boilerplate ● Close collaboration of developers & operations DevOps→ ● Costs time & money
  • 27. ITERATORSI T E R A T O R S @luksow Complexity ● Complexity never goes away ● Code complexity communication complexity→ ● It's easy to make (worse) spaghetti there as well ● MSA requires more code to be written (boilerplate) ● More work at the initial stage (foundations) ● Avoid nanoservices maintenance burden→
  • 28. ITERATORSI T E R A T O R S @luksow Distributed computing ● Fallacies of distributed computing (Peter Deutsch, 1994) – The network is reliable – Latency is zero – Bandwidth is infnite – The network is secure – Topology doesn't change – There is one administrator – Transport cost is zero – The network is homogeneous ● Ex. RPC (vs local call) – It can fail – It can timeout (and still execute successfully!) – It is a couple of magnitudes slower
  • 29. ITERATORSI T E R A T O R S @luksow Contracts ● What API should I have? ● Who are my collaborators? ● How can I contact them? ● Make product owners defne API & protocols ● Service discovery & confguration management (ex. ZooKeeper, Consul.io) ● Think about help from providers (libraries, stubs, ex. Swagger, pact)
  • 30. ITERATORSI T E R A T O R S @luksow Versioning ● How to handle changes? ● How to handle external (ex. API) changes? ● Keep multiple versions in production ● Observe their behaviour ● Let the load balancers do the heavy lifting ● Embrace it to do A/B testing
  • 31. ITERATORSI T E R A T O R S @luksow Monitoring, metrics ● Monitor/measure all the things! ● (You should be doing it in monolith anyway) ● System metrics, health monitoring ● Business metrics ● Keep yourself informed about anomalies ● Observe analyse react→ →
  • 32. ITERATORSI T E R A T O R S @luksow Logging & debugging ● How do you debug distributed system? ● Next to impossible, completely different from monolith ● Centralized logging with correlation id and efficient search (no, grep doesn't work anymore) ● Tracing whenever possible ● Again, monitor/measure everything (including network traffic)
  • 33. ITERATORSI T E R A T O R S @luksow Security ● Larger network larger attack surface→ ● Ex. internal API leakage auth-fb auth-pass auth-codes btc-users btc-ws identity metrics session token btc-market Internal API External API
  • 34. ITERATORSI T E R A T O R S @luksow Frontend ● No microservices solution for frontend ● Visual coherency coupling→ ● Monoliths (ex. SPA) ● Fragments
  • 35. ITERATORSI T E R A T O R S @luksow Conclusions tldr;
  • 36. ITERATORSI T E R A T O R S @luksow Is it worth it? When? ● For problems that microservices likely solve ● If you're working on a well-funded, innovative products, in a big teams ● If you have certain DevOps maturity ● If you can write proper monoliths ● If you're not expecting a free lunch
  • 37. ITERATORSI T E R A T O R S @luksow How to start? ● Try gradually migrating from monolith, don't start from scratch ● Make sure you have DevOps capabilities ● Reorganize teams around features ● Think in microservices, not in monolith ● Don't do “new architecture”, “new platform”, “new languages” all at once
  • 38. ITERATORSI T E R A T O R S @luksow What to remember? ● Microservices are hard – Operations – Complexity – Distribution ● But they can be very rewarding – Team scaling & developer happiness – Scaling – Resilience
  • 39. ITERATORSI T E R A T O R S @luksow Thanks! ● Łukasz Sowa ● http://luksow.com ● http://iterato.rs ● contact@luksow.com ● @luksow Questions?