環境
- GCP(Compute Engine)
- 「Re:dash packaged by Bitnami」を使用してRedashのインスタンスを運用中
- Redash 8.0.0
事象
とあるクエリの結果をExcelダウンロードしようとすると、「502 Proxy Error」が発生した。
行数は15万行で、条件を絞って取得行数を減らした場合はダウンロードできる。
結論
Apache(Webサーバ)にきたものをGunicorn(アプリケーションサーバ)に流して処理する構成になっていたため、ApacheとGunicornのTimeoutを伸ばすことでダウンロードできるようになった。
対応手順
Gunicornは設定ファイルを見つけられなかったため、起動スクリプトにタイムアウト設定を仕込みました。
もっと良いやり方があればコメントで教えていただけると助かります。
Gunicorn
スクリプトの先頭にあるGunicorn起動用のコマンドに引数でタイムアウトを設定します。
GUNICORN_START="/opt/bitnami/apps/redash/htdocs/bin/run gunicorn -b 127.0.0.1:5000 --pid /opt/bitnami/apps/redash/logs/redash_gunicorn.pid --log-file /opt/bitnami/apps/redash/logs/redash_gunicorn.log --name redash -w 4 --max-requests 1000 redash.wsgi:app"
↓
GUNICORN_START="/opt/bitnami/apps/redash/htdocs/bin/run gunicorn -b 127.0.0.1:5000 -t 300 --pid /opt/bitnami/apps/redash/logs/redash_gunicorn.pid --log-file /opt/bitnami/apps/redash/logs/redash_gunicorn.log --name redash -w 4 --max-requests 1000 redash.wsgi:app"
Apache
既存の設定にはなかったので、適当なところにTimeoutを置きます。
# Timeout
Timeout 300
VMを再起動して完了です。
おまけ
Apacheのログは/opt/bitnami/apache2/logs/error_log
Gunicornのログは/opt/bitnami/apps/redash/logs/redash_gunicorn.log
で確認できます。