Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
我在廣告業學到的 大數據實戰技巧
Search
Felix Chern
August 16, 2015
1
1.2k
我在廣告業學到的 大數據實戰技巧
Felix Chern
August 16, 2015
Tweet
Share
More Decks by Felix Chern
See All by Felix Chern
達到硬體極限的演算法設計
dryman
0
410
Atomic programming
dryman
0
290
Introduction to Big Data Engineering
dryman
1
520
Type qualifier and friends
dryman
1
120
Mastering Core Animation
dryman
3
980
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
Being A Developer After 40
akosma
90
590k
Making Projects Easy
brettharned
117
6.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Code Review Best Practice
trishagee
69
19k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
BBQ
matthewcrist
89
9.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.6k
It's Worth the Effort
3n
186
28k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Transcript
我在廣告業學到的 ⼤大數據實戰技巧 Felix Chern (陳仁乾) (dryman) @ OpenX
About Me • Felix Chern, Senior Hadoop Engineer @ OpenX
• MapReduce and Hive • 在前東家 SupplyFrame 從8台 Hadoop機器開始 • 之後加⼊入OpenX,現在擔任 data team tech lead • 200+TB/day data volume • http://idryman.org
什麼是⼤大數據? 資料科學? 資料視覺化? Open Data? Business Intelligence (BI)? Hadoop? Hive?
NoSQL?
From DataFox
產業鍊
⼤大數據(傳統上是BI) 是依附型產業
電商 廣告業 科學機構 網路產業 Big Data CG http://en.wikipedia.org/wiki/Image:Glui.png 電玩 電影⼯工業
動畫產業
沒有CG 還是可以做好電影/動畫
None
但⾃自⼰己沒有CG⼯工業 只能把電影外包時..
None
Big Data 是電商 scale up 的技術之⼀一 僅此⽽而已
你可以學會什麼 • 你是數據服務的接案公司 -> 瞭解客⼾戶需求 • 你也是電商 -> 我們 scale
up 的經驗 • 個⼈人 -> 學會⼤大數據應⽤用的⼀一個⾯面向,以及切⼊入點
廣告業 Google Yahoo! Facebook LinkedIn BBC NewYork Times
資料流與⾦金流
web site 0 0 0 OpenX Ad Server
Advertisers
web site 0 0 0 Ad request User Info OpenX
Ad Server Advertisers User Info Bids Ads Big Data!
有了⼤大數據豪開勳?
None
沒有經過處理的數據是沒有⽤用的 沒有經過處理的數據是沒有⽤用的 沒有經過處理的數據是沒有⽤用的 因為很重要,所以要說三次 D槽存了2TB的影⽚片可能都⽐比這些資料有 ⽤用些。⾄至少可以點開來看
資料⼯工程
Hadoop Ecosystem • Storage: HDFS (20x cheaper) • Computation: Map-Reduce,
YARN, Tez, Spark, etc.
Use case • 帳單報表 (external billing report) • OLAP for
Internal reporting • Traffic quality, User black list, Canary, etc. • Archive (query from hive) ⼩小 中 極⼩小 ⼤大
特性 • 從上百維的原始資料 -> ⼗十幾維的輸出 • Business logic 在所有輸出中必須⼀一致 •
清理髒資料的邏輯也必須⼀一致
以前⼈人怎麼做?
關連式資料庫 使⽤用⼤大量的 ETL (extract transform load) 資料流在不同表單中傳遞及更新
⼤大多數的 ⼤大數據公司怎麼做?
Raw Data ETL ETL ETL ETL ETL Output Output Output
Output Intermediate Data sets Intermediate Data sets Intermediate Data sets clean up
OpenX 怎麼做?
統⼀一的乾淨資料 統⼀一的Fact data 全部以Java撰寫 Raw Data Clean up Clean dataset
Fact dataset Data join Muxing job output output output output output output
三個實戰技巧
技巧⼀一 嚴格的資料驗證
• 使⽤用⼤大量的 guava preconditions class • 出現錯誤時怎麼辦? • Alert •
檢查錯誤 • 上游需「滾回」舊版本 (rollback) • 上 patch 以接受⼀一定⽐比例的髒資料 • 發⽣生頻率:⼀一年三次左右
技巧⼆二 ⽤用OOP處理business logic
if (…) { int a = raw.getInt(“field_a”); if (a >
0) { …; } else if (a == 0) { String b = raw.get(“field_b”); …; } else { …; } else { … } Business logic
• ⽤用java還算好的,pig/hive寫起來更醜、更慢 • ⼤大量的copy & paste,很難refactor • ⾮非常、⾮非常難維護
Business value objects • obj.set(raw); • obj.getValue(); • 繼承在此處⽤用起來⾮非常⾃自然 •
Impression <- QalifiedImpression <- BillableImpression, MarketImpression, etc.
@Override long getValue() { if (raw.is(BILLABLE_IMP)) { return super.getValue(); }
return 0; } 使⽤用繼承來 Unnest if-else 使⽤用Enum來當filter raw 會將enum結果cache起來
• OOP -> UML 適合跟不同team⼀一起制訂規格 • Business logic 變得⼀一致,所有的程式碼都共⽤用 •
重構變得極其簡單
技巧三 ⼤大數據的schema⽅方案
Schema的愛與恨 • 傳統資料庫的schema (Schema on read) • 更新⾮非常痛苦 • ⼀一開始就要設計好
• 沒有schema (i.e. NoSQL) 的話呢? • 什麼都可以進來,什麼都不可靠..
• 選⼀一個serialization format (protobuf, thrift, avro, lwes) (openx使⽤用lwes) • 版本號會附在資料中
• 資料進來時再根據版本號驗證,或是升級 • 兼顧可驗證性,以及開發迭代速度
Bad Practices
• 試圖把所有的big data⼯工具都⽤用上 資料處理不是疊樂⾼高 • 試圖同時解決太多問題 • 髒掉的big data,平均要花⼀一個⽉月才處理的掉 •
浮點數會有誤差。(使⽤用整數存sum & count) • 對資料清潔度妥協,就是對⾃自⼰己殘忍
如何切⼊入big data? • 中⼩小型公司可以試著把⾃自家的ETL改成hadoop • 四到⼋八台機器⾜足矣 • 五個⼩小時的ETL,縮短成20分鐘 (my first
job) • Hadoop the definitive guide: secondary key sort • 使⽤用secondary key sort 做 data join • 使⽤用secondary key sort 做 data de-duplicate
MLDM Monday 三場talk
Questions?