SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
28.
パフォーマンスの重要性
• UX
• Jakob Nielsen - Response Times: The 3 Important Limits
“1.0 second is about the limit for the user's flow of
thought to stay uninterrupted”
• KPI
• Google: Using site speed in web search ranking
• Aberdeen Group: study showed that a one second delay
in page load time equals 11% fewer page views, a 16%
decrease in customer satisfaction, and 7% loss in
conversions.
http://www.nngroup.com/articles/response-times-3-important-limits/
http://googlewebmastercentral.blogspot.jp/2010/04/using-site-speed-in-web-search-ranking.html
http://www.aberdeen.com/research/5136/ra-performance-web-application/content.aspx
44.
MySQL SlowLog解析
# mysqlのコンソールにて
> set global slow_query_log = 1;
> set global long_query_time = 0;
> set global slow_query_log_file = "/tmp/slow.log";
# ベンチマーク実行
$ pt-query-digest /tmp/slow.log > /tmp/digest.txt
$ rm /tmp/slow.log
# 戻すときは
$ service mysqld restart
52.
Remix: Latency Numbers Every Programmer Should Know(2014)
http://yuroyoro.net/latency.html
53.
コンテキストスイッチング
CPU CPU CPU CPU
process process process process process process process
process process process process process process process
process process process process process process process
OSによりスケジュール実行
54.
コンテキストスイッチング
CPU CPU CPU CPU
process process
process
process process process process
process process process process process process process
process process process process process process process
OSによりスケジュール実行
55.
コンテキストスイッチング
CPU CPU CPU CPU
process process process process process process process
process process process process process
process
process
process process process process process process process
OSによりスケジュール実行
62.
Nginx vs. h2o
リクエスト
process process
process
リクエスト
thread thread
thread
h2oはプロセスではなくスレッド。スレッドの方がコンテキスト
スイッチのコストが低い。スレッド間の情報の共有がしやすい
複数のworkerプロセスを
起動し大量のアクセスを
捌く
67.
MySQL の B+Tree
titleuser...
titleuser...
titleuser...
titleuser...
titleuser...
titleuser...
titleuser...
titleuser...
PRIMARY KEY
CLUSTERED INDEX
リーフノードに
データを含む
small large
id
id
id
id
id
id
id
id
68.
MySQL の B+Tree
SECONDARY KEY
primary keyじゃないkey
リーフノードに
PRIMARYKEYが含まれ、
データはCLUSTEREDINDEX
から取得
id id id id id id id id
is_private
created_at
older newer older newer
69.
MySQLのB+Tree
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
PRIMARY KEY
id
id
id
id
id
id
id
id
SECONDARY KEY
id id id id id id id id
is_private
created_at
70.
MySQLのB+Tree
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
PRIMARY KEY
id
id
id
id
id
id
id
id
SECONDARY KEY
id id id id id id id id
is_private
created_at
71.
MySQLのB+Tree
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
PRIMARY KEY
id
id
id
id
id
id
id
id
SECONDARY KEY
id id id id id id id id
is_private
created_at
72.
MySQLのB+Tree
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
titleuser....
PRIMARY KEY
id
id
id
id
id
id
id
id
SECONDARY KEY
id id id id id id id id
is_private
created_at
何度も繰り返す=重い
74.
MySQLのOFFSET処理
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... .
1 2 3 4
5 6 7 8
9 10 11 12
13
10000
10001 10002 10003 10004
75.
MySQLのOFFSET処理
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... .
1 2 3 4
5 6 7 8
9 10 11 12
13
10000
10001 10002 10003 10004
頑張ってソート
必要な個数まで到達
76.
MySQLのOFFSET処理
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... .
id title user ... . id title user ... . id title user ... . id title user ... .
id title user ... .
1 2 3 4
5 6 7 8
9 10 11 12
13
10000
10001 10002 10003 10004
頑張ってソート
必要な個数まで到達
廃棄