2. 2015 - David Bolene
TOC
Architecture for Cloud Services
SOA on Akka
2
4
24
Demo 35
What is (was) SOA? 20
Why Akka? 7
3. 2015 - David Bolene
TOC
Architecture for Cloud Services
SOA on Akka
3
4
24
Demo 35
What is (was) SOA? 20
Why Akka? 7
4. 2015 - David Bolene
Architecture Motivators for Cloud Services
- Elastic / Scalable
- Modular
- Simple
- Low Latency
- Service Integratable
- Resilient
- High Throughput
4
5. 2015 - David Bolene
Architecture Anti-Patterns for Cloud Services
- Transaction Locking in the Database
- Locked/Synchronized Mutable Objects
- Database Joins
- Thread Blocking Method Calls
- Thread Blocking Service Calls
5
6. 2015 - David Bolene
TOC
Architecture for Cloud Services
SOA on Akka
6
4
24
Demo 35
What is (was) SOA? 20
Why Akka? 7
7. 2015 - David Bolene
Akka Actors
Inbox
Message
Actor or
Future
Async
Send
Enqueue
Actor
“one at a time”Dispatcher
Threads
Cores
7
How They Work
8. 2015 - David Bolene
Akka
Actor
Actor
Actor
Supervises
Actor
Actor
Actor
Exception
Actor
Actor
Actor
re-start
Self Healing
8
9. 2015 - David Bolene
Akka Akka Persistence
Actor
Journal
Store
(e.g. Cassandra)
Snapshot
Store
(e.g. Cassandra)
Event
Event
Event
snapshotIncremental Periodic
async
writes
Message
Actor Durability - An Event Sourced Approach
9
10. 2015 - David Bolene
Akka Akka Persistence
Actor
Event
Event
Event
snapshot
Actor State Recovery
latest replay
1 2
Journal
Store
(e.g.
Cassandra)
Snapshot
Store
(e.g.
Cassandra)
10
then
Disk
Sequential
Scans
Message
11. 2015 - David Bolene
REST
based on Akka
Socket
Handler
ActorTCP
Packets
socket
REST
Route
Handler
Actor
HTTP
Requests
11
Spray / Akka HTTP
12. 2015 - David Bolene
Spray / Akka HTTP
REST
based on Akka
Socket
Handler
ActorTCP
Packets
socket
REST
Route
Handler
Actor
HTTP
Requests
Business
Domain
ActorMessage
Context
Continuation
12
13. 2015 - David Bolene
Spray / Akka HTTP
REST
based on Akka
Socket
Handler
ActorTCP
Packets
socket
REST
Route
Handler
Actor
HTTP
Requests
Business
Domain
ActorMessage
Context
Continuation
Socket
Handler
ActorTCP
Packets
socket
HTTP
Response
Context
Business
Domain
ActorMessage
time
13
14. 2015 - David Bolene
Async from Top
to Bottom
Domain
Actors
Cassandra
Akka.IO
HTTP Toolkit
Socket
Packets
Spray
REST Toolkit
HTTP
Commands /
Events
Turtles All the Way Down
Async Writes
14
15. 2015 - David Bolene 15
Async from
Front to Back
Domain
Actors
Akka.IO
HTTP Toolkit
Socket
Spray
REST Toolkit
Turtles All the Way Through
Socket
Spray
Client
Akka.IO
HTTP Toolkit
Frontend (REST Client Calls)
Backend (External Service Calls)
16. 2015 - David Bolene
Akka Clustering
Actor
Hosting
Cluster
Node
Actor
Hosting
Cluster
Node
Actor
Hosting
Cluster
Node
Actor
Hosting
Cluster
Node
Actor
Hosting
Cluster
Node
Actor
Hosting
Cluster
Node
Scaling Actors…
Message
Akka
16
Akka Protocol
17. 2015 - David Bolene
Akka
FrontEnd
(Spray)
Virtualizing Actor Placement
Backend
Node
Backend
Node
Backend
Node
Cluster Sharding
Akka Cluster Sharding
Message
Shard Proxy
(e.g.)
Cassandra
Re-hydrate
on Demand
Passivate
on Inactivity
Message
17
18. 2015 - David Bolene
Akka Look Ma! No Transactions
Shopping
Cart
Actor
Cassandra
18
Live state is here
NOT here
19. 2015 - David Bolene
TOC
Architecture for Cloud Services
SOA on Akka
19
4
24
Demo 35
What is (was) SOA? 20
Why Akka? 7
20. 2015 - David Bolene
Akka What is (was) SOA
20
(fat)
Web
Services
Web
Service
Web
Service
Web
Service
Web
Service
Web
Service
XML / JSON XML / JSON XML / JSON XML / JSON XML / JSON
21. 2015 - David Bolene
Akka What is (was) SOA
21
Process
Orchestration
(e.g. BPEL)
Receive
Order
Request
Credit
Score
Receive
Credit
Score
Send
Order
Status
Credit Service
Customer Order Placement Process
Seller Order Capture Process
Customer
Order
Order
Status
Credit
Request
Credit
Response
22. 2015 - David Bolene
Akka What is (was) SOA
22
Choreography
Choreography
Contract
Buyer Seller
RFQ
RFI
Clarification
Decline
Quote
P.O.
DecisionStatusRequest
DecisionStatus
Negotiation
Channel
PostNegotiation
Channel
valid-until
-dateTime
expired
Acceptance
Channel
LossNotification
23. 2015 - David Bolene
TOC
Architecture for Cloud Services
SOA on Akka
23
4
24
Demo 35
What is (was) SOA? 20
Why Akka? 7
24. 2015 - David Bolene
Akka What is a Service in Akka?
24
Web
Service
XML / JSON
Micro
service
Actor
JSON
26. 2015 - David Bolene
Akka Akka Cluster Service Architecture
FrontEnd
(Spray)
Backend
Orchestration
Actors
FrontEnd
(Spray)
Backend
Orchestration
Actors
FrontEnd
(Spray)
Backend
Orchestration
Actors
Load
Balancer
Microservice
Actors
1,2
Microservice
Actors
3,4,5…
Cluster Sharding
(e.g. Fulfillment Process)
Can be dynamically added/removed
for scale
Can be scaled horizontally
with Akka Actor Routers
1
26
27. 2015 - David Bolene and Comcast
Akka Service Registry for Akka
Discovery and Dependency Resolution of Service Actors…
A
B
C
D
E
Service
Registry
for
Akka
Microservice
Actors
1
2
3
Subscribe
to E Publish
E
Deliver
E
Microservice
Actors
Microservice
Actors
4
Publish
A
27
Actor Service Registry for Akka
is a Comcast artifact
soon to be open sourced
28. 2015 - David Bolene and Comcast
Akka Service Registry for Akka
Cluster-Wide Circuit Breaker Coordinator for Service Actors…
A
B
C
Service
Registry
for
Akka
Microservice
Actors
3
1
2
UnPublish
A Death
Watch
E
E
Unavailable
Microservice
Actors
Microservice
Actors
E
D
28
Actor Service Registry for Akka
is a Comcast artifact
soon to be open sourced
29. 2015 - David Bolene
Akka Microservice Actors
FSM Circuit Breaker
29
B
Offline Online
B [available]
B [unavailable]
A
depends
on
Overseer
supervises
30. 2015 - David Bolene
Akka Akka Clustering
Docker
Container
Docker
Container
Perfect with Docker
RUN java -jar FrontEnd.jar 2551
RUN java -jar BackEnd.jar 2552
30
32. 2015 - David Bolene and Comcast
Akka Service Registry for Akka
Provides Microservice Dependency Recovery/Resiliency
A
B
C
D
E
Service
Registry
for
Akka
Microservice
Actors
1
2
3
Subscribe
to E Publish
E
Deliver
E
Microservice
Actors
Microservice
Actors
4
Publish
A
32
33. 2015 - David Bolene
Akka
Actor
Actor
Actor
Supervises
Actor
Actor
Actor
Exception
Actor
Actor
Actor
re-start
Akka systems
are
fault-tolerant
(self-healing)
33
34. 2015 - David Bolene
TOC
Architecture for Cloud Services
SOA on Akka
34
4
24
Demo 35
What is (was) SOA? 20
Why Akka? 7
35. 2015 - David Bolene 35
Bob Wilson’s Garage
We repair your car
(if our staff showed up today)
and
we detail it for free!
36. 2015 - David Bolene 36
FrontEnd
(Spray)
Client
Backend
Orchestration
Actors
Backend
Orchestration
Actors
Staffing
Microservice
Car Detailing
Microservice
Sharded Order Fulfillment Processes
Cassandra
Cassandra
Cassandra
Car Repair
Microservice
Service
Registry
for Akka
Bob Wilson’s Garage
Cluster
Depends On
Depends On
37. 2015 - David Bolene 37
Initial
State
Car
Repairing
State
Car
Detailing
State
Finished
Service
Unavailable
BobWilsonsGarage
ServiceRequest
Car Repair Microservice Car Detailing Microservice
Staffing Microservice
BobWilsonsGarage
ServiceResponse
REST Client
Car
Service
Request
Car
Service
Response
Staffing
Request
Staffing
Request
Staffing
Response
Staffing
Response
Car
Detail
Request
Car
Detail
Response
Fulfillment Process
Bob Wilson’s
Garage
in
BPMN
[Car Repair & Car Detailing Offline]
[Car Detailing Offline]
POST GET
39. 2015 - David Bolene
Cassandra
Why Cassandra
Cassandra
Node
Cassandra
Node
Cassandra
Node
Cassandra
Node
Cassandra
Node
eventually
consistent
replication
eventually
consistent
replication
Akka Actor-based
in-memory state approach
allows for use of eventually
consistent NoSQL
persistence.
39
Cassandra is the
best write-optimized
scalable and
production maintainable
NoSQL system
on the market
(fits Akka perfectly).
42. 2015 - David Bolene
Materialized Views
How to Use Cassandra
42
Actor
Journal
Store
Snapshot
Store
Event
Event
Event
snapshot
Fulfillment
(Actor)
State
Property
2
Mutate
Party
(Actor)
Fulfillment
(Actor)
Property
1
Property
2
Materialized View - Party Vs Fulfillment Materialized View - Party Vs FuflillmentState
Designed
for sequential scans
Designed
for sequential scans
Side-EffectSide-Effect
Party
(Actor)