Forget about HTTP Requests
Irina Scurtu
Irina Scurtu
▪ Romania Based
▪ Software Architect @Endava
▪ Organizer of DotNet Iasi user group
▪ I teach .Net
@irina_scurtu
Agenda
▪ Monoliths& Microservices
▪ HTTP calls – sync & async
▪ RPC
▪ Messaging
▪ Queues
▪ Message Brokers
▪ Actor Model
MONOLITH
MONOLITH
▪ Self-contained
▪ Single codebase
▪ Single deploy unit
▪ Easy life for developers
▪ Dependencies are in your code
▪ Single technology stack
MONOLITH
▪ All or nothing deploys
▪ Downtimes
▪ Long build times
▪ ~ 0 continuous delivery
▪ Hard to test
Scaling the MONOLITH
Scale up
2
1 5
3
monolith syndrome?
MICROSERVICE
▪ it’s that thing that is not a monolith
▪ With it’s own database
▪ Easy to deploy
▪ Standalone
▪ Easy to maintain
Is it?
MICROSERVICES?
▪ Introduces complexity
▪ Cascading effects in case of failure
▪ Need to monitor them closely
2
1 5
3
Independent
units
2
1 5
3
Do you know?
▪ Amazon calls 150 APIs to Build a Page
▪ Netflix services about 5 billions API calls/day
▪ 99.7% are internal
HTTP API CALLS
HTTP CALLS
S
Response
H
HTTP CALLS
S H
HTTP CALLS
“It’s perfectly
fine to use sync
HTTP Calls”
▪ Timeouts
▪ Availability
▪ Going back to
coupling?
▪ You can loose
requests
▪ Retries?
“It’s perfectly fine to use async HTTP Calls”
▪You’ll have exactly the same issues as with sync calls
▪Distribute load?!
▪You can serve more request
▪You can serve the requests faster
HTTP General Notes
▪ Sync by nature
▪ Make a TCP connection for each request
▪ No retry out of the box
▪ No delivery guarantees
▪ Location transparency
▪ Good for public facing APIs
▪ Familiar
▪ Easy to debug
Challenges
▪Service Discovery
▪Retry policies
▪Circuit breakers
▪Timeouts
▪Routing
▪Tracing
RPC
RPC
▪ A kind of API call
▪Done through a message broker
▪ Ties systems together but preserves their
encapsulations
RPC
S H
Queues
Request
RPC
S
Queues
Response
Request
H
Gain vs Loss
▪You don’t lose the requests
▪You can add more handler instances
▪You can ‘apparently’ spread the load
▪You can process more requests
▪ Need to match the request
to the response
▪ You wait for a response =>
sync
Messaging
Body
Header
Messaging
▪Gives you loosely coupled integration
▪Doesn’t require both systems to be up
▪Messages ca be transformed in transit - Enrichers
▪Messaging systems trade consistency for availability
▪You don’t lose messages
▪Involves a Producer and a consumer
Messaging
ASYNC Queue Processing
S H
Queues
RequestRequest
Queue
S
Queues
Response
Request
Request
Request
H
Queue
Response
Response
With a DB
S
Queues
Response
Request
Request
Request
H
Storage
With a DB
s
Queues
Response
Request
Request
Request
H
Storage
Gains
• Is a reaction to the problems
of distributed sys
• Process more requests
• Process request faster
• Don’t lose requests
▪ You move the potential
issues to another
subsystem (DB in our case)
▪ Eventual consistency
remains a problem
Loss
Gain vs Loss
▪ Connection is scarce
▪ Batch process the message
▪ Use a semaphore to process them in batches
WHY USE a messaging system with MSA ?
Agility
▪Faster development
▪No integration process
▪Teams have ownership and full understanding of the codebase
▪You can switch technologies if needed
Scalability
Scale up
Scale out
Increased Throughput
38 267 vs 3500
ElasticityScale down to
reduce costs
A lot of ‘ilities’
▪Reliability
▪Flexibility
▪Distribution
▪Increased Throughput
▪Scalability
▪Elasticity
▪Performance
▪Agility
▪Fault Tolerance
Tools/Frameworks/Systems
Data Types
Queues
Actor Model
Message Brokers
What options do I have?
plenty
Many more
Queues
▪Useful for point to point communication
▪Messages are ordered and timestamped
▪Pull-mode
Actor model
▪Born from Reactive Programming
▪Actors are processes that encapsulate behavior
▪Actors are more than message consumers
▪Can delegate and create new actors
▪Can supervise children
▪At most once delivery
Reactive Manifesto
Message Driven
ResilientElastic
Responsive
Async message
Loose coupling
Location transparency
Scalable
React to workload
changes
Failures are self contained
Recovery
Isolation
Message Brokers
Message Brokers
▪One process sends a message to a named queue or topic
▪One or many consumers
▪Handles connections and disconnections very well
▪Dead-letter queue concept
▪Message Guarantees ( 3 types)
Message Brokers
▪Lightweight
▪Queues are FIFO
▪Supports AMPQ protocol
▪Easy to use, fast
▪At-least-once delivery
AMPQ General Notes
▪ Async by nature
▪ Guaranteed message delivery
▪ At-least once, exactly once, at most once delivery
▪ No DNS resolve
▪ Programmatic routing
▪ Retries out-of-the box
▪ Ack, Nack out of the box
▪ Concept of “channel”
Topic Exchange
References
In Summary
Messages
are great!
Messages are great
show them some
THANK YOU
@irina_scurtu
Q&A

Devit - forget about http requests