6. What are the trade-offs?
๏ Deployment is more complex;
๏ Weird programming model;
๏ Services have to find each other;
7.
8.
9.
10. Configuration Files
๏ Hard code all the locations;
๏ Automate update and reloads;
๏ Surprisingly workable;
๏ But gets messy fast!
11. Intelligent Load Balancing
๏ The load balancer knows where services are;
๏ Services have to register in some way;
๏ Load balancers are yet more things to manage;
๏ URL paths are still identifiers!
๏ Examples: Netflix Eureka, nginx, HAProxy
12. Service Registries
๏ Services lookup locations;
๏ Registries can provide health checks;
๏ Registries themselves need to be distributed;
๏ Service A still knows about Service B!
๏ Examples: consul, etcd, zookeeper
13. DNS
๏ Hide services behind domain names;
๏ We know DNS can scale;
๏ More management work;
๏ Service A still knows about Service B!
๏ Examples: Mesos, Weave, SkyDNS
14. Message Bus
๏ Hide services behind topic names;
๏ Nice for publish/subscribe models!
๏ You have to manage the bus;
๏ Rapids, rivers and pools;
๏ Topics are weak identifiers - better!
๏ Examples: Kafka, Rabbitmq, Redis
15.
16. 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.
17. Blind Messages
๏ Services have zero-knowledge of other services;
๏ Services emit messages into the world;
๏ Services let the world know what they care about;
๏ The underlying infrastructure handles identity;
๏ Works with any of the service discovery methods!
18. Peer-to-peer
๏ Knowledge of identity can be distributed;
๏ Each service maintains a local view of world,
and updates this view as services come and go;
๏ Mapping from message to destination is not
exposed to developers.
19. SWIM
๏ "Scalable Weakly-consistent Infection-style
Process Group Membership Protocol"
๏ https://www.cs.cornell.edu/~asdas/research/dsn02-swim.pdf
๏ Designed for large scale (used by Uber);
๏ Basic idea:
๏ each service pings a random subset of other
services, different each time
๏ the pings establish health and disseminate
membership information
20.
21.
22.
23. // 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
24. // 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
!
!
!