Title: Rethinking Service Discovery in Microservices Architecture
Description:
This presentation delves into the microservices architectural pattern, emphasizing the importance of service discovery in a landscape where services operate under the illusion of being solitary entities in the system. The discussion begins with an overview of microservices — small, independent processes that communicate through messages, which collectively contribute to a robust component model facilitating rapid development, continuous delivery, and the mitigation of technical debt.
The core of the talk addresses the complexities and unconventional programming models introduced by microservices, particularly focusing on the challenge of service-to-service discovery. Various strategies for service discovery are explored, including the use of configuration files, intelligent load balancing, service registries, DNS, and the necessity of a message bus. The concept of service discovery is then critically examined, proposing a paradigm shift towards pattern matching, where services interact based on message patterns rather than service identities. This approach advocates for transport independence, blind messaging, and a peer-to-peer model, where services maintain a local worldview, updated dynamically as services fluctuate. The presentation concludes by introducing the SWIM algorithm, an infection-style process group membership protocol designed for scalability and weak consistency, exemplified through a practical implementation in a Twitter clone built with 14 microservices.
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.
18. Blind Messages
๏ Services have zero-knowledge of other
services;
๏ Services emit messages into the world;
๏ Services let the world know what they
care about;
19. 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.
20. The SWIM Algorithm
๏ "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
21.
22.
23.
24.
25.
26.
27. A Twitter clone in
14 microservices:
github.com/senecajs/ramanujan
senecajs.org
38. // a search message
{
"search": "query",
"query": "blue"
}
// the pattern to match
search:query
๏ This message describes the search
activity
๏ At this point, we make no decisions
about the service that will answer this
message.
39. // message patterns
search:query // search for entries
search:insert // index an entry
post:entry // post an entry
info:entry // publish entry info
timeline:list // list entries
timeline:insert // insert entry
follow:user // follow a user
follow:list // list followers
...
๏ The informal requirements define
messages.
๏ The list of messages is a specification.