Skip to content
Radosław Szalski edited this page Apr 26, 2014 · 3 revisions

RTBkit uses Apache's ZooKeeper to publish available services so that components can connect to them and be notified when their availability status changes. This a foundation block of the high availability feature of RTBkit.

In fact, a given service will publish its service class and all available network endpoints.

RTBkit currently offers those services:

  • rtbAgentConfiguration
  • rtbBanker
  • rtbRequestRouter
  • rtbRouterAugmentation
  • rtbPostAuctionService
  • monitor

and 2 types of endpoints:

  • http
  • zeromq

Structure

Nodes are stored in ZooKeeper under an installation node (given as command line parameters) when launching each component. This enables multiple installations to run separately.

When a service is launched, it will publish its available endpoints under the installation root. For example, the current RTBkit banker has one endpoint accessible using either HTTP or ZeroMQ. This will create something similar to this:

$> ls
/installation
/installation/master_banker
/installation/master_banker/http
/installation/master_banker/http/tcp
/installation/master_banker/zeromq
/installation/master_banker/zeromq/tcp

The leaf nodes (here, the tcp nodes) contain a json string that describes how to connect. The content is specific to the type of endpoint but normally contains a list of possible URIs.

Once the various endpoints are published, the service adds a node with its name under the corresponding service class it supplies. For example, the banker would also create the following:

$> ls
/installation
/installation/serviceClass
/installation/serviceClass/rtbBanker
/installation/serviceClass/rtbBanker/master_banker

This node contains a json string used to find the previously published endpoint. In this case, there is only one endpoint so:

{
  "serviceName": "master_banker",
  "servicePath": "master_banker"
}

Thus, a client wanting to connect to a banker service would look under serviceClass/rtbBanker and enumerate the possible nodes. For each node, the servicePath can be used to get the endpoint node of that service.

Samples

HTTP endpoint node:

[
  {
    "httpUri": "http://127.0.0.1:9985",
    "transports": [
      {
        "addr": "127.0.0.1",
        "hostScope": "rtb",
        "name": "tcp",
        "port": 9985
      },
      {
        "name": "http",
        "uri": "http://127.0.0.1:9985"
      }
    ]
  },
  {
    "httpUri": "http://aaa.bbb.ccc.ddd:9985",
    "transports": [
      {
        "addr": "aaa.bbb.ccc.ddd",
        "hostScope": "*",
        "name": "tcp",
        "port": 9985
      },
      {
        "name": "http",
        "uri": "http://aaa.bbb.ccc.ddd:9985"
      }
    ]
  }
]
Clone this wiki locally