A programmable traffic routing engine.

TC - A programmable traffic routing engine

TC (short for traffic control) is a programmable routing engine that controls incoming request traffic to a pool of services distributed across multiple nodes.

Traffic can be controlled with scoring rules, applied on each incoming request to select a service endpoint among all the available nodes. Such scoring rules can take into account attributes of the request (the source IP address, for instance), or global properties of each node like the current load. Runtime metrics are shared between all nodes via a gossip protocol, which also allows for dead node detection.

Services on each node are configured locally (there is no "central configuration"), and each node broadcasts its local configuration to its peers. It is assumed that some other mechanism (a configuration management system) is available to distribute the rule configuration across all nodes.

Usage in a high-availability setup

The motivation for the realization of TC was controlling incoming user request traffic to a geographically distributed HA pool of services, using short-lived DNS replies.

By co-locating a TC node with every front-end, and with a simple set of scoring rules, users will be directed to the nearest front-end (according to GeoIP), but they will spill over to other front-ends in case that one becomes overloaded or unreachable.

There are other APIs to query the routing engine besides DNS: for example, for finer control over the request flow, TC could be integrated with NGINX via a LUA script performing an HTTP query.

Service monitoring

TC performs no monitoring of the service endpoint by itself, so if one wishes to enable or disable endpoints based on their status, it is necessary to integrate TC with an external monitoring system.

We attempt to make this easier by providing a command-line tool to enable / disable a service and reload the TC daemon configuration.


Make sure to have set up your GOPATH correctly, then after you've checked out the repository run:

$ go install git.autistici.org/ale/tc

This should place the tcd binary in $GOPATH/bin.


TC uses a JSON-encoded configuration file, usually located in /etc/tc/config.json. The configuration file contains two main sections:

Configuration of the local node: name, IP addresses, etc. including the list of local services and associated data.
Configuration of the routing engine. For each service, defines a list of scoring functions. The default service is special, and it's used as a default for services with no rules defined.

DNS setup

TC serves authoritative DNS replies for a single zone (which must be specified on the command line with the --origin option). If it's not possible to run the DNS server on port 53 (not advised since the server does not properly drop privileges), you can run it on a higher port and configure a forwarding zone on the primary DNS server. For instance, this is how one might do that with Bind:

zone "lb.example.com" {
    type forward;
    forwarders { port 1053; };