Service discovery is an anti-pattern.
Instead, make messages ﬁrst-class citizens.
Use message data to deﬁne patterns,
and these patterns deﬁne a language!
Services should not know about each other,
or how to send messages.
Services are fully deﬁned by:
message patterns that they recognise, and
message patterns that they emit.
// a search message
"role": "search", // a namespace
"cmd": "search", // this is a command
"query": "ldap", // some data
// the pattern to match
// 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
B responses are getting slower,
consuming As resources.
A should consider B dead.
Or: the transport should handle this.
A is sending messages to B
at a higher rate than B can handle.
Back-pressure from B.
A should accept back pressure
notiﬁcations and scale back.
Assumes B is doing more work than A.
A is sending messages to B,
and C is listening. But perhaps the
latest version of C is broken?
Measure message ﬂow rates.
Do the ﬂow ratios match
the business rules?
A and B are using a newer
but you forgot about C.
Don't use contracts!
Message schemas are a
net negative and hinder
A is sending messages that crash B.
B keeps restarting and trying to handle
the poison message. Now nothing works!
B should drop out of date messages
on the ﬂoor. B should maintain a list of
recently seen messages and ignore duplicates.
B sends bad messages to the "Dead Letter" log.
"Guaranteed Delivery ... ain't"
B expects at-most-once, exactly-one,
or at-least-once delivery of
unique messages. This is not possible.
Where possible, duplicate messages
should have no bad effects.
Strange loops and unexplained
message paths make it hard to understand
what the system is doing.
Attach correlation identiﬁers to messages
so that you can trace the ﬂow of causality.
You've introduced feedback
that grows exponentially.
And you've no idea how to ﬁx it.
Have a kill switch.
Microservices aren't a
silver bullet. Sometimes you
need to selectively reboot.