consul/website/source/intro/use-cases.html.markdown

2.3 KiB

layout page_title sidebar_current
intro Use Cases use-cases

Use Cases

At this point you should know what Serf is and the high-level features Serf provides. This page lists a handful of concrete use cases of Serf. Note that this list is not exhaustive by any means. Serf is a general purpose tool and has infinitely many more use cases. But this list should give you a good idea of how Serf might be useful to you.

It is important to remember that all the use cases available below require no centralized state, are masterless, and are completely fault tolerant.

Web Servers and Load Balancers

Using Serf, it is trivial to create a Serf cluster consisting of web servers and load balancers. The load balancers can listen for membership changes and when a web server comes online or goes offline, they can update their node list.

Clustering Memcached or Redis

Servers such as Memcached or Redis can be easily clustered by creating a Serf cluster for these nodes. When membership changes, you can update something like twemproxy or your own application's list of available servers.

Triggering Deploys

Serf can send custom events to a Serf cluster. If you cluster your web applications into a single cluster, you can use Serf's event system to trigger things such as deploys. Just call serf event deploy and have event handlers installed on all the nodes and the entire cluster will receive this message within seconds and begin deploying.

Updating DNS Records

Keeping your internal DNS servers updated can be a finicky process. By using Serf, the DNS server can know within seconds when nodes join, leave, or fail, and can update records appropriately. No more stale DNS records, or waiting for a Chef or Puppet run to clear out the records within X minutes. With Serf, the records can be updated nearly instantly.

A Building Block for Service Discovery

One of the most difficult parts of service discovery is simply knowing what nodes are online, at what addresses, and for what purpose. An effective service discovery layer can easily be built on top of Serf's seamless membership system. Serf handles all the problems of keeping an up-to-date node list along with some information about those nodes. The service discovery layer then only needs to answer basic questions above that.