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
330
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
モバイルサイトでGoogle Analyticsを利用する
クックパッドでは携帯版のアクセスログの解析について。
robotvert
June 01, 2010
More Decks by robotvert
See All by robotvert
ActionCable and React
robotvert
0
110
About COOKPAD (2013-11)
robotvert
21
5.2k
Pseudo SMT at COOKPAD
robotvert
0
390
Other Decks in Programming
See All in Programming
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
550
リアルな遅延を測る仕様
kota_yata
1
130
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.8k
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
380
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
Go 1.27 における memory allocation の高速化
andpad
0
320
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.1k
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
210
typoなんかねぇよ
raspython3
0
550
「人を評価する AI」の設計と実装
ryoyanara
0
240
React本体のコードリーディング
high_g_engineer
1
160
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
500
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
580
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
660
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
For a Future-Friendly Web
brad_frost
183
10k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
So, you think you're a good person
axbom
PRO
2
2.1k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
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/