5. github.com/rjrodger/nodezoo
Pattern Matching
Service discovery is an anti-pattern.
Instead, make messages first-class citizens.
Use message data to define patterns,
and these patterns define a language!
Transport Independence
Services should not know about each other,
or how to send messages.
Services are fully defined by:
message patterns that they recognise, and
message patterns that they emit.
6. github.com/rjrodger/nodezoo
// a search message
{
"role": "search", // a namespace
"cmd": "search", // this is a command
"query": "ldap", // some data
}
!
// the pattern to match
role:search,cmd:search
7. github.com/rjrodger/nodezoo
// some nodezoo message patterns
!
role:search,cmd:search // do a search
role:search,cmd:insert // insert into index
role:info,cmd:get // get module info
role:npm,cmd:get // get npm data
role:npm,info:change // module changed!
role:info,req:part // need module info
role:info,res:part // here's module info
!
!
!
18. github.com/rjrodger/nodezoo
failure mode
"Upstream overload"
A is sending messages to B
at a higher rate than B can handle.
mitigation
Back-pressure from B.
A should accept back pressure
notifications and scale back.
Assumes B is doing more work than A.
20. github.com/rjrodger/nodezoo
failure mode
"Lost Actions"
A is sending messages to B,
and C is listening. But perhaps the
latest version of C is broken?
mitigation
Measure message flow rates.
Do the flow ratios match
the business rules?
23. github.com/rjrodger/nodezoo
failure mode
"Poison Message"
A is sending messages that crash B.
B keeps restarting and trying to handle
the poison message. Now nothing works!
mitigation
B should drop out of date messages
on the floor. B should maintain a list of
recently seen messages and ignore duplicates.
B sends bad messages to the "Dead Letter" log.
24. github.com/rjrodger/nodezoo
failure mode
"Guaranteed Delivery ... ain't"
B expects at-most-once, exactly-one,
or at-least-once delivery of
unique messages. This is not possible.
mitigation
Idempotency.
Where possible, duplicate messages
should have no bad effects.