shellingford330 / isucon-kit Goto Github PK
View Code? Open in Web Editor NEWKit for ISUCON
Kit for ISUCON
/etc/nginx/nginx.conf
ファイルでlog_formatをalpが解析できるようなformatを指定http {
log_format json escape=json '{"time":"$time_local",'
'"host":"$remote_addr",'
'"forwardedfor":"$http_x_forwarded_for",'
'"req":"$request",'
'"status":"$status",'
'"method":"$request_method",'
'"uri":"$request_uri",'
'"body_bytes":$body_bytes_sent,'
'"referer":"$http_referer",'
'"ua":"$http_user_agent",'
'"request_time":$request_time,'
'"cache":"$upstream_http_x_cache",'
'"runtime":"$upstream_http_x_runtime",'
'"response_time":"$upstream_response_time",'
'"vhost":"$host"}';
access_log /var/log/nginx/access.log json
}
$ nginx -t
$ nginx -s reload
// or
$ systemctl reload nginx
クライアントから、まず変数を埋め込み可能な形のSQLを発行し、データベース側でそれを解析しキャッシュしておく。
そして、クライアントから変数のみを送ってSQLを実行する。同じSQLを何度も発行する場合、実行計画をキャッシュが効率があがり、SQLインジェクションも防ぐ。
しかし、Webアプリケーションでは発行するクエリの種類が多く、キャッシュが効率よく利用されない。
db, err := sql.Open("mysql", "isucon:@tcp(127.0.0.1:3306)/isuconp?interpolateParams=true")
issue-comment
イベントをトリガーにして、ログ解析を行う/etc/mysql/my.cnf
に以下の設定を追加
[mysqld]
slow_query_log=1
slow_query_log_file=/var/log/mysql/mysql-slow.log
long_query_time=0
log_queries_not_using_indexes=1
$ systemctl restart mysql
$ mysqldumpslow /var/log/mysql/mysql-slow.log
location /image/ {
root /home/isucon/private_isu/webapp/public/;
expires 1d;
try_files $uri @app;
}
location @app {
internal;
proxy_pass http://localhost:8080;
}
location ~ /(favicon\.ico|css/|js/|img/) {
root /home/isucon/private_isu/webapp/public/;
expires 1d;
}
あったら便利
pprof, alpやslow query出してる
1位の人達が作っているのが参考になる
PR 作成時に Origin の main ブランチのコードを自動 Rebase してくれる GitHub Actions を作成
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.