"From Orchestration to Choreography and Back", Yevhen Bobrov

Fwdays
FwdaysFwdays
LetyShops
from orchestration to
choreography and back
10-year journey
@yevhen
OS
S
@yevhen
YouScan.io
• founded in Kyiv in 2009
• 500K+ online sources
• 500M posts daily
added semantics
ML
NL
P
CV
ML
Rules
OC
R
pipeline
agenda
• functionality
• structure
• patterns
• tools
• problems
high-performance pipeline
sync T = (S1 + S2 + … + Sn) * K
async T = (S1 + S2 + … + Sn) + (Slow * K)
distributed pipeline
choreography
features
high throughput
low latency
backpressure
control parallelism
batching
routing
"From Orchestration to Choreography and Back", Yevhen Bobrov
Apache NiFi
ingestion pipeline (2013)
o validate
o normalize
o detect sentiment
o detect language
…
TPL DataFlow
var fetch = new TransformBlock(async url =>
{
using (var web = new WebClient())
return (url, await
web.DownloadAsync(url));
});
var save = new ActionBlock(async data => {
(string url, byte[] image) = data;
await File.WriteAllBytesAsync(filePath,
image);
});
fetch.LinkTo(save); // links the output from the TransformBlock to
the ActionBlock
TPL DataFlow
• backpressure control
• low-latency, high throughput
• limit parallelism
• batching (DIY)
• composition & routing (basic)
evolution conundrum
extend
o validate
o normalize
o detect sentiment
o detect language
o match
o delay
o send to client
Microservices, anyone?
vs split
o validate
o normalize
o detect sentiment
o detect language
o match
o delay
o send to client
disintegration reasons
+ + +
+
service
functionality
code
volatility
scalability &
throughput
fault
tolerance
data
security
Architecture, The Hard Parts by Neal Ford
(https:www.youtube.com/@thoughtworks)
messaging patterns
Pipes and
Filters
Content
Enricher
Point-to-Point
Channel
Document
Message
[isFresh]
o match
o delay
o send to client
evolution
evolution
o extract
o highlight
o send to client
evolution
o detect objects
o detect OCR
o send to client
[hasImage]
o match keywords
o send to client
[noOCR]
evolution
micromess ©
[isFresh]
[lowPriority]
[noOCR]
[hasImage]
[hasImage]
o match
o delay
o send to client
o validate
o normalize
o detect sentiment
o detect language …
o extract
o highlight
o send to client
o match keywords
o send to client
o detect objects
o detect OCR
o send to client
diagram maintenance
problems
tracing is a pain
dependencies and
code duplication
full redeployment on
document schema changes
NEWCOMER
S
diagram maintenance
problems
tracing is a pain
dependencies and
code duplication
full redeployment on
document schema changes
Vanya
Ask Vanya!
WTH!
diagram maintenance
problems
tracing is a pain
dependencies and
code duplication
full redeployment on
document schema changes
diagram maintenance
problems
tracing is a pain
dependencies and
code duplication
full redeployment on
document schema changes
serialization rollercoaster
-> {json} ->
-> {json} ->
-> {json} ->
-> {json} ->
-> {json} ->
-> {json} ->
How dare you,
waste it all
this energy!
delusive autonomy
Clients do not tolerate partial data!
last nail
contextmess ©
-Illities
reintegration reasons
Architecture, The Hard Parts by Neal Ford
(https:www.youtube.com/@thoughtworks)
database
transactions
structural (data)
dependencies
workflow and
choreography
orchestration
distributed dataflow
[image == null]
indexer percolator image recognition
separation of concerns
flow
function
[image == null]
indexer percolator image recognition
orchestration patterns
Message
Router
Content-Based
Router
simple made easy
Orchestrator Service
Function Services
competing consumers
scalability
10 VMs
new problems
complexity distribution
o validate
o normalize
o detect sentiment
o detect language
…
o match
o delay
o send to client
o detect objects
o detect OCR
o send to client o match keywords
o send to client
o extract
o highlight
o send to client
big ball of …
o validate
o normalize
o detect sentiment
o detect language
…
o match
o delay
o send to client
o detect objects
o detect OCR
o send to client
o match keywords
o send to client
o extract
o highlight
o send to client
[isFresh
]
[hasImage
]
[noOCR
]
[highPriority]
[isFromChanne
l]
[hasText]
flow graph
ascii routes
straightforward pipeline?
Selective Consumer
Selective Consumer
[image == null]
[nsfw!]
[!nsfw]
[image]
[!filter -> next]
linear pipeline
[image != null] [nsfw!]
code
pipeline = new Pipeline<IngestionPipelineContext>(HandleError)
{
validate.LinkTo(CompleteWhen(x => x.Status ==
IndexingStatus.Invalid)),
enrich,
geo,
irCache.Filter(x => x.HasImage),
match,
delay,
nsfw.Filter(x => x.HasImage),
ocr,
… // 20+ stage declarations
complete
};
results
easy to:
• understand
• extend
• maintain
• operate
infrastructure
cost reduction
no documentation
overhead
-2000 LOC
conclusions
orchestration over
choreography within
single BC
maintainability
matters
you don’t need fancy
pipeline framework
When forming analogies, this bias
may lead individuals to selectively
focus on similarities between
two things while ignoring
differences, even if the analogy
is not valid.
Confirmation Bias
the end
we’re
hiring!
1 of 57

More Related Content

More from Fwdays(20)

"From Orchestration to Choreography and Back", Yevhen Bobrov