Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
高速な広告配信サーバの作り方のコツ
Search
Satoshi
June 23, 2016
Technology
540
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
高速な広告配信サーバの作り方のコツ
高速な配信サーバをつくるためのコツを紹介しています。
Satoshi
June 23, 2016
More Decks by Satoshi
See All by Satoshi
スケールしない広告サーバの作り方
satoshi03
0
260
Gunosy AdServerのデータ周りの話
satoshi03
2
3k
フルスクラッチで書いたアドサーバの開発・運用史
satoshi03
2
4.5k
Gunosy.go #2 container
satoshi03
1
79
Gunosy Go Lang Study #6 net net/http net/url
satoshi03
0
150
Other Decks in Technology
See All in Technology
夫婦で子育てするための育児標準化
codmoninc
PRO
0
200
味覇で作るパスタが美味い - 20261001_yabaubuki.dev
livesense
PRO
0
130
大型犬好きによるPugの紹介
yamanoku
1
150
ゲームのリアルタイム通信から見た QUIC と MoQ
segadevtech
0
110
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
180
Kiro Crewをはじめよう
kizawa2020
1
150
[AWS 秋のクラウドオペレーション祭り 2026]AWS DevOps Agentで変わるリリースと運用対応 ~リリース管理機能と Directed actions のご紹介~
furuton
4
1.2k
FactoryBotアンチパターン / factory_bot anti-patterns
toshimaru
0
150
Loop Engineering これくらいでいい
mikanichinose
0
230
Cognition AI Japan - ウェビナー2_テストQA_運用監視
cogakira
0
140
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
410
AI時代に必要な脅威モデリング― 変化の速度に負けない理解とリスク判断
masakane55
5
1.3k
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
500
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Transcript
高速な広告配信サーバの作り方 のコツ GUNOSY inc. 印南 聡志
自己紹介 • 印南聡志(いんなみ さとし) • Gunosyのアドエンジニア (3年目) –
Gunosyのアド配信サーバ周り全般担当 • 言語 – Go – Python • マイブーム – AJINOMOTOの冷凍餃子 – 大食い(視るだけ) • 参照 – Blog:NO AD NO LIFE(hBp://inchom.hatenadiary.jp/) – Github:hBps://github.com/satoshi03
広告配信サーバって?
配信サーバ (API) バッチサーバ 広告情報 (キャッシュ) とても簡単な仕組み 広告情報
(元データ) ELB 広告 リクエスト
広告配信による収益の最大化 目的
収益 広告選択 応答性能 可用性
高速な広告配信サーバって?
50ms or die 某社
リプレース時の要求性能 1リクエストの応答時間: 50ms 以内 リクエスト数:
10,000req/sec
リプレース後のサーバ性能は?
5ms
1リクエストの応答時間: 5ms リクエスト数:
10,000req/sec 以上
(あたり前だけど忘れがちな) 広告配信サーバを高速化するコツ
1. ボトルネックをつくらない
配信サーバ Redis これまでの問題 リクエスト増
中央の共有DBを作らない
配信サーバ LevelDB S3 バッチサーバ ダウンロード アップロード
共有DBが必要な場合は Writeを集約
配信サーバ Redis Master Redis Slave Redis Slave READ WRITE Sync
バッチサーバ (ログ集約)
プロセスキャッシュを導入
配信サーバ Redis Master Redis Slave Redis Slave READ WRITE Sync
取得したデータを 一定期間保持
2. APIサーバは薄く
これまでの問題 • APIサーバ側で複雑な入札ロジックを実装 – 複数の入札ロジック – 逐次スコアを計算 – 複雑なバリデーション
• Python (tornado) 製
対応 • API側 – Golangで実装 – やることを極限まで削減 • 広告候補の取得
• 簡単なバリデーション • バッチ側で複雑な処理を一括で計算 – Python
3. 応答性能を常時計測
問題 • 様々な性能劣化の原因 – 機能追加/改修 – データの増加 – アクセス傾向の変化
負荷試験をかけて性能劣化を防止
LOCUST • Python製の分散負荷計測ツール – テストのシナリオをPythonで記述 – Web UI の管理画面
– 管理が容易
LOCUST 構成 ・・・ Locust slave Locust master 広告配信 サーバ ・・・
シナリオに応じてリクエストを 生成 Slaveを管理
None
4. コードのチューニング
問題 実際に実行すると処理速度が遅い…
pprof • Goのプロファイラ – 関数ごとのCPU処理時間を計測 – グラフ描画 • 重い処理を視覚的に発見しやすい
見つかった問題 • 様々な原因 – ライブラリ内の実装 – 入札時の広告の探索範囲が広い – バリデーションのコスト
– データキャストのコスト – オブジェクト生成のコスト – DB接続時のコスト – ログ出力コスト
対策を全部うってもダメな場合…
5. 金で解決
金で解決の例 • Redis をやめる – DynamoDB – AeroSpike •
スケールアップで対応 – 4xlargeインスタンス…
まとめ • 広告配信サーバの高速化のコツ 1. ボトルネックをつくらない 2. APIサーバを薄く
3. 応答性能を計測 4. コードのチューニング 5. 金で解決