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
1
280
モバイルサイトでGoogle Analyticsを利用する
クックパッドでは携帯版のアクセスログの解析について。
robotvert
June 01, 2010
Tweet
Share
More Decks by robotvert
See All by robotvert
ActionCable and React
robotvert
0
73
About COOKPAD (2013-11)
robotvert
21
5k
Pseudo SMT at COOKPAD
robotvert
0
290
Other Decks in Programming
See All in Programming
ドメイン駆動設計を実践するために必要なもの
bikisuke
4
330
Google Sign-inの移行から始めるCredential Manager活用
clockvoid
0
310
今インフラ技術をイチから学び直すなら
yuhta28
1
140
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
120
LangChainの現在とv0.3にむけて
os1ma
4
920
o1モデルのプロンプトエンジニアリングって?
ktc_wada
0
260
GenU導入でCDKに初挑戦し、悪戦苦闘した話
hideg
0
160
[DroidKaigi 2024] Android ViewからJetpack Composeへ 〜Jetpack Compose移行のすゝめ〜 / From Android View to Jetpack Compose: A Guide to Migration
syarihu
1
630
仮想ファイルシステムを導入して開発環境のストレージ課題を解消する
segadevtech
2
550
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
490
意外とフォントが大事だった話 / Font Issues on Internationalization
fumi23
0
110
Rechartsで楽にゴリゴリにカスタマイズする!
10tera
1
170
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
459
32k
Become a Pro
speakerdeck
PRO
22
4.9k
Making Projects Easy
brettharned
113
5.8k
No one is an island. Learnings from fostering a developers community.
thoeni
18
2.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
21
3k
Statistics for Hackers
jakevdp
794
220k
Pencils Down: Stop Designing & Start Developing
hursman
119
11k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
89
16k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
The Cult of Friendly URLs
andyhume
76
6k
Building Your Own Lightsaber
phodgson
101
6k
Building Adaptive Systems
keathley
36
2.1k
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/