📢
Search & Discovery

Online Advertising System

Real-Time Bidding Aur Budget
💡 Ad system EK NILAAMI hai jo 100 millisecond mein khatam ho jaati hai. Page load hone se pehle hazaaron advertisers boli lagate hain, sabse oonchi boli jeetti hai, aur ad dikh jaata hai.

Flow hai: ad request → targeting (kaunse ads is user ke liye eligible hain) → auction (bid × predicted CTR se ranking) → winner → impression log. Poora budget 100ms ka hota hai, isliye targeting index memory mein rehta hai aur CTR prediction model bhi low-latency serving mein.

Sabse mushkil distributed problem BUDGET ENFORCEMENT hai. Advertiser ka daily budget khatam hone par ad turant band hona chahiye, par counters kai servers par distributed hain. Solution: har server ko budget ka chhota slice allot karo (local counter) aur periodically central se sync karo — thoda overspend acceptable maana jaata hai, latency ke badle.

// Auction — 100ms budget
Ad request → Targeting (in-memory index: geo, age, interest)
           → eligible ads (~1000)
           → score = bid × predictedCTR      // eCPM
           → winner → serve → impression event (Kafka)

// Budget: local slice + periodic sync, exact global counter nahi
// (exact counter har impression par network round-trip maangega)
📢
Ad system EK NILAAMI hai jo 100 millisecond mein khatam ho jaati hai. Page load hone se pehle hazaaron advertisers boli lagate hain, sabse oonchi boli jeetti hai, aur ad dikh jaata hai.
1 / 2
⚡ Quick Recap
  • Targeting → auction (bid × CTR) → serve, sab 100ms mein
  • Budget enforcement distributed hai — local slices + periodic sync
  • Impressions async (Kafka); billing usi data ka accurate reprocessing
Is page mein (2 subtopics)

Auction sirf bid par nahi jeeti jaati. Platform apni kamai maximize karta hai, isliye ranking eCPM (effective cost per mille) par hoti hai = bid × predicted CTR. Kam bid par high-CTR ad, zyada bid par low-CTR ad ko haraa sakta hai.

CTR prediction ek low-latency ML model hai jo user features, ad features aur context (time, device, placement) leta hai. Ise 10-20ms mein score karna hota hai, isliye model chhota rakha jaata hai aur features precomputed hote hain.

// Ranking eCPM par, bid par nahi
Ad A: bid ₹10, CTR 0.5%  -> eCPM = 10 × 0.005 = 0.05
Ad B: bid ₹5,  CTR 2.0%  -> eCPM = 5  × 0.020 = 0.10  ← jeetega

Bots clicks generate karte hain jisse advertisers ka paisa barbaad hota hai. Detection async hoti hai — impression aur click events analyze karke suspicious patterns (same IP se hazaaron clicks, impossible click-through timing) mark kiye jaate hain aur billing se hataaye jaate hain.

ATTRIBUTION alag problem hai — user ne ad dekha, 2 din baad kharida. Us sale ka credit kis ad ko? Last-click, first-click, ya multi-touch attribution — ye business decision hai aur system ko dono events jodne padte hain.

💡Tip: Billing ko real-time counting se alag rakho. Real-time counters approximate hote hain (dashboards ke liye), aur billing ek separate accurate batch process hai jo fraud filtering ke baad chalta hai.