Microservices - opportunities, dilemmas and problems

Łukasz Sowa
Łukasz SowaCo-founder, managing partner at Iterators
Microservices in Scala 
workshop by Iterators 
by Jacek Głodek, Łukasz Sowa and Andrzej Michałowski
Questions we try to answer today: 
• What are microservices? 
• What's the difference between them vs monolithic 
architectures? 
• What are the different flavours of microservices? 
• How to use Spray.io, Play and Akka to do 
microservices?
Agenda 
• Short introduction to microservices 
• Spec of our system 
• "MS backbone - simple microservices with spray.io" talk 
• Auth and url collection microservices 
• "Asynchronous views and web services with Play and Akka" talk 
• Image fetching — reactive deffered job — Play with websockets 
• "Eventsourcing - total data immutability with akka persistence" talk 
• Voting made with event sourcing 
• Ops, testing and monitoring 
• Summary
Architectures and practices 
What architectures are we talking about?! 
Don't think MVC, think MVC web-app run on multiple 
nodes with load-balancing, memcached cache and 
Postgres db. 
What practices are we talking about?! 
Think TDD, BDD, SOLID, etc.
Code and code-base 
architecture and practices 
• programming paradigms 
• TDD, SOLID, BDD, etc. 
• Folder structure 
• Object naming conventions 
• Separation of concerns 
• Sharing data in threads
Distributed system 
architecture 
• Interfaces, protocols and 
contracts between modules 
• System modules 
• APIs 
• Deployment strategy 
• Non-functional guarantees
“Microservices” 
is a vague term 
• multiple small apps with REST/HTTP interface, 
• multiple small apps with deferred message 
processing 
• multiple single-file apps with less than 100 lines of 
code 
• multiple small apps possibly written in different 
languages communicating with each other
Microservices 
• small single-purpose apps with bounded domain 
enabling polyglot programming 
+ add your favourite ingredients 
+ differences from monolithic architecture 
© Marivlada | Dreamstime Stock 
Photos & Stock Free Images
Microservices vs Monolithic architecture 
Deployment units 
Monolith Microservices
Microservices vs Monolithic architecture 
Deployment strategy 
Monolith Microservices
Microservices vs Monolithic architecture 
Coupling 
Monolith Microservices 
• global variables 
• messages 
• function calls 
• data structures 
• shared memory 
• multiple levels of indirection 
managed with 
• SOLID, encapsulation and other practices 
• dependency injection, etc. 
• different protocols 
• shared DB’s 
• shared message queues 
managed with 
• contracts
Microservices vs Monolithic architecture 
Interfaces vs Contracts 
Monolith Microservices 
• written with code and shared interfaces 
within code packages and libraries 
• checked by tests or compilers (?) 
• type validations 
• api calls defined by the language 
• encapsulation, single-responsibility 
rule, etc. 
Problems: 
• meta-programming, monkey-patching, 
global state and workarounds. 
• spoken / unspoken 
• should be defined on “paper” 
• defined by protocols, and technologies 
used, like: 
• http, websockets, RPC, rabbitMQ, 
shared MongoDB or Redis, etc. ) 
Problems: 
• changing contract or having no contract 
requires changing multiple services. 
• multiple API versions without easy 
solution for validating consistency
Programming microservices
Small single purpose code 
• Low complexity 
• No code-level coupling 
with other modules 
• “this big” or one 
hundred lines of code 
• Easy to rewrite 
• Rewrite instead of 
refactor 
• Easy to spot inputs and 
outputs 
• Still requires readable 
logic
Relevant metrics 
• Measuring business 
performance using relevant 
metrics 
• Visualisation 
• Ex. Kamon, custom charts 
Ex: 
• forms processed, 
• mails sent, 
• PDF invoices generated 
• performance metrics: 
• response times 
• queue sizes 
• ex. New Relic, etc.
Continuous deployment with hot 
swapping 
Having all the metrics: 
• You can deploy continuously 
• You can test the service by deploying new and old 
versions concurrently. 
• Given enough fail-safety contracts, you can test in 
production 
• One service down shouldn’t break whole architecture
Polyglot programming
Problems and dilemmas
Problems and Dilemmas 
• synchronous and asynchronous processing 
• guarantees and SLAs 
• shared and private databases 
• making layers of micro services 
• bare-metal vs platforms 
• data-driven systems, eventsourcing and real-time 
messaging
Synchronous vs 
Asynchronous processing 
Synchronous processing 
• immediate responses 
• fast and hard failure 
• “asking” 
• request timeouts 
• problematic to debug series of request 
Ex. chain of HTTP request and getting 200 
Success response 
Asynchronous processing 
• posting jobs to be processed 
• tell don’t ask 
• fire and forget 
• need of pooling or waiting for response 
• longer jobs 
• failures can be recovered from! 
Ex. uploading a video file to be processed 
and getting “Video uploaded successfuly” 
response.
Guarantees and SLA’s 
Is clicking like button same as performing bank transfer? Do we really need full 
ACID DB for holding chat messages? Will it perform fast enough to serve 
thousand of clients concurrently without building whole cluster of DB’s? 
100% consistency and synchronicity is not possible to achieve in distributed 
system without introducing system wide locks. 
System-wide locks affect performance a lot, while we try to achieve reactive and 
scalable system. 
In microservices we can keep different parts of system with different guarantees 
and different approaches
Shared vs private databases 
Shared database 
• pretty strong contract 
• convenient for simple domain problems 
• easier to maintain 
• problems: 
• coupling too many services, too deeply. 
• can become performance bottle-neck 
Private databases 
• useful for decoupling and reuse 
• useful for performance 
• useful for embedding in microservices that abstract 
complicated domain models 
• difficult to maintain, although can many databases can 
work on single db cluster/instance. 
• useful for giving microservice authority over some data 
• problems: 
• data sharding
Layers of micro services 
frontend, public facing micro services, 
background workers and services
Layers of micro services 
frontend issues 
• CORS (Cross Origin Resource Sharing) 
• Rendering of HTML: server-side or in javascript 
• Moving caches to CDN 
• Keeping modularity and reusability also on the frontend side 
• One backend microservice failure shouldn’t break whole frontend.
Layers of micro services 
user facing services issues 
• CORS 
• Versioning of API 
• Authentication 
• Caching 
• Loadbalancing 
• Security
Layers of micro services 
internal services 
• Security 
• Scalability 
• Monitoring for failures 
• Keeping the data consistent 
• Garbage-in garbage-out
Platform abstraction level 
bare-metal servers vs platforms 
Higher level framework = more difficult polyglot 
programming + easier maintenance + possible code 
sharing + more tight coupling opportunities
Stateful databases vs 
eventsourcing 
Stateful databases 
• State stored in the database 
• Ex. “John has $3122 
USD on his account” 
• Transactions and locks that 
enable us to mutate the 
state 
Eventsourcing 
• No state just events. 
• Ex. “John got spent $12 USD” 
• State is inferred from the past 
events… 
• Every situation can be replayed! 
• Events are immutable = no 
problem with locking, etc. 
We can also not care about keeping the data at all.
… and other dilemmas. 
But…
Why not mix all the approaches?
Can sole database 
be a microservice?
Must microservice be 
based on 
REST interfaces?
How would you 
model microservices 
for the last system 
you developed?
That’s it for the intro 
Thanks! 
jacek@theiterators.com
Summary 
Microservices come in different flavours:! 
sync, async, rest, mq, databases, events, hard 
and easy guarantees, with private and shared 
databases, based on bare-metal machines and 
high level platforms. 
© Marivlada | Dreamstime Stock 
Photos & Stock Free Images
Summary 
Spray is great foundation: 
for simple HTTP services 
for connecting with awesome Akka processing framework 
with great directives for strictly defining what requests get 
processed 
with great marshalling and serialisation 
who make simple easy and abstractable
Summary 
Play is has some useful elements: 
! 
nice routing DSL, 
nice controller with Action composing 
nice Websockets with Akka actors 
lots of libraries to integrate to 
big boilerplate
Summary 
Akka is great for messaging, makes concurrent 
programming easy! 
! Actors are not threads 
Messages and Questions with timeouts 
Scheduling 
Watch not to make bloated — keep it single 
purpose
Summary 
Eventsourcing ! 
! Don’t store mutable state 
Store immutable events 
Rebuild state by processing the past events 
Akka persistance stores the events for you in a 
journal of choice (Mongo, Redis, Postgres, Maria, 
Mysql)
What haven’t we talked about 
! 
JVM microframeworks — Finagle, etc. 
Frontend — how to keep modularity, where to generate HTML, 
how to handle caching. 
Monitoring — health checks and metrics (spray directives?) and 
monitoring front end 
DevOps — How to configure loadbalancers, CORS, handling 
configuration and discovery of microservices, prepare auto-scaling, 
and handling situations when services fail, or how to make 
hot swap deployments.
Thanks! 
Łukasz Sowa @luksow 
lukasz@theiterators.com 
Jacek Głodek @jacekglodek 
jacek@theiterators.com
1 of 41

Recommended

Building microservices web application using scala & akka by
Building microservices web application using scala & akkaBuilding microservices web application using scala & akka
Building microservices web application using scala & akkaBinh Nguyen
3.1K views51 slides
Microservices Architecture by
Microservices ArchitectureMicroservices Architecture
Microservices ArchitectureSrinivasan Nanduri
318 views41 slides
Micro services Architecture by
Micro services ArchitectureMicro services Architecture
Micro services ArchitectureJenis Dharmadurai
134 views42 slides
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
Data stores: beyond relational databases by
Data stores: beyond relational databasesData stores: beyond relational databases
Data stores: beyond relational databasesJavier García Magna
736 views44 slides
Debugging Microservices - key challenges and techniques - Microservices Odesa... by
Debugging Microservices - key challenges and techniques - Microservices Odesa...Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Lohika_Odessa_TechTalks
88 views32 slides

More Related Content

What's hot

Microservices with Spring by
Microservices with SpringMicroservices with Spring
Microservices with SpringSoftware Infrastructure
721 views34 slides
Come for the traffic management, stay for the security by
Come for the traffic management, stay for the securityCome for the traffic management, stay for the security
Come for the traffic management, stay for the securityChristian Posta
723 views26 slides
Microservices Antipatterns by
Microservices AntipatternsMicroservices Antipatterns
Microservices AntipatternsC4Media
3.1K views80 slides
Tokyo Azure Meetup #6 - Azure Monthly Update - June by
Tokyo Azure Meetup #6 - Azure Monthly Update - JuneTokyo Azure Meetup #6 - Azure Monthly Update - June
Tokyo Azure Meetup #6 - Azure Monthly Update - JuneTokyo Azure Meetup
210 views18 slides
REST vs. Messaging For Microservices by
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesEberhard Wolff
76.8K views40 slides
Microservices Journey Fall 2017 by
Microservices Journey Fall 2017Microservices Journey Fall 2017
Microservices Journey Fall 2017Christian Posta
1.1K views81 slides

What's hot(20)

Come for the traffic management, stay for the security by Christian Posta
Come for the traffic management, stay for the securityCome for the traffic management, stay for the security
Come for the traffic management, stay for the security
Christian Posta723 views
Microservices Antipatterns by C4Media
Microservices AntipatternsMicroservices Antipatterns
Microservices Antipatterns
C4Media3.1K views
Tokyo Azure Meetup #6 - Azure Monthly Update - June by Tokyo Azure Meetup
Tokyo Azure Meetup #6 - Azure Monthly Update - JuneTokyo Azure Meetup #6 - Azure Monthly Update - June
Tokyo Azure Meetup #6 - Azure Monthly Update - June
Tokyo Azure Meetup210 views
REST vs. Messaging For Microservices by Eberhard Wolff
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For Microservices
Eberhard Wolff76.8K views
Microservices Journey Fall 2017 by Christian Posta
Microservices Journey Fall 2017Microservices Journey Fall 2017
Microservices Journey Fall 2017
Christian Posta1.1K views
Microservices and Integration: what's next with Istio service mesh by Christian Posta
Microservices and Integration: what's next with Istio service meshMicroservices and Integration: what's next with Istio service mesh
Microservices and Integration: what's next with Istio service mesh
Christian Posta3.3K views
Istio: solving challenges of hybrid cloud by Christian Posta
Istio: solving challenges of hybrid cloudIstio: solving challenges of hybrid cloud
Istio: solving challenges of hybrid cloud
Christian Posta890 views
Global Azure Bootcamp: Azure service fabric by Luis Valencia
Global Azure Bootcamp: Azure service fabric Global Azure Bootcamp: Azure service fabric
Global Azure Bootcamp: Azure service fabric
Luis Valencia455 views
Lowering the risk of monolith to microservices by Christian Posta
Lowering the risk of monolith to microservicesLowering the risk of monolith to microservices
Lowering the risk of monolith to microservices
Christian Posta1.9K views
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric by Tokyo Azure Meetup
Tokyo Azure Meetup #5 - Microservices and Azure Service FabricTokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup517 views
Atlanta Microservices Day: Istio Service Mesh by Christian Posta
Atlanta Microservices Day: Istio Service MeshAtlanta Microservices Day: Istio Service Mesh
Atlanta Microservices Day: Istio Service Mesh
Christian Posta3.9K views
Continuous delivery by sergey seletsky by Sergey Seletsky
Continuous delivery by sergey seletskyContinuous delivery by sergey seletsky
Continuous delivery by sergey seletsky
Sergey Seletsky1K views
THEFT-PROOF JAVA EE - SECURING YOUR JAVA EE APPLICATIONS by Markus Eisele
 THEFT-PROOF JAVA EE - SECURING YOUR JAVA EE APPLICATIONS THEFT-PROOF JAVA EE - SECURING YOUR JAVA EE APPLICATIONS
THEFT-PROOF JAVA EE - SECURING YOUR JAVA EE APPLICATIONS
Markus Eisele6.5K views
20160317 lagom sf scala by shinolajla
20160317 lagom sf scala20160317 lagom sf scala
20160317 lagom sf scala
shinolajla1.7K views

Viewers also liked

Modern Software Architecture - Cloud Scale Computing by
Modern Software Architecture - Cloud Scale ComputingModern Software Architecture - Cloud Scale Computing
Modern Software Architecture - Cloud Scale ComputingGiragadurai Vallirajan
2.2K views59 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
Software Architecture for Cloud Infrastructure by
Software Architecture for Cloud InfrastructureSoftware Architecture for Cloud Infrastructure
Software Architecture for Cloud InfrastructureTapio Rautonen
4.7K views35 slides
Microservices in Scala: Spray by
Microservices in Scala: SprayMicroservices in Scala: Spray
Microservices in Scala: SprayŁukasz Sowa
1.9K views10 slides
Microservices 101: opportunities, dilemmas and problems by
Microservices 101: opportunities, dilemmas and problemsMicroservices 101: opportunities, dilemmas and problems
Microservices 101: opportunities, dilemmas and problemsŁukasz Sowa
1.8K views39 slides
Truly agile company by
Truly agile companyTruly agile company
Truly agile companyMarek Kirejczyk
1.7K views40 slides

Viewers also liked(20)

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
Software Architecture for Cloud Infrastructure by Tapio Rautonen
Software Architecture for Cloud InfrastructureSoftware Architecture for Cloud Infrastructure
Software Architecture for Cloud Infrastructure
Tapio Rautonen4.7K views
Microservices in Scala: Spray by Łukasz Sowa
Microservices in Scala: SprayMicroservices in Scala: Spray
Microservices in Scala: Spray
Łukasz Sowa1.9K views
Microservices 101: opportunities, dilemmas and problems by Łukasz Sowa
Microservices 101: opportunities, dilemmas and problemsMicroservices 101: opportunities, dilemmas and problems
Microservices 101: opportunities, dilemmas and problems
Łukasz Sowa1.8K views
Cognos vs Hyperion vs SSAS Comparison by Asis Mohanty
Cognos vs Hyperion vs SSAS ComparisonCognos vs Hyperion vs SSAS Comparison
Cognos vs Hyperion vs SSAS Comparison
Asis Mohanty9.2K views
Developing Event-driven Microservices with Event Sourcing & CQRS (gotoams) by Chris Richardson
Developing Event-driven Microservices with Event Sourcing & CQRS (gotoams)Developing Event-driven Microservices with Event Sourcing & CQRS (gotoams)
Developing Event-driven Microservices with Event Sourcing & CQRS (gotoams)
Chris Richardson4.6K views
8051 microcontroller notes continuous by THANDAIAH PRABU
8051 microcontroller notes continuous 8051 microcontroller notes continuous
8051 microcontroller notes continuous
THANDAIAH PRABU5.2K views
Duplicating data or replicating data in Micro Services by Dennis van der Stelt
Duplicating data or replicating data in Micro ServicesDuplicating data or replicating data in Micro Services
Duplicating data or replicating data in Micro Services
Practical Akka HTTP - introduction by Łukasz Sowa
Practical Akka HTTP - introductionPractical Akka HTTP - introduction
Practical Akka HTTP - introduction
Łukasz Sowa8.5K views
Building and deploying microservices with event sourcing, CQRS and Docker (Be... by Chris Richardson
Building and deploying microservices with event sourcing, CQRS and Docker (Be...Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Chris Richardson38.8K views
Asynchronous and synchronous by Akhil .B
Asynchronous and synchronousAsynchronous and synchronous
Asynchronous and synchronous
Akhil .B29.4K views
Php development with Docker by Michael Bui
Php development with DockerPhp development with Docker
Php development with Docker
Michael Bui364 views
Git Workshop : Getting Started by Wildan Maulana
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
Wildan Maulana913 views
Information Design Web Planning Mockup by ANGELA Smithers
Information Design Web Planning MockupInformation Design Web Planning Mockup
Information Design Web Planning Mockup
ANGELA Smithers507 views
component based softwrae engineering Cbse by Sravs Dals
component based softwrae engineering Cbsecomponent based softwrae engineering Cbse
component based softwrae engineering Cbse
Sravs Dals837 views

Similar to Microservices - opportunities, dilemmas and problems

Introduction to Microservices by
Introduction to MicroservicesIntroduction to Microservices
Introduction to MicroservicesMahmoudZidan41
783 views30 slides
Pros & Cons of Microservices Architecture by
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitectureAshwini Kuntamukkala
2.8K views31 slides
Building FoundationDB by
Building FoundationDBBuilding FoundationDB
Building FoundationDBFoundationDB
3.4K views38 slides
Accelerate DevOps/Microservices and Kubernetes by
Accelerate DevOps/Microservices and KubernetesAccelerate DevOps/Microservices and Kubernetes
Accelerate DevOps/Microservices and KubernetesRick Hightower
224 views70 slides
Data Engineer, Patterns & Architecture The future: Deep-dive into Microservic... by
Data Engineer, Patterns & Architecture The future: Deep-dive into Microservic...Data Engineer, Patterns & Architecture The future: Deep-dive into Microservic...
Data Engineer, Patterns & Architecture The future: Deep-dive into Microservic...Igor De Souza
492 views42 slides
DCEU 18: From Monolith to Microservices by
DCEU 18: From Monolith to MicroservicesDCEU 18: From Monolith to Microservices
DCEU 18: From Monolith to MicroservicesDocker, Inc.
267 views28 slides

Similar to Microservices - opportunities, dilemmas and problems(20)

Introduction to Microservices by MahmoudZidan41
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
MahmoudZidan41783 views
Building FoundationDB by FoundationDB
Building FoundationDBBuilding FoundationDB
Building FoundationDB
FoundationDB3.4K views
Accelerate DevOps/Microservices and Kubernetes by Rick Hightower
Accelerate DevOps/Microservices and KubernetesAccelerate DevOps/Microservices and Kubernetes
Accelerate DevOps/Microservices and Kubernetes
Rick Hightower224 views
Data Engineer, Patterns & Architecture The future: Deep-dive into Microservic... by Igor De Souza
Data Engineer, Patterns & Architecture The future: Deep-dive into Microservic...Data Engineer, Patterns & Architecture The future: Deep-dive into Microservic...
Data Engineer, Patterns & Architecture The future: Deep-dive into Microservic...
Igor De Souza492 views
DCEU 18: From Monolith to Microservices by Docker, Inc.
DCEU 18: From Monolith to MicroservicesDCEU 18: From Monolith to Microservices
DCEU 18: From Monolith to Microservices
Docker, Inc.267 views
IBM Connect 2017: Your Data In the Major Leagues: A Practical Guide to REST S... by Serdar Basegmez
IBM Connect 2017: Your Data In the Major Leagues: A Practical Guide to REST S...IBM Connect 2017: Your Data In the Major Leagues: A Practical Guide to REST S...
IBM Connect 2017: Your Data In the Major Leagues: A Practical Guide to REST S...
Serdar Basegmez678 views
Cloud-native Data: Every Microservice Needs a Cache by cornelia davis
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cache
cornelia davis4.4K views
Iot cloud service v2.0 by Vinod Wilson
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0
Vinod Wilson495 views
AWS Serverless Community Day Keynote and Vendia Launch 6-26-2020 by Tim Wagner
AWS Serverless Community Day Keynote and Vendia Launch 6-26-2020AWS Serverless Community Day Keynote and Vendia Launch 6-26-2020
AWS Serverless Community Day Keynote and Vendia Launch 6-26-2020
Tim Wagner1.8K views
Introduction to microservices by Anil Allewar
Introduction to microservicesIntroduction to microservices
Introduction to microservices
Anil Allewar1.2K views
Concurrency at Scale: Evolution to Micro-Services by Randy Shoup
Concurrency at Scale:  Evolution to Micro-ServicesConcurrency at Scale:  Evolution to Micro-Services
Concurrency at Scale: Evolution to Micro-Services
Randy Shoup9.4K views
Software Architecture and Architectors: useless VS valuable by Comsysto Reply GmbH
Software Architecture and Architectors: useless VS valuableSoftware Architecture and Architectors: useless VS valuable
Software Architecture and Architectors: useless VS valuable
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20... by Javier García Magna
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20....Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
How to grow your own Microservice? by Dmitry Buzdin
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
Dmitry Buzdin685 views
SpringPeople - Introduction to Cloud Computing by SpringPeople
SpringPeople - Introduction to Cloud ComputingSpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud Computing
SpringPeople252 views

Recently uploaded

Bootstrapping vs Venture Capital.pptx by
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptxZeljko Svedic
15 views17 slides
Quality Assurance by
Quality Assurance Quality Assurance
Quality Assurance interworksoftware2
5 views6 slides
Keep by
KeepKeep
KeepGeniusee
78 views10 slides
tecnologia18.docx by
tecnologia18.docxtecnologia18.docx
tecnologia18.docxnosi6702
5 views5 slides
Top-5-production-devconMunich-2023-v2.pptx by
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTier1 app
6 views42 slides
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P... by
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...NimaTorabi2
16 views17 slides

Recently uploaded(20)

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
tecnologia18.docx by nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67025 views
Top-5-production-devconMunich-2023-v2.pptx by Tier1 app
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
Tier1 app6 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
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
Quality Engineer: A Day in the Life by John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino7 views
Electronic AWB - Electronic Air Waybill by Freightoscope
Electronic AWB - Electronic Air Waybill Electronic AWB - Electronic Air Waybill
Electronic AWB - Electronic Air Waybill
Freightoscope 5 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok16 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
Introduction to Git Source Control by John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino7 views
JioEngage_Presentation.pptx by admin125455
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptx
admin1254558 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
Sprint 226 by ManageIQ
Sprint 226Sprint 226
Sprint 226
ManageIQ11 views
predicting-m3-devopsconMunich-2023.pptx by Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app8 views

Microservices - opportunities, dilemmas and problems

  • 1. Microservices in Scala workshop by Iterators by Jacek Głodek, Łukasz Sowa and Andrzej Michałowski
  • 2. Questions we try to answer today: • What are microservices? • What's the difference between them vs monolithic architectures? • What are the different flavours of microservices? • How to use Spray.io, Play and Akka to do microservices?
  • 3. Agenda • Short introduction to microservices • Spec of our system • "MS backbone - simple microservices with spray.io" talk • Auth and url collection microservices • "Asynchronous views and web services with Play and Akka" talk • Image fetching — reactive deffered job — Play with websockets • "Eventsourcing - total data immutability with akka persistence" talk • Voting made with event sourcing • Ops, testing and monitoring • Summary
  • 4. Architectures and practices What architectures are we talking about?! Don't think MVC, think MVC web-app run on multiple nodes with load-balancing, memcached cache and Postgres db. What practices are we talking about?! Think TDD, BDD, SOLID, etc.
  • 5. Code and code-base architecture and practices • programming paradigms • TDD, SOLID, BDD, etc. • Folder structure • Object naming conventions • Separation of concerns • Sharing data in threads
  • 6. Distributed system architecture • Interfaces, protocols and contracts between modules • System modules • APIs • Deployment strategy • Non-functional guarantees
  • 7. “Microservices” is a vague term • multiple small apps with REST/HTTP interface, • multiple small apps with deferred message processing • multiple single-file apps with less than 100 lines of code • multiple small apps possibly written in different languages communicating with each other
  • 8. Microservices • small single-purpose apps with bounded domain enabling polyglot programming + add your favourite ingredients + differences from monolithic architecture © Marivlada | Dreamstime Stock Photos & Stock Free Images
  • 9. Microservices vs Monolithic architecture Deployment units Monolith Microservices
  • 10. Microservices vs Monolithic architecture Deployment strategy Monolith Microservices
  • 11. Microservices vs Monolithic architecture Coupling Monolith Microservices • global variables • messages • function calls • data structures • shared memory • multiple levels of indirection managed with • SOLID, encapsulation and other practices • dependency injection, etc. • different protocols • shared DB’s • shared message queues managed with • contracts
  • 12. Microservices vs Monolithic architecture Interfaces vs Contracts Monolith Microservices • written with code and shared interfaces within code packages and libraries • checked by tests or compilers (?) • type validations • api calls defined by the language • encapsulation, single-responsibility rule, etc. Problems: • meta-programming, monkey-patching, global state and workarounds. • spoken / unspoken • should be defined on “paper” • defined by protocols, and technologies used, like: • http, websockets, RPC, rabbitMQ, shared MongoDB or Redis, etc. ) Problems: • changing contract or having no contract requires changing multiple services. • multiple API versions without easy solution for validating consistency
  • 14. Small single purpose code • Low complexity • No code-level coupling with other modules • “this big” or one hundred lines of code • Easy to rewrite • Rewrite instead of refactor • Easy to spot inputs and outputs • Still requires readable logic
  • 15. Relevant metrics • Measuring business performance using relevant metrics • Visualisation • Ex. Kamon, custom charts Ex: • forms processed, • mails sent, • PDF invoices generated • performance metrics: • response times • queue sizes • ex. New Relic, etc.
  • 16. Continuous deployment with hot swapping Having all the metrics: • You can deploy continuously • You can test the service by deploying new and old versions concurrently. • Given enough fail-safety contracts, you can test in production • One service down shouldn’t break whole architecture
  • 19. Problems and Dilemmas • synchronous and asynchronous processing • guarantees and SLAs • shared and private databases • making layers of micro services • bare-metal vs platforms • data-driven systems, eventsourcing and real-time messaging
  • 20. Synchronous vs Asynchronous processing Synchronous processing • immediate responses • fast and hard failure • “asking” • request timeouts • problematic to debug series of request Ex. chain of HTTP request and getting 200 Success response Asynchronous processing • posting jobs to be processed • tell don’t ask • fire and forget • need of pooling or waiting for response • longer jobs • failures can be recovered from! Ex. uploading a video file to be processed and getting “Video uploaded successfuly” response.
  • 21. Guarantees and SLA’s Is clicking like button same as performing bank transfer? Do we really need full ACID DB for holding chat messages? Will it perform fast enough to serve thousand of clients concurrently without building whole cluster of DB’s? 100% consistency and synchronicity is not possible to achieve in distributed system without introducing system wide locks. System-wide locks affect performance a lot, while we try to achieve reactive and scalable system. In microservices we can keep different parts of system with different guarantees and different approaches
  • 22. Shared vs private databases Shared database • pretty strong contract • convenient for simple domain problems • easier to maintain • problems: • coupling too many services, too deeply. • can become performance bottle-neck Private databases • useful for decoupling and reuse • useful for performance • useful for embedding in microservices that abstract complicated domain models • difficult to maintain, although can many databases can work on single db cluster/instance. • useful for giving microservice authority over some data • problems: • data sharding
  • 23. Layers of micro services frontend, public facing micro services, background workers and services
  • 24. Layers of micro services frontend issues • CORS (Cross Origin Resource Sharing) • Rendering of HTML: server-side or in javascript • Moving caches to CDN • Keeping modularity and reusability also on the frontend side • One backend microservice failure shouldn’t break whole frontend.
  • 25. Layers of micro services user facing services issues • CORS • Versioning of API • Authentication • Caching • Loadbalancing • Security
  • 26. Layers of micro services internal services • Security • Scalability • Monitoring for failures • Keeping the data consistent • Garbage-in garbage-out
  • 27. Platform abstraction level bare-metal servers vs platforms Higher level framework = more difficult polyglot programming + easier maintenance + possible code sharing + more tight coupling opportunities
  • 28. Stateful databases vs eventsourcing Stateful databases • State stored in the database • Ex. “John has $3122 USD on his account” • Transactions and locks that enable us to mutate the state Eventsourcing • No state just events. • Ex. “John got spent $12 USD” • State is inferred from the past events… • Every situation can be replayed! • Events are immutable = no problem with locking, etc. We can also not care about keeping the data at all.
  • 29. … and other dilemmas. But…
  • 30. Why not mix all the approaches?
  • 31. Can sole database be a microservice?
  • 32. Must microservice be based on REST interfaces?
  • 33. How would you model microservices for the last system you developed?
  • 34. That’s it for the intro Thanks! jacek@theiterators.com
  • 35. Summary Microservices come in different flavours:! sync, async, rest, mq, databases, events, hard and easy guarantees, with private and shared databases, based on bare-metal machines and high level platforms. © Marivlada | Dreamstime Stock Photos & Stock Free Images
  • 36. Summary Spray is great foundation: for simple HTTP services for connecting with awesome Akka processing framework with great directives for strictly defining what requests get processed with great marshalling and serialisation who make simple easy and abstractable
  • 37. Summary Play is has some useful elements: ! nice routing DSL, nice controller with Action composing nice Websockets with Akka actors lots of libraries to integrate to big boilerplate
  • 38. Summary Akka is great for messaging, makes concurrent programming easy! ! Actors are not threads Messages and Questions with timeouts Scheduling Watch not to make bloated — keep it single purpose
  • 39. Summary Eventsourcing ! ! Don’t store mutable state Store immutable events Rebuild state by processing the past events Akka persistance stores the events for you in a journal of choice (Mongo, Redis, Postgres, Maria, Mysql)
  • 40. What haven’t we talked about ! JVM microframeworks — Finagle, etc. Frontend — how to keep modularity, where to generate HTML, how to handle caching. Monitoring — health checks and metrics (spray directives?) and monitoring front end DevOps — How to configure loadbalancers, CORS, handling configuration and discovery of microservices, prepare auto-scaling, and handling situations when services fail, or how to make hot swap deployments.
  • 41. Thanks! Łukasz Sowa @luksow lukasz@theiterators.com Jacek Głodek @jacekglodek jacek@theiterators.com