Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try...
Transcript of Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try...
![Page 1: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/1.jpg)
Microservices Lessons Learned From a
Startup Perspective
Susanne Kaiser@suksr
CTO at Just Software@JustSocialApps
![Page 2: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/2.jpg)
Each journey is different
“People try to copy Netflix, but they can only copy what they see. They copy the results, not the process.”
Adrian Cockcroft, AWS VP Cloud Archtitect, former Netflix Chief Cloud Architect
![Page 3: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/3.jpg)
Affecting Circumstances
Team● Size● Skillset● Structure
Legacy-System● Maintenance effort ● Environment
Strategy● New Features● Timeline/Milestones
![Page 4: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/4.jpg)
Background
JUST PAGESocial Network
JUST CONNECTReal-time collaboration
JUST DRIVEDocument Sharing
JUST TASKSTask Management
JUST PEOPLEUser Management
![Page 5: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/5.jpg)
Background
One team
One collaboration product
One technologystack
Single Unit
At The Beginning … A Monolith In Every Aspect
![Page 6: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/6.jpg)
Productivity suffered
Usability and UX suffered
New features released slowly
Background
After An Evolving Time ...
![Page 7: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/7.jpg)
Background
JUST PAGESocial Network
JUST CONNECTReal-time collaboration
JUST DRIVEDocument Sharing
JUST TASKSTask Management
JUST PEOPLEUser Management
Separate Collaboration Apps
![Page 8: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/8.jpg)
Background
JUST PAGESocial Network
JUST CONNECTReal-time collaboration
JUST DRIVEDocument Sharing
JUST TASKSTask Management
Small, Autonomous Teams
JUST PEOPLEUser Management
With well-defined responsibilities
![Page 9: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/9.jpg)
Background
Product Organization Software architecture
In The Long Run ...
![Page 10: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/10.jpg)
Straightforward Process?
Start End
![Page 11: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/11.jpg)
No Straightforward Process!
Start
Theory Reality
Start End
![Page 12: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/12.jpg)
First Approach As Co-Existing Service
JUST DRIVE
JUST DRIVE
JUST LIST
JUST CONNECT
JUST PAGE
DB Adapter
REST API
Web App
DB Adapter
MessageBroker
Messa
ge Br
oker
Adap
ter
Message Broker
Adapter
![Page 13: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/13.jpg)
Lesson #1: Too Many Steps At Once Slow You Down
More features
New UI
New data structure
Maintain & runcurrent system
Timelines
![Page 14: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/14.jpg)
Start With One Manageable Step At A Time
Easy to extract Changing frequently
Different resource requirements Split in steps, e.g.
top/down
![Page 15: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/15.jpg)
Lesson #2: Deferring Solving Authz Handling Hurts
I have a new service that needs authorization. Where isthe authz service I could use?
Not there, yet. Sorry!
Ok, than I am putting my codeto the place where authz handling exists … to the monolith.
Feeding the monolith
I have a new service that needs authorization. Where isthe authz service I could use?
Not there, yet. Sorry!
Ok, than I am implementing authzin my local service.
Re-implementing authz w/ every service
![Page 16: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/16.jpg)
Lesson #2: Deferring Solving Authz Handling Hurts
Solve Authz Handling Early!
![Page 17: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/17.jpg)
Lesson #3: Less Aligned Strategy Is Expensive
Separate Apps Separate Teams Separate Services Bundled Deployment
![Page 18: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/18.jpg)
Lesson #4: Data Related Overhead
Setup Maintain SetupSetup Maintain
Keep in sync
![Page 19: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/19.jpg)
Lesson #4: Data Related Overhead
Streams
![Page 20: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/20.jpg)
How To Interact Between Services?
Request-Driven Event-Driven
command
query
produceconsume
Event-Stream
Hybrid
produceconsume
command/query
Event-Stream
![Page 21: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/21.jpg)
How To Manage Data?
ProfileService
DocumentService
TaskService
Hybrid Model
REST
getProfile(ProfileId)Remote query directly to source
Event stream purely for notifications
![Page 22: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/22.jpg)
How To Manage Data?
ProfileService
DocumentService
TaskService
Event-Driven State Transfer
ProfileUpdatedEvent
Local copy/cache
![Page 23: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/23.jpg)
How To Manage Data?Source Of Truth
Database
Events
“Traditional” Event-Driven System
![Page 24: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/24.jpg)
How To Manage Data?Multiple Sources Of Truth
Database
Events
Internal source of truth
External source of truth
Dual writes
“Traditional” Event-Driven System
![Page 25: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/25.jpg)
How To Manage Data?Multiple Sources Of Truth
Database
Events
Internal source of truth
External source of truth
Dual writes
“Traditional” Event-Driven System Event Sourcing
Derive state from events
Event-Store
Single Source Of Truth
Events as first-class entities
![Page 26: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/26.jpg)
Apache Kafka
P0 P1 P2 P30123
012
0123
0123
Consumer
Topic
Consumer Consumer Consumer Consumer
Consumer Group Consumer Group
Producer
Each partition is assigned to one consumer within
a consumer group
Immutable, ordered sequence of records per partition
Each consumer controlsits position per partition(offset)
writes
readsEach consumer subscribes
to a topic
Consumer
![Page 27: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/27.jpg)
Apache Kafka
P0 P1 P2 P30123
012
0123
0123
Consumer
Topic
Consumer Consumer Consumer Consumer
Consumer Group Consumer Group
Producerwrites
reads
Scalable
Fault-tolerant
Node/Broker
● Data stored to disk● Replicated partitions● Consumer conrols its offset
● Topic can be scaled outto several nodes
● Messages load-balancedbetween consumer of one group
● Add partitions for more parallelism● Adding capacity with 0 downtime
Fast ● O(1) to append messages● LinkedIn 2016:
1.4 trillion messages/day across over 1400 brokers
Consumer
![Page 28: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/28.jpg)
Apache Kafka Combines ...
Messaging System Storage System Streaming Platform
![Page 29: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/29.jpg)
Primary Use Cases Of Streaming Platforms
Stream Processing Data Integration
Source
Sink
![Page 30: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/30.jpg)
Kafka Streams
Topic
Unbounded, ordered sequence
Key/value-pairContinuouslyupdating
![Page 31: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/31.jpg)
Kafka Streams
Topic Service
State Store (disk backed)
Running in the process of Microservice
Loads topic on startup
Streams can be:● Joined● Filtered● Grouped● Aggregated ● etc.Streams make data available wherever it’s needed
![Page 32: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/32.jpg)
Kafka Streams For Materialized Views
Document Topic
Profile Topic
Document Service
API
Table for enrichment
Stream
Matererialized View as State Store
Stream-Table-Join
![Page 33: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/33.jpg)
Low Barrier To Entry For New Service
● No separate data storage to set up● No extra local copies / caches to set up and to keep in sync● No remote calls● Materialized View always up to date● Scalable, fault-tolerant, fast
=> reducing overhead, increasing performance & autonomy
![Page 34: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/34.jpg)
If We Could Start The Journey Again ...
● Start with one manageable step at a time● Take care of Authorization handling early● Align strategy w/ Microservices goals● Using Kafka Streams for Materialized Views
![Page 35: Microservices Lessons Learned From a Startup Perspective · Each journey is different “People try to copy Netflix, but they can only copy what they see. They copy the results, not](https://reader034.fdocuments.us/reader034/viewer/2022051800/5abfc9257f8b9ac6688b5372/html5/thumbnails/35.jpg)
THANK YOU!Susanne Kaiser
@suksr
CTO at Just Software@JustSocialApps