Skip to content

Commit 17c7fca

Browse files
committed
Merge pull request #22 from rick446/master
Latest batch of use cases, with some corrections to old ones (DOCS-169 DOCS-201)
2 parents 2425b73 + ba4f443 commit 17c7fca

12 files changed

+1725
-65
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
.. -*- rst -*-
2+
3+
=======================================
4+
Online Advertising: Campaign Management
5+
=======================================
6+
7+
.. default-domain:: mongodb
8+
9+
Overview
10+
--------
11+
12+
This document outlines the basic patterns and principless for using
13+
MongoDB as a persistent storage engine for an online advertising network. In
14+
particular, this document focuses on creating and maintaining an advertising
15+
campaign with a pre-set daily budget and cost per click (CPC) and cost per
16+
thousand impressions (CPM) limit.
17+
18+
Problem
19+
~~~~~~~
20+
21+
You want to create an advertising network that will serve ads to a variety of
22+
online media. As part of this ad serving, you want to track which ads are
23+
available to be served, based on both the daily budget and the CPC and CPM
24+
limits.
25+
26+
As part of a campaign, a customer creates one or more *zones*, where
27+
each zone represents some location on a group of pages. Each zone in a campaign
28+
then has one or more ads assigned to it
29+
30+
Solution
31+
~~~~~~~~
32+
33+
In this solution, you will store each campaign's metadata in its own document,
34+
including budget, limits, targets, and ongoing statistics. This data can be
35+
modified before the campaign starts or during the campaign itself.
36+
37+
Schema Design
38+
~~~~~~~~~~~~~
39+
40+
The schema for campaign management consists of a two collections, one which
41+
stores campaign metadata, and another for campaign statistics. The campaign
42+
metadata collection ``campaign.metadata`` documents have the following
43+
format:
44+
45+
.. code-block:: javascript
46+
47+
{
48+
_id: ObjectId(...),
49+
customer_id: ObjectId(...),
50+
title: "August Shoes Campaign",
51+
begin: ISODate("2012-08-01T00:00:00Z"),
52+
end: ISODate("2012-08-31T00:00:00Z"),
53+
zones: {
54+
z1: {
55+
site: 'cnn.com',
56+
page: 'stories/shoes/.*', zone: 'banner',
57+
limit: { type: 'cpm', value: 2000 },
58+
ad_ids: [ 'ad1', 'ad2' ] },
59+
z2: {
60+
site: 'cnn.com',
61+
page: 'stories/shoes/.*', zone: 'tower-1a',
62+
limit: { type: 'cpc', value: 45 },
63+
ad_ids: [ 'ad3' ] } },
64+
daily_budget: 25000
65+
}
66+
67+
The statistics are stored in their own collection ``campaign.stats``:
68+
69+
.. code-block:: javascript
70+
71+
{
72+
_id: ObjectId(...), // same as campaign ID
73+
zones: {
74+
z1: {
75+
daily_stats: {
76+
'2012-08-01': {
77+
total: { impressions: 10146, clicks: 198, conversions: 16 },
78+
ad1: { impressions: ... },
79+
ad2: { impressions: ... } },
80+
'2012-08-02': {
81+
total: { impressions: 9182, clicks: 183, conversions: 18 },
82+
ad1: { impressions: ... },
83+
ad2: { impressions: ... } },
84+
'2012-08-03': {
85+
total: { impressions: 9784, clicks: 202, conversions: 21 },
86+
ad1: { impressions: ... },
87+
ad2: { impressions: ... } },
88+
...
89+
'2012-08-31': {
90+
total: { impressions: 0, clicks: 0, conversions: 0 },
91+
ad1: { impressions: 0, clicks: 0, conversions: 0 },
92+
ad2: { impressions: 0, clicks: 0, conversions: 0 } } }
93+
},
94+
z2: {
95+
daily_stats: {
96+
'2012-08-01': {
97+
total: { impressions: 10457, clicks: 79, conversions: 14 },
98+
ad3: { impressions: ... } },
99+
'2012-08-02': {
100+
total: { impressions: 9283, clicks: 53, conversions: 8 },
101+
ad3: { impressions: ... } },
102+
'2012-08-03': {
103+
total: { impressions: 9197, clicks: 72, conversions: 14 },
104+
ad3: { impressions: ... } },
105+
...
106+
'2012-08-31': {
107+
total: { impressions: 0, clicks: 0, conversions: 0 },
108+
ad1: { impressions: 0, clicks: 0, conversions: 0 },
109+
ad2: { impressions: 0, clicks: 0, conversions: 0 } } }
110+
}],
111+
daily_spent: {
112+
'2012-08-01': 23847,
113+
'2012-08-02': 20749,
114+
...
115+
'2012-08-12': 0,
116+
'2012-08-13': 0,
117+
...
118+
'2012-08-31': 0 }
119+
}
120+
121+
Operations
122+
----------
123+
124+
TODO: summary of the operations section
125+
126+
The examples that follow use the Python programming language and the
127+
:api:`PyMongo <python/current>` :term:`driver` for MongoDB, but you
128+
can implement this system using any language you choose.
129+
130+
Operation 1
131+
~~~~~~~~~~~
132+
133+
TODO: describe what the operation is (optional)
134+
135+
Query
136+
`````
137+
138+
TODO: describe query
139+
140+
Index Support
141+
`````````````
142+
143+
TODO: describe indexes to optimize this query
144+
145+
Sharding
146+
--------
147+
148+
.. seealso:: ":doc:`/faq/sharding`" and the ":wiki:`Sharding` wiki
149+
page.

0 commit comments

Comments
 (0)