View on GitHub


Redirector Logo


The Redirector project is a collection of tools that facilitate redirection of incoming connections to a set of trusted backend servers based on a set of rules that operate on parameters in the incoming request. Redirector can assist with load-balancing across the backend servers and traffic-shaping to two versions of an application. Redirector is typically used to create “sticky” sessions to the backend servers, however, it could be called for each request to a service.

The current version of the project supports HTTP redirects, or the ability to specify the target backend in the body of the response. The frameworks are designed to be flexible/extensible and support any non-HTTP protocol (such as WebSockets) as well. The core premise of the tool is that there are stacks or groups of backend servers running a particular version of software and are validated and ready to take traffic. Groups of backend servers may be whitelisted to be able to handle any incoming request in a round-robin fashion. The tools are designed to be able to function during any systemic outages when the tools themselves may not be in a stable state.

The core components of the Redirector framework are Redirector Gateway and Redirector Web Service. The Redirector Gateway receives requests from clients and returns the server to which the client should connect. The Redirector Web Service is used to manage the stacks of backend servers and the rules that direct traffic to the stacks.

Redirector Gateway

Redirector Gateway (Redirector GW) receives requests and returns the IP addresses of backend servers according to the model. Redirector GW uses a distributed key/value store (Zookeeper) as the source of truth for backend servers and Redirector WS for the rules. If either Zookeeper or Redirector WS is temporarily down, Redirector GW uses a local file system backup of the Last Known Good service discovery and rule engine data.

Redirector Model

The Redirector model contains various information about an application that allows Redirector GW to choose the correct backend server. There is a separate model for each application. Redirector WS notifies Redirector GW of a model update through Zookeeper. Redirector GW will obtain the latest model and save it in a local filesystem backup. The local backup is a Last Known Good that can be used if the connection to Zookeeper is down when Redirector GW is restarted.

The Redirector model consists of the following items.

Redirector Service Discovery

Redirector GW uses service discovery to find the IP addresses of the backend servers in each stack. There are two approaches to service discovery–static and dynamic. With static service discovery, Redirector GW takes a snapshot of all service discovery information from Zookeeper when a Model Update is initiated by the user. Redirector GW keeps the service discovery information in memory and uses until the next Model Update. With dynamic service discovery, Redirector GW learns of a new server once it registers with Zookeeper. This server is then available to take traffic.

Application service hosts register with Zookeeper exhibiting their availability. They can publish their attributes such as IPv4 and IPv6 support. The default mode of traffic distribution is Round-robin, where all the hosts get even distribution of traffic. The framework supports Weighted traffic shaping via controls defined by the application. During the registration process, service hosts can publish an individual weight that varies from 1 to 100 thereby controlling the amount of traffic being directed to the host.

// Sample payload for registration:


Redirector Web Service

Redirector Web Service (Redirector WS) is used to manage the stacks and rules through an Admin UX. Stacks can be whitelisted in Redirector WS so that they can take traffic. Rules can be created to send traffic to stacks based on input parameters or distribution percentages. Redirector WS saves the model in Zookeeper so that Redirector GW can access it.

Model approval process in Redirector Web Service

Any changes to the model are saved in a pending changes state. This allows one person to make the change and another person to approve the change. Once the change is approved, the new model is saved in Zookeeper, and the Redirector GW servers are notified.

Redirector Admin UX Offline mode

In order to let administrators modify the model when there is no connection to the Zookeeper cluster, the Admin UX works in an Offline Mode and keeps all information in a browser index DB. Administrators can download the Redirector Core backup and scp it to Redirector GW servers. After the Redirector GW servers are restarted, the model produced by Offline Mode will be applied as the Last Known Good and will be used until the Zookeeper cluster is restored.