بنقرة واحدة
go-db-tuning
Tune Go database/sql connection pool settings for optimal MySQL performance under ISUCON load
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Tune Go database/sql connection pool settings for optimal MySQL performance under ISUCON load
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
MCP tool reference — exec, benchmark_start, benchmark_status, note_write, etc. Use when: executing commands on VMs, running benchmarks, or recording findings
ISUCON13 contest manual — server topology, service management, benchmark execution, and rules. Use when: checking environment setup, running benchmarks, or understanding contest constraints
ISUPipe application manual — features, terms, constraints, and API specs. Use when: understanding the app domain, checking API behavior or MUST/MAY requirements
General strategy for identifying and adding missing database indexes in ISUCON web applications
General techniques for optimizing user icon/avatar image serving in ISUCON web applications
General techniques for identifying and fixing N+1 query problems in ISUCON web applications
استنادا إلى تصنيف SOC المهني
| name | go-db-tuning |
| description | Tune Go database/sql connection pool settings for optimal MySQL performance under ISUCON load |
Go の database/sql パッケージのデフォルト設定は ISUCON のような高負荷ワークロードに最適化されていない。接続プールの設定を調整する。
sql.Open() の直後に以下を追加:
db.SetMaxOpenConns(25) // 同時接続数の上限 (デフォルト: 無制限)
db.SetMaxIdleConns(25) // アイドル接続の保持数 (デフォルト: 2)
db.SetConnMaxLifetime(0) // 接続の最大寿命 (0 = 無制限)
db.SetConnMaxIdleTime(0) // アイドルタイムアウト (0 = 無制限)
| 設定 | デフォルト | 推奨値 | 理由 |
|---|---|---|---|
| MaxOpenConns | ∞ | 25 | MySQL のmax_connections を超えないようにする |
| MaxIdleConns | 2 | = MaxOpenConns | コネクション再作成のオーバーヘッドを回避 |
| ConnMaxLifetime | ∞ | 0 | ベンチ中は接続ローテーション不要 |
max_connections は 151max_connections / サーバー数 程度db.Prepare() を使っている場合、interpolateParams=true を DSN に追加すると round-trip を削減できる:
// 3 round-trip (Prepare → Execute → Close) → 1 round-trip に
dsn := "user:password@tcp(host:3306)/dbname?parseTime=true&interpolateParams=true"
# Go ソースで sql.Open を探す
grep -n 'sql.Open\|db.Set' /path/to/webapp/go/*.go