Ads Serving Service Architecture
Tổng Quan / Overview
Domain Aggregates
AdRequest Aggregate
- AdRequest: Placement, UserContext, Device
Auction Aggregate
- Auction (Root): Single ad auction instance
- Bid: Candidate ad with calculated score
- AuctionResult: Winner, final price
Pacing Aggregate
- BudgetPacer: Smooth/Accelerated spending
- SpendTracker: Real-time budget consumption
Frequency Aggregate
- FrequencyCap: Max impressions per user/day
- UserAdHistory: Redis-backed view tracking
eCPM Calculation
Redis Data Structures
| Key |
Type |
TTL |
Purpose |
ads:active:{placement} |
Sorted Set |
5 min |
Active ads by eCPM |
freq:{userId}:{date} |
Hash |
24h |
Ad views per user |
budget:{campaignId}:{date} |
String |
24h |
Daily spend counter |
target:{criteria} |
Set |
1h |
Eligible ad sets |
Latency Budget
| Phase |
Target |
| Redis lookup |
< 5ms |
| Auction logic |
< 20ms |
| Response serialization |
< 5ms |
| Total |
< 100ms |