Howto Serve 2500 Ad Requests / Second
Howto Serve 2500 Ad Requests / Second
Team lead of
Anúncios Sapo (text ads) team
Are we a role-model?
●
Project Overview
●
Full System Overview
●
Serving Text Ads
●
Latency & Speed
●
Scaling on the Front
●
Backend & backend Services
●
Availability, Reliability & Fault Tolerance
●
Scalability Issues
●
Monitoring & Logging
●
Programming Languages & Technologies
Anúncios SAPO
●
Text Advertisement System
●
Search Engines:
●
BING ( http://www.bing.pt )
●
SAPO's Search ( http://sl.pt )
●
SAPO & Partners' Content Network
●
~200 web sites
●
Impresa, Publico, Cofina, IOL, controlinveste
●
Peaks at 90M ad requests per day, 2500/sec
Serving
Text Ads
Concepts
●
Pay Per Click Business Model
●
CPC - Cost Per Click
●
QPS – Queries Per Second
●
CTR - Click Through Rate
(clicks / impressions)
Serving text-ads ..
Major features:
●
choose & serve ads
●
register requests, impressions, clicks,
conversions
●
maintain user budget up to date
●
Quickly reflect changes in ad pool
Serving text-ads ...
elect_get_ads() {
if( words )
ads = get_ads_keywords()
else {
if (crawled_site)
ads = get_ads_crawler()
else
ads = get_ads_site_keywords()
}
site_ads = get_ads_site_targeting()
merge_ads(ads,site_ads)
}
Serving text-ads ...
Election of ads:
●
requires index
ads['word'] -> [ad1, ad2, ad3..]
●
ads ordered by:
'score' -> f(CTR, CPC, quality)
●
Auction based on
Generalized second-price Auction
Serving text-ads..
contextualization of webpages/sites
reporting information
●
cache it in local RAM (memcached)
●
'persistent' backing store is RAM
Fast word lookups - LiveDB
●
fast index lookup based on the 'fame'
of MySQL speed in simple workloads
●
Replication for free using MySQL's
master-slave replication
Fast word lookups - LiveDB
Constraints:
• There is a maximum table size in bytes
• VARCHAR is in fact.. CHAR()
MySQL MyISAM
Speed is .. ?
Speed is ..
●
We can add more Frontends
to handle more QPS
●
We can add more LiveDB slaves
to handle more SQL Queries
Backend
'compact' & apply operations to the DBMS
runs anti-fraud system
runs contextualizer & crawler
runs semantic analyser
runs reports & suggestions system
Building the LiveDB
Master DBMS MySQL server
(but we are far from saturating it..)
we currently don't plan to 'solve' this
Master LiveDB server
...
Scalability Issues
Building LiveDB doesn't scale:
●
We build a full new LiveDB everytime
●
It isn't distributed nor is it easily made parallel
●
Time is proportional to nº of active Bids
intercept error
serve blank ad
log error
trigger alarm
Monitoring & Alarmistics
network failures
machine failures
software bugs..
bad (or lack of) data
radio silence
log error
trigger alarm
Programming Languages
Python (backend)
Perl (frontend code)
C (1 app only)
Java (broker & reporting)
PHP (backoffices)
SQL
Javascript
Software used
Linux
memcached
MySQL
squid
nginx
Currently Evaluating
Languages: Technologies:
CouchDB
Questions?