Skip to content

Post Auction Loop Sharding

Rémi Attab edited this page Apr 28, 2015 · 2 revisions

The post-auction loop (PAL) is responsible matching bids to wins and as such has to be able to handle to support the full bid traffic plus the full win traffic on an RTBkit data-center. This means that after a certain point, multiple PAL instances may need to be deployed to support the load. The tricky bit is we need to make sure that all a matching bid and win are sent to the same PAL instance otherwise we'll fail to match them. This page will cover how the PAL is scaled and what configuration options need to be enabled to make it work.

PAL Scaling

To scale the PAL, we need to make sure that a bid is sent to the same PAL instance that a win will be sent to. To make this happen we shard the events by hashing the auction id and applying a modulo of the number of active PAL instances. The resulting number will tell us which PAL instance a given bid and win will be sent to in order to ensure that they will be matched. The sharding scheme is applied in the ad-server connector for wins and in the router for bids.

PAL configurations

To get started, you need to modify the bootstrap.json to contain the key postAuctionShards set to the number of PAL instances which you will be running. This parameter is used by both the ad server connector and the router as the modulo value to be applied to the hash of the auction id.

Next, you'll need to start your various PAL instances by specifying the shard command line argument set to the shard id of that PAL instance. This shard ids are sequential numbers starting at 0 and will be published to zookeeper such that both the ad-server connector and the router can determine which PAL instance correspond to which shard.

Example

Assuming we want to run 4 PAL shards then you'll have to start by adding the following to the bootstrap.json:

{
    ...
    "postAuctionShards": 4,
    ...
}

You'll then want to use the following command line arguments to start the various PAL instances:

./build/x86_64/bin/post_auction_runner --shard 0 ...
./build/x86_64/bin/post_auction_runner --shard 1 ...
./build/x86_64/bin/post_auction_runner --shard 2 ...
./build/x86_64/bin/post_auction_runner --shard 3 ...

That's it.

Clone this wiki locally