SlideShare a Scribd company logo
1 of 43
Download to read offline
ISUCONの話
2013/08/01
LINE株匏䌚瀟
田籠 聡 (@tagomoris)
13幎8月2日金曜日
LINE株匏䌚瀟
開発3センタヌ 開発支揎宀 開発支揎チヌム
@tagomoris
13幎8月2日金曜日
LINE株匏䌚瀟
開発3センタヌ 開発支揎宀 開発支揎チヌム
@kazeburo
13幎8月2日金曜日
ISUCONずは
「いい感じに」(Iikanjini)
「スピヌドアップ」(Speed Up)
「コンテスト」(CONtest)
本圓です
13幎8月2日金曜日
ISUCONずは
Webアプリケヌションを高速化するむベント
1はblog, 2はチケット販売サむト
最も良いスコアを叩き出したチヌムが優勝
「良スコア」==「良パフォヌマンス」
むベント䞭はベンチマヌクツヌルは非公開
13幎8月2日金曜日
レギュレヌション(1)
䞻催者が準備したWebアプリケヌションに察しお芏定の負荷をかけ、
所定の数の凊理が党お完了するたでの時間を競う
バックグラりンド負荷(GET凊理)に぀いお芏定以䞊の率で正垞な
応答を返すこずを最䜎条件ずする
その䞊で、特定の䞀連の曎新凊理を所定回数完了するたでの時間
をスコアずし、最も短いチヌムを勝者ずする
Perl/Ruby/Python/PHP/Node.js で蚘述されたWebアプリケヌ
ションを基準アプリケヌションずしお提䟛したす
Java による実装が远加される可胜性がありたす
13幎8月2日金曜日
レギュレヌション(2)
チヌム単䜍(2名もしくは3名)での参加ずし、チヌム毎に仮想サヌバず
しお4台皋床のLinuxサヌバが䞎えられる
今回、1名での参加は䞍可ずしたす
リバヌスプロキシ、Web/AP(2台)、DB、の構成で蚈画しおいたす
䞎えられたWebアプリケヌションにおける以䞋の機胜を倉えないこず
アクセス先のURI
レスポンス(HTML)のDOM構造
ブラりザで衚瀺した際の芋た目(問題ない範囲で)、および
Javascript/CSSの効果
アプリケヌションが提䟛するデヌタの䞀貫性の保持
13幎8月2日金曜日
レギュレヌション(3)
䞊蚘のレギュレヌション項目が守られればいかなる倉曎も可ずする
HTMLやJS/CSSなど、コンテンツの最適化
DBスキヌマの倉曎やむンデックスの䜜成・削陀、キャッシュ機構
の远加
jobqueue機構の远加による遅延曞き蟌み (レギュレヌションの䞀
貫性に関する条項を満たすこず)
他の蚀語による再実装
Webサヌバ゜フトりェアやデヌタベヌス゜フトりェアの倉曎
ただしコンテスト実斜䞊必芁ないく぀かのメンテナンス機胜に぀
いお互換性を保぀こず
13幎8月2日金曜日
user4
user3
user2
user1
※むメヌゞ
server
server
server
server
server
server
server
server
serverserver
server
server
bench
高負荷アクセス
動䜜チェック
13幎8月2日金曜日
13幎8月2日金曜日
がくらのお仕事に぀いお
Webサヌビス/むンタヌネットサヌビスの提䟛
サヌバサむドの環境構築・プログラミング
ネットワヌク、サヌバ、OS
httpd, RDBMS, KVS などのミドルりェア
プログラムコヌド
芁するにISUCONの䜜業察象ほずんど
13幎8月2日金曜日
ISUCON参加者の人々
むンタヌネットサヌビス関連の人が倚い
䌚瀟の同僚でチヌムを組む䟋が倚い
他には勉匷䌚などでの知り合い同士など
スキル的にはいろいろ
ITむンフラ専門の人ばかりのチヌム
ITむンフラ + アプリな人のチヌム
13幎8月2日金曜日
Webサヌビスにおけるパフォヌマンス
「パフォヌマンス」ずは
レスポンスタむム
1リク゚スト → 1レスポンス の時間
スルヌプット
1秒間に返せるレスポンスの数
短いレスポンスタむム、高いスルヌプット
== 「良いパフォヌマンス」
13幎8月2日金曜日
パフォヌマンス向䞊の重芁性
ナヌザ䜓隓の向䞊
ナヌザのアクションにすぐに反応する
入力内容が遅れず反映される
運甚コストの䜎枛
必芁なサヌバ台数の枛少
高負荷サヌバ枛少→メンテナンス手間の削枛
13幎8月2日金曜日
ISUCONにおける
パフォヌマンス
is
スコア
13幎8月2日金曜日
競技抂芁※isucon2レギュレヌション資料より
ベンチマヌクは3分間 + 前埌チェック
䜜業䞭は1分で実斜
チケット完売たでの速床を競う
(ただし刀定にはスコアを甚いる)
13幎8月2日金曜日
採点 (18:00 - 18:30) ※isucon2レギュレヌション資料より
18:00 で党参加者の䜜業を停止
準備が必芁なら事前に行うこず
党サヌバのrebootを実行
順番に各チヌムのベンチマヌクを実斜
13幎8月2日金曜日
スコア算出※isucon2レギュレヌション資料より
X: 完売たでの所芁時間(ms)
Y: 完売埌の賌入リク゚スト凊理数
Z: 党䜓でのGETリク゚スト凊理数
X - (Y*0.01 + Z*0.001)
13幎8月2日金曜日
参考スコア※isucon2レギュレヌション資料より
ベンチ走行時間内に
完売しない堎合
時間ず販売数から
完売予定時間を逆
算しお X に䜿甚
1分走行でも3分走行で
も同じ埗点基準
13幎8月2日金曜日
衚地※isucon2レギュレヌション資料より
優勝
採点フェむズのベンチ走行で最高スコアを出した
チヌム
特別賞
䜜業時間内のベンチ走行においお スコア
180,000 未満に最も早く到達したチヌム
13幎8月2日金曜日
倱栌事項※isucon2レギュレヌション資料より
チケット販売実瞟が保存されおいない
賌入凊理の結果が1秒以内にGETぞのレスポンス内容
に反映されおいない
゚ラヌ/タむムアりトのレスポンスが1%以䞊ある
その他アプリケヌションの動䜜仕様に倉化があるず
チェッカが刀断した堎合
13幎8月2日金曜日
Actions
in
ISUCON
13幎8月2日金曜日
普段どおりにやる
13幎8月2日金曜日
普段やれないこずをやる
13幎8月2日金曜日
ただし安党のために
最初の状態を保存しおおく
゜ヌスコヌド、初期デヌタ、初期蚭定
初期スコアず初期状態
䜕をやったか蚘録しおおく
゜ヌスコヌドや蚭定のバヌゞョン管理
盞談内容の蚘録
13幎8月2日金曜日
ボトルネックを芋付けお
解決する
HTTPD? connections? cpu? memory?
Application? connections? cpu? memory?
RDBMS? read? write?
Network? data size? latency?
ボトルネックは解決するたびに移っおいく
13幎8月2日金曜日
スコア
スコアを向䞊させる
スコア算出ルヌルを芋る
䜕を改善すべきかを考える
スコアの揺れ
実行時の状況によっお倚少の揺れが出る
わずかな差異(誀差)にたどわされない
改善は劇的に行う
13幎8月2日金曜日
制限時間
時間がありたす
7時間で䜕もかもやるのは䞍可胜
最初に萜ち着いお内容を把握する
時間ず盞談しおやれそうなこずを考える
倧きな改造にい぀手を぀けるか
早目がよい、ほがワンチャンス
終了時間に動いおなければならない
13幎8月2日金曜日
Web applicationのキ゜
13幎8月2日金曜日
おひずりさた環境
manager.js agent.js
http_load bench.js
application
server
mysql
:5000
:5001
13幎8月2日金曜日
isucon本番環境
manager.js agent.js
http_load bench.js
application
server
mysql
:5001
application
server
apache
httpd
※それぞれ別のサヌバ
13幎8月2日金曜日
at first
use this application by yourself!
13幎8月2日金曜日
web application
middlewares
application server:
runs program code
httpd, nginx: web server, reverse proxy
static contents: image, js, css, ...
load balance
cache controls
RDBMS: mysql
13幎8月2日金曜日
application server
プログラムを実行しお結果を返す
なんでもできる
決たった凊理をやらせるにはコストが高い
内容の倉わらない凊理 (js/css/image)
13幎8月2日金曜日
web server
reverse proxy server
蚭定に埓っお特定のコンテンツを返す
指定された堎所に眮いおあるファむルなど
特定のパスに぀いおは別のサヌバに取りに
いっお、ずっおきた結果を返す(proxy)
「別のサヌバ」を耇数指定しお順番に問合
せる、ずかできる
13幎8月2日金曜日
RDBMS (mysql)
SQLでの問合せに察しお結果を返す
SQLが効率的に曞かれおいるかは非垞に重芁
むンデックスをきちんず䜿えおいるか
適切なむンデックスが䜜成されおいるか
同時接続数が倚/少なすぎる、なども泚意
13幎8月2日金曜日
how to get high scores
serve static files by web server
enhance sql
tune parameters
inject caches
change architecture
13幎8月2日金曜日
serve static files
on web server
execute httpd, and serve static files on it
write configurations
change bench setting to access :80
13幎8月2日金曜日
enhance sql
create index
rewrite sql queries
use JOIN / remove JOIN ...
13幎8月2日金曜日
tune parameters
connections
connections, maxclients, keepalives
processes
application server processes
httpd process/threads
database configuration
13幎8月2日金曜日
inject caches
cache application server response
on reverse proxy
for GETs
13幎8月2日金曜日
change architecture
ex: change datastore from mysql to redis
ex: rewrite overall application
13幎8月2日金曜日
Enjoy ISUCON!
13幎8月2日金曜日

More Related Content

More from SATOSHI TAGOMORI

Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)SATOSHI TAGOMORI
 
Make Your Ruby Script Confusing
Make Your Ruby Script ConfusingMake Your Ruby Script Confusing
Make Your Ruby Script ConfusingSATOSHI TAGOMORI
 
Hijacking Ruby Syntax in Ruby
Hijacking Ruby Syntax in RubyHijacking Ruby Syntax in Ruby
Hijacking Ruby Syntax in RubySATOSHI TAGOMORI
 
Lock, Concurrency and Throughput of Exclusive Operations
Lock, Concurrency and Throughput of Exclusive OperationsLock, Concurrency and Throughput of Exclusive Operations
Lock, Concurrency and Throughput of Exclusive OperationsSATOSHI TAGOMORI
 
Data Processing and Ruby in the World
Data Processing and Ruby in the WorldData Processing and Ruby in the World
Data Processing and Ruby in the WorldSATOSHI TAGOMORI
 
Planet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: BigdamPlanet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: BigdamSATOSHI TAGOMORI
 
Technologies, Data Analytics Service and Enterprise Business
Technologies, Data Analytics Service and Enterprise BusinessTechnologies, Data Analytics Service and Enterprise Business
Technologies, Data Analytics Service and Enterprise BusinessSATOSHI TAGOMORI
 
Ruby and Distributed Storage Systems
Ruby and Distributed Storage SystemsRuby and Distributed Storage Systems
Ruby and Distributed Storage SystemsSATOSHI TAGOMORI
 
Perfect Norikra 2nd Season
Perfect Norikra 2nd SeasonPerfect Norikra 2nd Season
Perfect Norikra 2nd SeasonSATOSHI TAGOMORI
 
To Have Own Data Analytics Platform, Or NOT To
To Have Own Data Analytics Platform, Or NOT ToTo Have Own Data Analytics Platform, Or NOT To
To Have Own Data Analytics Platform, Or NOT ToSATOSHI TAGOMORI
 
The Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersThe Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersSATOSHI TAGOMORI
 
How To Write Middleware In Ruby
How To Write Middleware In RubyHow To Write Middleware In Ruby
How To Write Middleware In RubySATOSHI TAGOMORI
 
Modern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldModern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldSATOSHI TAGOMORI
 
Open Source Software, Distributed Systems, Database as a Cloud Service
Open Source Software, Distributed Systems, Database as a Cloud ServiceOpen Source Software, Distributed Systems, Database as a Cloud Service
Open Source Software, Distributed Systems, Database as a Cloud ServiceSATOSHI TAGOMORI
 
Fluentd Overview, Now and Then
Fluentd Overview, Now and ThenFluentd Overview, Now and Then
Fluentd Overview, Now and ThenSATOSHI TAGOMORI
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra PerfectSATOSHI TAGOMORI
 
Distributed Logging Architecture in Container Era
Distributed Logging Architecture in Container EraDistributed Logging Architecture in Container Era
Distributed Logging Architecture in Container EraSATOSHI TAGOMORI
 
Fighting API Compatibility On Fluentd Using "Black Magic"
Fighting API Compatibility On Fluentd Using "Black Magic"Fighting API Compatibility On Fluentd Using "Black Magic"
Fighting API Compatibility On Fluentd Using "Black Magic"SATOSHI TAGOMORI
 
Fluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API DetailsFluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API DetailsSATOSHI TAGOMORI
 

More from SATOSHI TAGOMORI (20)

Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
 
Make Your Ruby Script Confusing
Make Your Ruby Script ConfusingMake Your Ruby Script Confusing
Make Your Ruby Script Confusing
 
Hijacking Ruby Syntax in Ruby
Hijacking Ruby Syntax in RubyHijacking Ruby Syntax in Ruby
Hijacking Ruby Syntax in Ruby
 
Lock, Concurrency and Throughput of Exclusive Operations
Lock, Concurrency and Throughput of Exclusive OperationsLock, Concurrency and Throughput of Exclusive Operations
Lock, Concurrency and Throughput of Exclusive Operations
 
Data Processing and Ruby in the World
Data Processing and Ruby in the WorldData Processing and Ruby in the World
Data Processing and Ruby in the World
 
Planet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: BigdamPlanet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: Bigdam
 
Technologies, Data Analytics Service and Enterprise Business
Technologies, Data Analytics Service and Enterprise BusinessTechnologies, Data Analytics Service and Enterprise Business
Technologies, Data Analytics Service and Enterprise Business
 
Ruby and Distributed Storage Systems
Ruby and Distributed Storage SystemsRuby and Distributed Storage Systems
Ruby and Distributed Storage Systems
 
Perfect Norikra 2nd Season
Perfect Norikra 2nd SeasonPerfect Norikra 2nd Season
Perfect Norikra 2nd Season
 
Fluentd 101
Fluentd 101Fluentd 101
Fluentd 101
 
To Have Own Data Analytics Platform, Or NOT To
To Have Own Data Analytics Platform, Or NOT ToTo Have Own Data Analytics Platform, Or NOT To
To Have Own Data Analytics Platform, Or NOT To
 
The Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersThe Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and Containers
 
How To Write Middleware In Ruby
How To Write Middleware In RubyHow To Write Middleware In Ruby
How To Write Middleware In Ruby
 
Modern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldModern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real World
 
Open Source Software, Distributed Systems, Database as a Cloud Service
Open Source Software, Distributed Systems, Database as a Cloud ServiceOpen Source Software, Distributed Systems, Database as a Cloud Service
Open Source Software, Distributed Systems, Database as a Cloud Service
 
Fluentd Overview, Now and Then
Fluentd Overview, Now and ThenFluentd Overview, Now and Then
Fluentd Overview, Now and Then
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra Perfect
 
Distributed Logging Architecture in Container Era
Distributed Logging Architecture in Container EraDistributed Logging Architecture in Container Era
Distributed Logging Architecture in Container Era
 
Fighting API Compatibility On Fluentd Using "Black Magic"
Fighting API Compatibility On Fluentd Using "Black Magic"Fighting API Compatibility On Fluentd Using "Black Magic"
Fighting API Compatibility On Fluentd Using "Black Magic"
 
Fluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API DetailsFluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API Details
 

Isucon summer class_2013