Service Discovery; or, Why each microservice should believe it's the only one in the world - by...
-
Upload
nearform -
Category
Technology
-
view
4.969 -
download
1
Transcript of Service Discovery; or, Why each microservice should believe it's the only one in the world - by...
![Page 1: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/1.jpg)
Service Discovery or
Why each microservice should believe it's the only one in the world.
Richard Rodger @rjrodger
![Page 2: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/2.jpg)
![Page 3: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/3.jpg)
![Page 4: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/4.jpg)
What are microservices?
๏ Small independent processes; ๏ Communicating via messages; ๏ A powerful component model.
![Page 5: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/5.jpg)
Why use microservices?
๏ Avoid technical debt; ๏ Get continuous delivery; ๏ Build fast.
![Page 6: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/6.jpg)
What are the trade-offs?
๏ Deployment is more complex; ๏ Weird programming model; ๏ Services have to find each other;
![Page 7: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/7.jpg)
![Page 8: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/8.jpg)
![Page 9: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/9.jpg)
![Page 10: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/10.jpg)
Configuration Files
๏ Hard code all the locations; ๏ Automate update and reloads; ๏ Surprisingly workable; ๏ But gets messy fast!
![Page 11: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/11.jpg)
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
![Page 12: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/12.jpg)
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
![Page 13: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/13.jpg)
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
![Page 14: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/14.jpg)
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
![Page 15: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/15.jpg)
![Page 16: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/16.jpg)
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.
![Page 17: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/17.jpg)
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!
![Page 18: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/18.jpg)
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.
![Page 19: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/19.jpg)
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
![Page 20: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/20.jpg)
![Page 21: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/21.jpg)
![Page 22: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/22.jpg)
![Page 23: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/23.jpg)
// 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
![Page 24: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/24.jpg)
// 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 !!!
![Page 25: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/25.jpg)
role:search,cmd:search
role:info,cmd:get
synchronous request/response
![Page 26: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/26.jpg)
role:npm,info:change
asynchronous "winner-take-all" (actor)
![Page 27: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/27.jpg)
role:info,req:part
asynchronous "fire-and-forget" (publish/subscribe)
role:info,res:part
![Page 28: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/28.jpg)
asynchronous "fire-and-forget" (publish/subscribe)
synchronous request/response
asynchronous "winner-take-all" (actor)
synchronous "sidewinder" (side effects!)
synchronous/ asynchronous
consumed/ observed
![Page 29: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/29.jpg)
// nodezoo-web IN: none OUT: role:search,cmd:search // sync role:info,cmd:get // sync
// nodezoo-search IN: role:search,cmd:search // sync role:search,cmd:insert // async OUT: none
service specification
![Page 30: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/30.jpg)
// nodezoo-info IN: role:info,cmd:get // sync role:info,res:part // async OUT: role:info,req:part // async
// nodezoo-npm IN: role:npm,cmd:get // sync role:npm,info:change // async role:info,req:part // async OUT: role:info,res:part // async
service specification
![Page 31: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/31.jpg)
// role:search,cmd:search consumed: nodezoo-web -> nodezoo-search
// role:info,cmd:get consumed: nodezoo-web -> nodezoo-info
// role:npm,info:change observed: nodezoo-update -> nodezoo-npm
service interactions
![Page 32: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/32.jpg)
// role:info,req:part observed: nodezoo-info -> nodezoo-npm nodezoo-info -> nodezoo-github
// role:info,res:part observed: nodezoo-npm -> nodezoo-info nodezoo-github -> nodezoo-info
service interactions
![Page 33: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/33.jpg)
senecajs.org
![Page 34: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/34.jpg)
Code! github.com/rjrodger/nodezoo
![Page 35: Service Discovery; or, Why each microservice should believe it's the only one in the world - by Richard Rodger](https://reader031.fdocuments.in/reader031/viewer/2022020411/586f77401a28ab10258b6735/html5/thumbnails/35.jpg)
Thanks!Richard Rodger
@rjrodger richardrodger.com
senecajs.org github.com/apparatus/fuge