Skip to content

issue100: uWSGI 並列度・タイムアウトと PostgreSQL チューニングを環境変数で調整可能にする#102

Open
tichi73 wants to merge 2 commits into
developfrom
feature/issue100-tuning-env2
Open

issue100: uWSGI 並列度・タイムアウトと PostgreSQL チューニングを環境変数で調整可能にする#102
tichi73 wants to merge 2 commits into
developfrom
feature/issue100-tuning-env2

Conversation

@tichi73

@tichi73 tichi73 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

概要

高負荷時に Web ワーカ (uWSGI) が長時間占有され、画面や API 全体の応答が枯渇する事象を緩和するため、標準シングル構成の uWSGI ワーカ並列度・タイムアウト、PostgreSQL チューニング、nginx タイムアウトを環境変数で調整可能にします。いずれも既定値は従来挙動を維持するため、未指定なら現行と同じ動作です。

Fixes #100

変更内容

  • ke2/services/kompira.yml: uWSGI のワーカ並列度・タイムアウト系を環境変数化。他の env と同様に KOMPIRA_UWSGI_* → UWSGI_* → 既定 の多段フォールバックで解決する(コンテナへ渡すキー名 UWSGI_* は本体イメージの起動スクリプトが読む名前なので維持)。
    • UWSGI_PROCESSES (既定 5) / UWSGI_THREADS (1) / UWSGI_LISTEN (100) / UWSGI_HARAKIRI (0=無効) / UWSGI_THUNDER_LOCK (false)
    • 同時処理数 = UWSGI_PROCESSES × UWSGI_THREADS
  • ke2/services/nginx.yml, configs/nginx.conf: nginx→uWSGI の read/send タイムアウトを個別の環境変数で調整可能に。
    • KOMPIRA_NGINX_UWSGI_READ_TIMEOUT / KOMPIRA_NGINX_UWSGI_SEND_TIMEOUT(各既定 300 秒)
  • ke2/cloud/azureci/aci-deployment.json: 上記テンプレート (configs/nginx.conf) を使う ACI デプロイの nginx コンテナにも read/send タイムアウト env を既定 300 で設定(envsubst で未設定だと空/未展開となり nginx 起動に失敗するため)。
  • ke2/services/postgres.yml: PostgreSQL の主要チューニング項目を環境変数化。
    • POSTGRES_MAX_CONNECTIONS (100) / POSTGRES_SHARED_BUFFERS (128MB) / POSTGRES_EFFECTIVE_CACHE_SIZE (4GB) / POSTGRES_WORK_MEM (4MB) / POSTGRES_MAINTENANCE_WORK_MEM (64MB)
  • ke2/single/basic/README.md: これらの環境変数の説明を追記。
  • ChangeLog: (uWSGI ワーカ並列度・タイムアウトを compose / nginx 設定で調整可能にする #100) を追記。

注意

  • uWSGI の並列度 (processes × threads) を引き上げる場合は POSTGRES_MAX_CONNECTIONS も連動して引き上げてください。 不足すると "FATAL: sorry, too many clients already" で接続が拒否され、画面/API が 500 になります(目安: processes × threads + 余裕 ≦ max_connections)。
  • UWSGI_* は kompira 本体イメージの起動スクリプトが解釈する前提です。対応イメージと組み合わせて有効になります(既定値では従来と同一のため、未対応イメージでも動作は変わりません)。
  • 既定値はすべて従来挙動を維持しています。

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

高負荷時の Web ワーカ枯渇を緩和するため、標準シングル構成における uWSGI 並列度・タイムアウト、PostgreSQL の主要チューニング、nginx→uWSGI タイムアウトを環境変数で調整可能にする変更です(未指定時は従来挙動を維持する想定)。

Changes:

  • uWSGI の並列度/タイムアウト系パラメータを ke2/services/kompira.yml で環境変数化
  • nginx の uwsgi read/send timeout を ke2/services/nginx.yml + configs/nginx.conf で環境変数化
  • PostgreSQL の主要チューニング値を ke2/services/postgres.yml で環境変数化し、README/ChangeLog に追記

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ke2/single/basic/README.md 追加された調整用環境変数と注意点・例を追記
ke2/services/postgres.yml PostgreSQL チューニング項目を環境変数化し、起動コマンドへ反映
ke2/services/nginx.yml nginx テンプレート置換用に uwsgi timeout の既定値付き env を追加
ke2/services/kompira.yml uWSGI 並列度/タイムアウト系 env を多段フォールバックで追加
configs/nginx.conf uwsgi timeout を envsubst 変数参照に変更
ChangeLog #100 の変更点を追記

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread configs/nginx.conf

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread configs/nginx.conf Outdated
Comment thread ke2/single/basic/README.md Outdated
tichi73 added a commit that referenced this pull request Jul 2, 2026
PR #102 の Copilot 再レビュー指摘への対応。
- nginx.conf のコメントのファイルパスに ke2/ prefix を補い実パスに合わせた
- README の UWSGI_THREADS 説明で .wait/.recv をインラインコード表記にし可読性を改善

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tichi73 tichi73 requested a review from Copilot July 2, 2026 01:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread ke2/services/postgres.yml Outdated
Comment thread ke2/cloud/azureci/aci-deployment.json
tichi73 added a commit that referenced this pull request Jul 2, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tichi73 tichi73 requested a review from Copilot July 2, 2026 01:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

tichi73 and others added 2 commits July 2, 2026 10:50
高負荷時の Web ワーカ枯渇を緩和するため、標準シングル構成の uWSGI ワーカ並列度・
タイムアウト (UWSGI_*、他 env 同様 KOMPIRA_ 上書き対応)、nginx→uWSGI の read/send
タイムアウト (KOMPIRA_NGINX_UWSGI_READ/SEND_TIMEOUT)、PostgreSQL チューニング
(POSTGRES_*) を環境変数で調整可能にした。既定値は従来挙動を維持。configs/nginx.conf を
参照する ACI デプロイにも既定 300 を渡す。並列度を上げる場合は POSTGRES_MAX_CONNECTIONS
も連動が必要。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tichi73 tichi73 force-pushed the feature/issue100-tuning-env2 branch from f1acff0 to a5bee00 Compare July 2, 2026 01:51
@tichi73 tichi73 requested a review from Copilot July 2, 2026 01:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@tichi73 tichi73 marked this pull request as ready for review July 2, 2026 02:00
@tichi73 tichi73 requested a review from fixpoint-hasan July 2, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants