Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Service Discovery Primer / µCon 2016

Alex Ramírez
November 08, 2016

A Service Discovery Primer / µCon 2016

The monolith applications world got us used to services connected to each other in direct, easy ways. The cloud environments and the modern and current microservices architectures with virtual or containerized setups where the instances can vary in number and location, create an ever-changing context where the communication between services becomes a bit more complicated.

We explore some of the different patterns of Service Discovery in a microservices architecture, and focus on pros and cons, while also mentioning concrete examples of tools and software available.

Alex Ramírez

November 08, 2016
Tweet

Other Decks in Technology

Transcript

  1. @alexramirez #mucon #servicediscovery A SERVICE DISCOVERY PRIMER ABOUT ME •

    Alex Ramírez • alexramirez.com • Barcelona (born in Mexico City). • Working with ‘online stuff’ since 1994. • µServices (and SOA/EDA) evangelism, coding, designing, training & consulPng. • This is my 2nd µCon.
  2. @alexramirez #mucon #servicediscovery A SERVICE DISCOVERY PRIMER TOC • Where

    are we? • Service Discovery? • Service Discovery paUerns • Service RegistraPon • QuesPons/Comments
  3. @alexramirez #mucon #servicediscovery HOW CAN A CLIENT DETERMINE THE INFORMATION

    (I.E. ADDRESS & PORT) OF A SERVICE IT WANTS TO CONNECT TO? Someone implementing µServices THE PROBLEM TO SOLVE
  4. @alexramirez #mucon #servicediscovery SERVICE …DISCOVERY? SERVICE DISCOVERY 101 • Service

    Discovery: The way for a client to find about the informaPon (i.e. address:port) of a service that it will connect to. • TradiPonal applicaPons (physical hardware) & configuraPon files. • Cloud environments and architectures are different. • Understand the principles. • What happens with a service found on mulPple hosts?
  5. @alexramirez #mucon #servicediscovery HOW CAN A CLIENT DETERMINE THE INFORMATION

    OF A SERVICE THAT EXISTS IN MULTIPLE HOSTS
 …THAT CHANGE DYNAMICALLY? Someone implementing µServices THE PROBLEM GETS A BIT MORE COMPLICATED
  6. @alexramirez #mucon #servicediscovery THE CLOUD MAKES ALL EASIER. RIGHT? CLOUDY

    WEATHER • StaPc configuraPon? • Live system. Deploying services. Service instances. • Service network locaPons change o\en: scaling, upgrades, hosts fail/get replaced. • Service interrupPon is not a possibility. • Dynamic service registraPon and discovery.
  7. @alexramirez #mucon #servicediscovery CONTAINERS IMPLY EVEN MORE THINGS TO CONSIDER

    CONTAINERS • MulPple containers in a single host. • Networking with containers means more “fun”. • Several instances in different containers in a same host. • OrchestraPon
  8. @alexramirez #mucon #servicediscovery SERVICE DISCOVERY TWO MAIN THINGS TO SOLVE

    • Service RegistraTon • Service registering its informaPon in a central registry. • Host & port (somePmes auth credenPals, protocols, version and/or environment info). • Service Discovery • Client applicaPon querying a registry to get info about the services and locaPon.
  9. @alexramirez #mucon #servicediscovery DISCOVERY PATTERNS PRO ET CONTRA: CLIENT-SIDE •

    Client coupled to the Service Registry • Client-side implemented SD logic • Different programming languages/frameworks in the clients. May mean many libraries to code.
  10. @alexramirez #mucon #servicediscovery DISCOVERY PATTERNS SERVER-SIDE SD: EXAMPLES Google Compute

    Engine Load Balancing Metadata server ElasPc Load Balancer EC2
  11. @alexramirez #mucon #servicediscovery DISCOVERY PATTERNS PRO ET CONTRA: SERVER-SIDE •

    Client-code gets simpler with no SD logic. Discovery is abstracted from the client. • More control over traffic, allowing A/B tests or canary releases. • Most cloud environments provide it as part of the plaform.
  12. @alexramirez #mucon #servicediscovery DISCOVERY PATTERNS PRO ET CONTRA: SERVER-SIDE •

    If the router is not part of the platform, we have a new HA component to setup and manage in our infrastructure. • HA: multiple instances, always visible. • More network hops (compared to client-side), i.e. more latency.
  13. @alexramirez #mucon #servicediscovery SERVICE REGISTRATION SERVICE REGISTRY: EXAMPLES Eureka Service

    Registry. Client & server. Library. Service RegistraPon implemented via ephemeral nodes under a namespace. Service RegistraPon implemented with k/v and addiPonal libraries
  14. @alexramirez #mucon #servicediscovery SERVICE REGISTRATION SERVICE REGISTRY: EXAMPLES Own system,

    based on DNS and SRV records. K/V mechanism. Full service discovery system in the library. Built on top of etcd. DNS queries to discover available services. SmartStack framework: Nerve (status of machines/services) + Synapse (SD)
  15. @alexramirez #mucon #servicediscovery REGISTRATION PATTERNS PRO ET CONTRA: SELF-REGISTRATION •

    Service instances know their own info, which allows for a complex set of the state model (up/down adds starPng, available, etc.)
  16. @alexramirez #mucon #servicediscovery REGISTRATION PATTERNS PRO ET CONTRA: SELF-REGISTRATION •

    Service coupled to the Service Registry. • Reg logic implemented in every language/framework used. • A running service unable to handle requests lacks self- awareness to unregister itself.
  17. @alexramirez #mucon #servicediscovery REGISTRATION PATTERNS PRO ET CONTRA: 3rd.PARTY-REG. •

    Service code is less complex with no logic of the registraPon. • The registrar can perform health checks to register/ unregister.
  18. @alexramirez #mucon #servicediscovery REGISTRATION PATTERNS PRO ET CONTRA: 3rd.PARTY-REG. •

    The registrar may have limited state knowledge (up/down), with no info on request handling. • If the registrar is not part of the infrastructure, it’s a new component with HA needs to maintain and configure.
  19. @alexramirez #mucon #servicediscovery CREATIVE COMMONS & COPYRIGHT, RESOURCES Credits &

    acknowledgements • These slides contain some photographs from Flickr with an AUribuPon-NonCommercial 2.0 Generic creaPve commons licence: hUps://www.flickr.com/photos/bogers/397745699, hUps://www.flickr.com/photos/ jeremysorrells/8075811194, hUps://www.flickr.com/photos/jasonpier/11300873596, hUps://www.flickr.com/ photos/53221801@N07/14118483789/, hUps://www.flickr.com/photos/manthatcooks/107121255/, hUps:// www.flickr.com/photos/sarahridgley/2118754450/, hUps://www.flickr.com/photos/arcPcpenguin/7153378221/, hUps://www.flickr.com/photos/r4vi/16040202797, hUps://www.flickr.com/photos/bump/3981175472/, hUps:// www.flickr.com/photos/jamesclay/4177348515/, hUps://www.flickr.com/photos/61921496@N04/15008331908/, hUps://www.flickr.com/photos/25143108@N04/3233875532/, hUps://www.flickr.com/photos/johnpaulgoguen/ 3644147837/ , hUps://www.flickr.com/photos/36666383@N00/5342204450/ • The remaining photographs were obtained via Google Images from pages with no license informaPon. Please contact for their removal in the event of any copyright issue. • Most graphics are self-made, though some are or include free icons designed by Fripik and Madebyoliver from FlaPcon.
  20. @alexramirez #mucon #servicediscovery µCon LONDON 2016 Skillscast / VIDEO •

    This presentaPon will soon be available on the conference website at the following link:
 hUps://skillsmaUer.com/conferences/7412-con-2016-the-microservices- conference#skillscasts