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
モバイルサイトでGoogle Analyticsを利用する
Search
robotvert
June 01, 2010
Programming
320
1
Share
モバイルサイトでGoogle Analyticsを利用する
クックパッドでは携帯版のアクセスログの解析について。
robotvert
June 01, 2010
More Decks by robotvert
See All by robotvert
ActionCable and React
robotvert
0
100
About COOKPAD (2013-11)
robotvert
21
5.2k
Pseudo SMT at COOKPAD
robotvert
0
360
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
440
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
2
250
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
110
JOAI2026 1st solution - heron0519 -
heron0519
0
170
Road to RubyKaigi: Play Hard(ware)
makicamel
1
520
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2.5k
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
19
9.4k
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
310
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
130
GitHubCopilotCLIをはじめよう.pdf
htkym
0
310
Back to the roots of date
jinroq
0
620
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
790
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.5k
Claude Code のすすめ
schroneko
67
220k
For a Future-Friendly Web
brad_frost
183
10k
WCS-LA-2024
lcolladotor
0
570
sira's awesome portfolio website redesign presentation
elsirapls
0
230
Designing Powerful Visuals for Engaging Learning
tmiket
1
360
A Tale of Four Properties
chriscoyier
163
24k
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
Exploring anti-patterns in Rails
aemeredith
3
350
Design in an AI World
tapps
1
210
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Transcript
Mobile Analytics Julien Feltesse
自己紹介 フェルテス ジュリアン @robotvert フランス出身 日本に滞在4年目 最近はKVSとAndroidに興味
1 2 3 Google Analytics COOKPAD Google 1 request to
whatever page 2 requested page + GA javascript 3 sending infos about the request to GA using javascript
携帯はJavascript対応してないので 違う方法が必要
Googleのコード aspx, php, java, perl... no ruby! まずはRubyに変換
1 4 2 Mobile Analytics COOKPAD Google 1 request to
whatever page 2 requested page + img src html tag whose source is on the server 3 requesting the img, passing along some parameters 4 sending infos about the request to GA 4 finally, returning the img itself (1x1 transparent GIF) 5 3
Googleのコード ページに1x1ピクセルの透明GIFを入れる。 <img src=”ga? utmac=ACCOUNT&utmn=RANDOM &utmr=REFERER&utmp=REQUEST_URI”>
Googleのコード サーバー側 •パラメーターからもらった情報の整理 • Visitor id 作成:cookie使うか、uid使うか、UAで ランダムidを作ってる。 • Cookieを送ってみてる。
•集まった情報でGoogleに送るリクエスト作って、 クライアントのUAとAccept-Language使ってサー バーがGoogleにリクエストを送る。 •レスポンスは透明GIFになる。
Googleのコード 問題 • GIF呼び込むとサーバーに2回リクエストする • 携帯は通信が遅い • サーバーの負荷もったいない • syncでサーバーがGAにリクエスト送るので、GA
が遅いまたは落ちた場合は、クライアントに影響 になる。
COOKPADバージョン •とにかくサーバーがパラメーター作ってるので 2回リクエストしなくてもうごく → GIFいらない! •クライアントに影響ないようにしなきゃ
バージョン1 LVSの後ろ、サーバー2台で、Railsのアプリで リクエストの時にforkして、別なプロセスでGAに リクエスト送る事 大失敗 • forkが死ぬほど遅い • その代わりにRails 2.3.5で、MetalやThreadを
使ってもまだまだ遅い
バージョン2 Beanstalk queue serverをインストールして、 appサーバーがGAに送るリクエストをQueueに 入れて、別なサーバーがJavaのアプリでその Queueからタスクとってきて、GAにリクエスト 送る 成功 •
CPUはいつも20%未満 • メモリーリークなし • ピークタイムでも死なない
1 2 3 COOKPAD Analytics COOKPAD Google L V S
Beanstalk queue java Beanstalk queue java
Javaのアプリ とっても簡単: • Master classが起動の時N worker threadsを作成 し、スタートさせる(現在は100 threadsで) •
Worker classが常にQueueの状態を確認して、タ スクがあったら直接GAにリクエスト送る
Javaのアプリ お得なところ • Beanstalkのいいところ:接続キープしてる → threadsがpollingするの必要がない。 • ThreadsがMasterとsyncしないのでsynchronize 系のバグやパフォーマンスの問題がない
Javaのアプリ 簡単なHTTPサーバーを追加してから: • ヘルスチェック可能 • /hello => HTTP 204 •
きれいに止める事が出来る(killしないで) • /shutdown => HTTP 200, stop all workers or exit in 5 secs • すべてのthreadのステータスが見れる • /status => HTTP 200 Worker 009: RUNNABLE | 3182853 completed jobs, 0 failed jobs Worker 010: RUNNABLE | 3183679 completed jobs, 0 failed jobs Worker 011: RUNNABLE | 3182793 completed jobs, 0 failed jobs ...
ありがとうございます icons: http://quantum-bits.org/