isucon10q's People
isucon10q's Issues
h2oチューニングに関するメモ
goチューニングに関するメモ書き
net/http/pprof
https://golang.org/pkg/net/http/pprof/
hs := http.NewServeMux()
hs.HandleFunc("/debug/pprof/", pprof.Index)
hs.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
hs.HandleFunc("/debug/pprof/profile", pprof.Profile)
hs.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
hs.HandleFunc("/debug/pprof/trace", pprof.Trace)
s := &http.Server{
Addr: ":6060",
Handler: hs,
}
go s.ListenAndServe()
$ go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30
## 上位20件の圧倒的に遅い関数
(pprof) top 20
## 子供も含めておそいやつ
(pprof) top -cum 20
database/sql
- UNIX socketの検討
- コネクションプールの調整
db.SetConnMaxLifetime(conf.ConnMaxLifetime) // poolするには65sとか
db.SetMaxOpenConns(conf.MaxOpenConns) // MaxIdleConns と同じかな
db.SetMaxIdleConns(conf.MaxIdleConns) // idleさせたほうがいいと思う
json
https://github.com/goccy/go-json の検討
環境変数
GOGC
cache
TODOリスト
やらないこと
- ミドルウェアの追加や変更
- ソロプレイなのでその時間はないので知らないのが来たら諦める。
- あり物で限界まで頑張る縛りで楽しむ
fasthttp
事前に~/.ssh/known_hostsからisuNを消しておく
当日まずやることリスト
1.5h
- 複数Serverの場合は /etc/hosts を設定して isu1, isu2, isu3,... でそれぞれつながるようにする
- visudo でsudoパスワードを不要に
- https://qiita.com/RyodoTanaka/items/e9b15d579d17651650b7
isucon ALL=NOPASSWD: ALL
- install.sh を実行してとりあえず使いそうなものを入れておく
- マニュアルを読み重要そうなところをまとめる
- ブラウザでデベロッパーツール見ながら動かしてurlと動作をざっくり把握する
- コードを持ってきてコミットする
- 初回完走
- ミドルウェアを書き出す
- ps aux すればいいか?
- スペック確認
- memory
free
cat /proc/cpuinfo
- memory
- アクセスログを出す #4 #5
- スローログを出す #3
- コードの流れを読む
- 修正の反映方法の確立
戦略を決める
0.5h
- スローログの解決はどのくらいかけるか?
- 静的ファイル系の問題はあるか?
- ミドルウェアのチューニング余地はどのくらいあるか?
- いつpprofするか
- アプリケーションの改善で自明かつすぐできるところはあるか?
改善に着手
5.0h
- アプリ改善
- ミドルウェアパラメータ調整
- 複数Server化などの構成変更
最終チェック
1.0h
ただし、この時点でスコアが出ていなかったら引き続き改善を頑張る
- 各種ログをoffにする
- 再起動試験
- ベンチガチャ
redisを入れる
https://github.com/go-redis/redis
apt-get update
apt-get -yV upgrade
apt -yV install redis-doc
apt -yV install redis-server
sudo service redis-server start
vi /etc/redis/redis.conf
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 775
sudo usermod -g isucon redis
# chmod /var/run/redis/
botを弾く
https://blog.mitsuto.com/nginx-useragent-deny
/ISUCONbot(-Mobile)?/
/ISUCONbot-Image//
/Mediapartners-ISUCON/
/ISUCONCoffee/
/ISUCONFeedSeeker(Beta)?/
/crawler (https://isucon.invalid/(support/faq/|help/jp/)/
/isubot/
/Isupider/
/Isupider(-image)?+/
/(bot|crawler|spider)(?:[-_ ./;@()]|$)/i
mysqlチューニングに関するメモ書き
https://qiita.com/mm-Genqiita/items/3ef91f6df6c15c620ec6
- innodb_buffer_pool_size ガツンと( 一般的な値は、5-6GB(8GB RAMの場合)、20-25GB(32GB RAM)、100-120GB(128GB RAM)。
- innodb_log_file_size 512M ? 4G
- max_connections 200 くらい?
スローログ
my.cnf
mysql --help | grep my.cnf
long_query_time=1
log-slow-queries=/var/log/slow.log
echo "SET GLOBAL slow_query_log=1, long_query_time=0.01, slow_query_log_file='/var/log/slow.log'" | mysql
Nginxチューニングに関するメモ書き
- exists /etc/nginx/nginx.conf
- keepalive
- gzip / gzipstatic
- cache-controll
- staticfile
- http2
listen 443 ssl http2;
- open_file_cache
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.