Service discovery with Mesos-DNS

Mesos-DNS is a stateless DNS server for Mesos. Contributed to open source by Mesosphere, it provides service discovery in datacenters or cloud environments managed by Mesos.

Highly-distributed systems like Mesos require service discovery as an essential building block to connect applications and services. At its simplest, service discovery is the mechanism by which an application or service can “discover” where other applications and services are located so that they can be connected. In a datacenter managed by Mesos, service discovery is especially important because applications and services are placed on machines (and sometimes moved) based on real time scheduling decisions as Mesos scales them out or restarts them after a machine failure. In such a dynamic environment, it is difficult for applications and services to find and keep up with the location of other applications and services they rely on.

Until now, each user of Mesos was required to choose their own service discovery mechanism, or to use a patchwork of mechanisms supplied by different frameworks. Mesos-DNS offers a service discovery system purposely built for Mesos. It allows applications and services running on Mesos to find each other with DNS, similarly to how services discover each other throughout the Internet. Applications launched by Marathon or Aurora are assigned names like search.marathon.mesos or log-aggregator.aurora.mesos. Mesos-DNS translates these names to the IP address and port on the machine currently running each application. To connect to an application in the Mesos datacenter, all you need to know is its name. Every time a connection is initiated, the DNS translation will point to the right machine in the datacenter.

How does it work

Service dicovery in Mesos with Mesos-DNS

Mesos-DNS periodically queries the Mesos master and retrieves the state of all running applications for all frameworks. It uses the latest state to generate DNS records that associate application names to machine IP addresses and ports. Mesos-DNS operates as the primary DNS server for the datacenter. It receives DNS requests from all machines, translates the names for Mesos applications, and forwards requests for external names, such as www.google.com, to other DNS servers. The configuration of Mesos-DNS is minimal. You simply point it to the Mesos masters at launch. Frameworks do not need to communicate with Mesos-DNS at all. As the state of applications is updated by the Mesos master, the corresponding DNS records are automatically updated as well.

Mesos-DNS is simple and stateless. Unlike Consul and SkyDNS, it does not require consensus mechanisms, persistent storage, or a replicated log. This is possible because Mesos-DNS does not implement heartbeats, health monitoring, or lifetime management for applications. This functionality is already available by the Mesos master, slaves, and frameworks. Mesos-DNS builds on it by periodically retrieving the datacenter state from the master. Mesos-DNS can be made fault-tolerant by launching with a framework like Marathon, that can monitor application health and re-launch it on failures.

What’s next?

The alpha release of Mesos-DNS supports a basic scheme for application naming. With the upcoming enhancements to Mesos for service discovery support, we will be able to support flexible naming schemes that capture the service discovery needs for a wide set of deployments. We will extend Mesos-DNS to track security and networking features introduced in Mesos. Mesos-DNS will be integrated in the Mesosphere DCOS to support service discovery in public cloud, private datacenter, and hybrid deployments.

Try it now

Get the code and instructions for Mesos-DNS from the Mesosphere github repository. We’re looking forward to community feedback.