The topology doesn't change

Topology is the definition/schematic of the components and the interconnects. With the high feature velocity in most modern systems, the topology of application deployment is rarely static. In fact, one of the reasons people opt for distributed systems and cloud deployments is the ability to change topology as needed.

What does this mean in terms of code? It means not assuming location (endpoints) for various services. We need to build in service discovery, so that clients of services can figure out how to reach a particular service. There are two ways clients can discover service endpoints:

  • Client-side discovery: Each service instance registers itself (the connection endpoint) with a service registry when it starts up. It is removed from the service registry when the instance terminates. Clients are responsible for consulting the service registry to get an appropriate instance endpoint and directly talk to this endpoint. Netflix OSS has frameworks for supporting the client‑side discovery pattern. Netflix Eureka is a service registry. Netflix Ribbon is an IPC client that works with Eureka to load balance requests across the available service instances.
  • Server-side discovery: Clients are totally ignorant of the distribution of the instances for a service. The client requests go through a router (LB) that is available at a well-known URI. The LB periodically pings each instance to a service to determine the set of healthy instances for the service. When a request is received from a client, the LB uses one of multiple algorithms (such as round robin, random, or affinity) to route the request to the best possible service instance.

Server-side discovery is much simpler to code. However, it can lead to extra hops (client | router | service). Client-side service discovery also allows clients to choose a best possible instance. Thus the tradeoff is more in terms of easier scalability in server-side discovery versus more fine-grained control in client-side-discovery. In practice, the server-side discovery mechanism is more prevalent.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset