1
Beyond Microservices: Streams, State and Scalability
Gwen Shapira, Engineering Manager @gwenshap
Beyond Microservices: Streams, State and Scalability Gwen Shapira, - - PowerPoint PPT Presentation
1 Beyond Microservices: Streams, State and Scalability Gwen Shapira, Engineering Manager @gwenshap 2 In the beginning 3 We Have Microservices 3 4 We Microservices 4 5 They need to communicate 5 I know! Ill use REST APIs 6
1
Gwen Shapira, Engineering Manager @gwenshap
2
3
3
4
4
5
5
6
6
Orders Returns? Inventory Fulfill Order Validate Order
7
Synchronous request-response communication Leads to Tight point-to-point coupling
7
8
Orders Inventory Returns Validate Fulfill
9
9
Retry? Retry? Retry?
10
1
11
1 1
Mistake Handler
12
1 2
13 13
14
15 15
16
Orders Inventory Returns Validate Fulfill
17
Auth Auth Auth
18
Returns Inventory Orders API Gateway
19 19
analytics
20
21 21
22
23
24
26
Proxy Proxy Proxy Proxy Proxy
27
Proxy
I have a new IP
Who cares? I magically know all about it!
28
Proxy
I can recover from errors without drowning Error? No worries! Lets retry every millisecond forever
dropping 99%
29 29
30
3
31
3 1
Mistake Handler
32
Logic Logic Logic Logic
1. Tell others what to do (commands) 2. Ask questions (queries)
Logic Logic Logic Logic
Broadcast what I do Kafka Others work out what to do Queries use local cache
33
34
Service to tell it to ship item.
address to ship to (from Customer Service)
Submit Order shipOrder() getCustomer() Orders Service Shipping Service Customer Service Webserver
35
about the Shipping service (or any other service). Events are fire and forget.
Submit Order Order Created getCustomer()
REST Notification
Orders Service Shipping Service Customer Service Webserver
36
events, into the shipping service, where it is queried locally. .
Customer Updated Submit Order Order Created
Data is replicated
Orders Service Shipping Service Customer Service Webserver
37 37
They are all derived from same stream of events
projection just the data each service needs.
dependencies
38
39
40 40
41
Logic Logic Logic Logic
1. Tell others what to do (commands) 2. Ask questions (queries)
Logic Logic Logic Logic
Broadcast what I do Kafka Others work out what to do Queries use local cache
42
43 43
{ sessionId: 676fc8983gu563, timestamp: 1413215458, viewType: "propertyView", propertyId: 7879, loyaltyId: 6764532
...... lots of metadata.... }
44
4 4
45
4 5
46
There are lots of dependencies
Booking service {user_id: 53, timestamp: 1497842472} create table ( use_id number, timestamp number) new Date(timestamp) Attribution service
47
Booking service {user_id: 53, timestamp: “June 28, 2017 4:00pm”} create table ( use_id number, timestamp number) new Date(timestamp) Attribution service
48
Booking service {user_id: 53, timestamp: “June 28, 2017 4:00pm”} create table ( use_id number, timestamp number) new Date(timestamp) Attribution service
49
APIs between services are Contracts In Event Driven World – Event Schemas ARE the API
50
51
Dev Nightly build / merge Prod Test Registry Prod Registry Test MVN Plugin
52 52
53
Event
< / >
Response
VM Function Instance
< / >
Launch
54
Event
< / >
Response
VM Function Instance
< / >
Launch
55
Event
< / >
Response
VM Function Instance
< / >
Launch
VM Function Instance
< / >
VM Function Instance
< / >
VM Function Instance
< / >
56
Consume Event Produce
Container Function Instance
< / >
Kafka Partitions Container Order Service!
< / >
57 57
58
59
Create Order
< / >
Order Created
VM Function Instance
< / >
Launch
Cloud Data Store
select from inventory … insert into Orders…
60
Select order_id, customer_name, product, quantity, price, state from
where state != “CLOSED”
< / > VM Function Instance < / > Cloud Data Store What’s the latest with my order? Maybe check DB? Order is processing Not shipped yet.
61
62
VM Create Order < / > Order Status < / > Validate Order < / > Inventory, Rules
64
everywhere
from data stores to functions
current state
65
66
stopford-confluent-kafka-summit-sf-2019