Implementation Patterns

Overview

This section addresses some common integration patterns, and provides guidance on how Foursquare's On-Prem Campaign SDK can be used to best effect.

The expected deployment architecture is multiple Campaign On-Prem processes behind a load-balancer capable of server-side keep-alive connections, such as HAProxy. Each underlying process expects to process a high volume of requests over a small number of connections (approx. two connections per core is ideal).

Load Balancer

Multiple Campaign On-Prem processes placed behind a load balancer is the most simple pattern:

602

Figure 1. Multiple Campaign On-Prem processes behind a load balancer

(The arrows above, and all other diagrams represent requests, with responses implicitly travelling in the opposite direction.)

An alternate approach is placing a Campaign On-Prem process alongside each server process. This can simplify deployment, but requires sufficient resources on each server to host both processes.

508

Figure 2. A Campaign On-Prem process cohabiting with each server process

Ad Server Integration

A common need is to turn the Proximity and Audience responses into segments that can be consumed by an ad server. This can be accomplished one of two ways: (1) Proxying all requests to both Campaign On-Prem and the Ad Server, or (2) the server proxys the segment information back to the client.

376

Figure 3. A server proxying all requests to Campaign On-Prem and the ad server

Here, the client wishes to show an ad, and makes a request to the server, which queries Campaign On-Prem, and extracts the necessary information to construct the segments that will be passed to the Ad Server. The response from the Ad Server is proxied back to the client.

376

Figure 4. A server proxying requests to Campaign On-Prem

Alternately, the server can proxy the segment information back to the client, which will make the call to the Ad Server directly. These approaches are largely interchangeable, but the second approach may be somewhat less demanding on the server infrastructure.

Keeping the logic that transforms Campaign On-Prem responses into ad segments on the server is critical, especially if the client is a mobile application. As it is difficult to predict how Audience and Proximity data may be employed in ad targeting, the logic should be kept where it can be easily updated.