7.3 Ad targeting
On countless websites around the internet, we see advertisements in the form of text
snippets, images, and videos. Those ads exist as a method of paying website owners for
their service—whether it’s search results, information about travel destinations, or
even finding the definition of a word.
In this section, we’ll talk about using SETs and ZSETs to implement an ad-targeting
engine. When you finish reading this section, you’ll have at least a basic understanding
of how to build an ad-serving platform using Redis. Though there are a variety of
ways to build an ad-targeting engine without Redis (custom solutions written with
C++, Java, or C# are common), building an ad-targeting engine with Redis is one of
the quickest methods to get an ad network running.
If you’ve been reading these chapters sequentially, you’ve seen a variety of problems
and solutions, almost all of which were simplified versions of much larger projects
and problems. But in this section, we won’t be simplifying anything. We’ll build
an almost-complete ad-serving platform based on software that I built and ran in a
production setting for a number of months. The only major missing parts are the web
server, ads, and traffic.
Before we get into building the ad server itself, let’s first talk about what an ad
server is and does.