Heroku์ Django ์ ํ๋ฆฌ์ผ์ด์ ์์์ Gunicorn์ด ์คํ๋๋ ์์ฒญ ์๊ฐ ์ด๊ณผ์ ๊ด๋ จ๋ ๋งค์ฐ ์ด์ํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.
๋ณธ์ง์ ์ผ๋ก ์ด ๋ฌธ์ ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋งค์ฐ ์ค๋ ์คํ๋๋ ์์ฒญ์ด ์์ ๋ ๋ฐ์ํ์ฌ 30์ด ํ์ Heroku์ ํ๋ซํผ ์์ค ์์ฒญ ์๊ฐ ์ด๊ณผ๋ก ์ธํด ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ฐจ๋จ๋ฉ๋๋ค. ์ด๊ฒ์ ๊ทธ ์์ฒด๋ก ๋ฌธ์ ๊ฐ ์๋๋๋ค. ์ด๋ฌํ ์ฅ๊ธฐ ์คํ ์์ฒญ์ ์๊ฐ ์ด๊ณผ๋์ด์ผ ํฉ๋๋ค. ์ค์ ๋ฌธ์ ๋ ํ์ ์์ฒญ์์ ๋ฐ์ํฉ๋๋ค. ์ด ์ฅ๊ธฐ ์คํ ์์ฒญ _after_ ๋ฐ์ํ๋ ์์ฒญ์ด ์ฆ์ ๋ค์ ํ์์ Gunicorn ์ค๋ฅ๋ฅผ ๋ฐ์์ํฌ ๊ฐ๋ฅ์ฑ์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
[CRITICAL] WORKER TIMEOUT (pid:15)
์ด๋ก ์ธํด ๋ด๋ถ ์๋ฒ ์ค๋ฅ ํ์ด์ง๊ฐ ํด๋ผ์ด์ธํธ์ ์ฆ์ ๋ฐํ๋ฉ๋๋ค. ์ด ๋์์ ์ผ๊ด๋์ง ์์ต๋๋ค. ๋ค์ ์์ฒญ์ด ์ฑ๊ณตํ ๋๋ ์๊ณ ๊ทธ๋ ์ง ์์ ๋๋ ์์ต๋๋ค. ์ฅ๊ธฐ ์คํ ์์ฒญ์ ์ฒ๋ฆฌํ๋ ๋์ผํ Gunicorn ์์ ์๊ฐ ์์ฒญ์ ์ฒ๋ฆฌํ๋ ๊ฒฝ์ฐ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์์๊น ํ๋ ์์ฌ์ด ๋ญ๋๋ค.
๋ค์๊ณผ ๊ฐ์ด Django์์ ์ง์ Gunicorn์ ์คํํ๊ณ ์์ต๋๋ค.
python app/manage.py run_gunicorn -b 0.0.0.0:$PORT -w 2 -k gevent
worker_connections ๋ฐ max_requests์ ๊ฐ์ ๊ธฐํ ๊ด๋ จ ๊ตฌ์ฑ ๋งค๊ฐ๋ณ์๋ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ค์ ๋ฉ๋๋ค. ๊ทธ๋ฌ๋ ์ฐ๋ฆฌ๋ ์ด๋ฌํ ์ค์ ๊ณผ ์์ ์ ์๋ฅผ ๋ณ๊ฒฝํ์ฌ ์คํํ์ง๋ง ์๋ํ ๋ชจ๋ ๊ฒฝ์ฐ์ ์์์ ์ค๋ช ํ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ํ์ฌ Gunicorn ๋ฒ์ ์ 0.14.6์ด๋ฉฐ ๋ฌธ์ ์ ์์ธ์ธ ๊ฒฝ์ฐ 17.5๋ก ์ ๊ทธ๋ ์ด๋ํ ํ ๋กค๋ฐฑ๋์์ต๋๋ค. ๋ถํํ๋ ๋ ๋ฒ์ ์์ ๋์ผํ ๋์์ด ๋ฐ์ํฉ๋๋ค.
์ด ๋ฌธ์ ์ ๊ทผ๋ณธ ์์ธ์ ์ดํดํ๋ ๋ฐ ํฐ ์ด๋ ค์์ ๊ฒช๊ณ ์์ต๋๋ค. ์์ ๋งํฌ๋ Heroku ๋ฌธ์์์:
๋ผ์ฐํฐ๊ฐ ํด๋ผ์ด์ธํธ์ ์๋ต์ ๋ฐํํ๋ ๋์ ์์ฉ ํ๋ก๊ทธ๋จ์ ์ฒ๋ฆฌ ์ค์ธ ์์ฒญ์ด ์๊ฐ ์ ํ์ ๋๋ฌํ์์ ์์ง ๋ชปํ๋ฉฐ ์์ฉ ํ๋ก๊ทธ๋จ์ ๊ณ์ํด์ ์์ฒญ์ ๋ํด ์์ ํฉ๋๋ค.
์ด๊ฒ์ ์๋ ์ฅ๊ธฐ ์คํ ์์ฒญ์ด ํด๋ผ์ด์ธํธ์ ๊ด์ ์์ ์๊ฐ ์ด๊ณผ๋์๋ค๋ ์ฌ์ค์๋ ๋ถ๊ตฌํ๊ณ Gunicorn ์์ ์๊ฐ ์ฌ์ ํ ์์ฒญ์ ์ฒ๋ฆฌํ๊ณ ์์์ ์๋ฏธํ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค. ๋๋ฅผ ๋นํฉํ๊ฒ ๋ง๋๋ ๊ฒ์ ์์ ์๊ฐ gevent๋ฅผ ์ฌ์ฉํ๊ณ ๋ฐ๋ผ์ ๋น๋๊ธฐ ์ค๋ ๋๋ฅผ ์ฌ์ฉํ์ฌ ์์ฒญ์ ์ฒ๋ฆฌํ๋ค๋ ์ ์ ๊ฐ์ํ ๋ ์ด๊ฒ์ด ์ด๋ป๊ฒ ์์ ์ ์๊ฐ ์ด๊ณผ๋ฅผ ์ฆ์ ๋ฐ์์ํค๋ ์๋ก์ด ํ์ ์์ฒญ์ ๋ฐ์์ํฌ ๊ฒ์ธ์ง์ ๋๋ค. ๋๋ ์ฒซ ๋ฒ์งธ ์ฅ๊ธฐ ์์ฒญ์ด ๋ ๊ฒ์ด๋ผ๊ณ ์๊ฐํ์ ๊ฒ์ ๋๋ค.
์ฅ๊ธฐ ์คํ ์์ฒญ์ด PostgreSQL ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ฐ๊ฒฐ๋๊ณ ์ฌ๋ฌ ๋ณต์กํ ์ฟผ๋ฆฌ๋ฅผ ์ํํ๋ค๋ ์ ์ ์ธ๊ธํ ๊ฐ์น๊ฐ ์์ต๋๋ค. ์ถฉ๋์ DB์ ์ธํฐํ์ด์คํ๋ ๋์ Heroku ๋๋ถ์ ์ฅ๊ธฐ ์คํ ์ฐ๊ฒฐ ์๊ฐ์ด ์ด๊ณผ๋ ํ์๋ง ๋ฐ์ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ํ ์คํธ ์๋ฒ์์ ๋ ๊ฐ์ ๊ฐ๋ณ ๋ณด๊ธฐ๋ฅผ ๋ง๋ค์ด ํ ์คํธํ์ต๋๋ค. ๊ทธ ์ค ํ๋๋ Heroku ์๊ฐ ์ด๊ณผ์ ๋๋ฌํ ๋๊น์ง ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ํด ๊ธด ์ฟผ๋ฆฌ๋ฅผ ์คํํ๊ณ ๋ค๋ฅธ ํ๋๋ Heroku ์๊ฐ ์ด๊ณผ๋ฅผ ์์ฑํ๊ธฐ ์ํด 30์ด ํ์๋ฅผ ๋จ์ํ ๊ธฐ๋ค๋ฆฝ๋๋ค. ์ด์ ๋ณด๊ธฐ๋ ๋ค์ ์์ฒญ์์ Gunicorn ์์ ์ ์๊ฐ ์ด๊ณผ๋ฅผ ์ ๋ฐํ ์ ์์์ง๋ง '์ ์๊ธฐ' ๋ณด๊ธฐ๋ ๊ทธ๋ ์ง ์์์ต๋๋ค.
๋๊ตฌ๋ ์ง ์ด ๋ฌธ์ ๋ฅผ ์ผ์ผํค๋ ๊ธฐ๋ณธ ๋์์ ๋ํ ํต์ฐฐ๋ ฅ์ด ์์ผ๋ฉด ํ์์ ์ผ ๊ฒ์ ๋๋ค. ๋ฌธ์ ๋ฅผ ์ง๋จํ๋ ๋ฐ ๋์์ด ๋ ์ ์๋ ์ถ๊ฐ ์ ๋ณด๊ฐ ์์ผ๋ฉด ์๋ ค์ฃผ์ญ์์ค. ์ด๊ฒ์ด ๊ทธ๋ฌํ ๋ฌธ์ ๋ฅผ ์ฒ๋ฆฌํ๋ ์ฌ๋ฐ๋ฅธ ๋ฐฉ๋ฒ์ด๋ฉฐ ์ด์ ์ ์ ๊ธฐ/์ฒ๋ฆฌ๋์ง ์์์ผ๋ฉด ํฉ๋๋ค.
@Jwpe ์ฐ์ํ ๋ฒ๊ทธ ๋ณด๊ณ ์.
๊ฐ์ฅ ๋จผ์ ์ดํด๋ณผ ๊ฒ์ ์นํ๊ฒฝ PostgreSQL ๋๋ผ์ด๋ฒ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์ ๋๋ค. ์ด ์์ ์ ์ฌ๋ฐ๋ฅด๊ฒ ์ํํ๋ ค๋ฉด ์์ญ์ด ํจ์น์ ํจ๊ป ์ฌ์ฉํด์ผ ํ๋ ํน์ ๋ฒ์ ์ด ์์์ต๋๋ค. ์ง๊ธ ์ํฉ์ ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ถ์ฌ ๋ฃ์ ์๊ฐ ์ด๊ณผ๋ ์์ ์ ์๊ฐ ์ด๊ณผ์ด๋ฉฐ ๊ธฐ๋ณธ์ ์ผ๋ก "๊ทธ๋ฆฐ๋ ์ด $timeout ์ด ์ด์ ๋์ ์๋ณดํ์ง ์์์ต๋๋ค"๋ก ์์ฝ๋๋ ๋น๋๊ธฐ ์์ ์ ์ค ํ๋์ ๋๋ค. ์ฅ๊ธฐ ์คํ PostgreSQL ์์ฒญ์ ๋ํด ์ค๋ช ํ๊ณ ์๋ค๋ ์ ์ ๊ฐ์ํ ๋ ๊ฐ์ฅ ๋จผ์ ์กฐ์ฌํ ์์น์ ๋๋ค.
@davisp ์ด์ ๋ํ ์ ์ํ ๋ต๋ณ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!
๊ทํ์ ํฌ์ธํฐ๋ฅผ ๋ฐ๋ผ Django ์ฑ์ Postgres์ ์ฐ๊ฒฐํ๋ ๋ฐ ์ฌ์ฉํ๋ psycopg2 ์ด๋ํฐ๋ฅผ ์ดํด๋ณด๊ณ ๋ค์๊ณผ ๊ฐ์ ๋ฌธ์ ์น์ ์ ๋ฐ๊ฒฌ
๊ฒฝ๊ณ : Psycopg ์ฐ๊ฒฐ์ ๋ น์ ์ค๋ ๋๋ก๋ถํฐ ์์ ํ์ง ์์ผ๋ฉฐ ๋ค๋ฅธ ๋ น์ ์ค๋ ๋์์ ๋์์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ค๋ ๋๋น ํ๋์ ์ปค์๋ฅผ ์ฌ์ฉํ์ฌ ํ ๋ฒ์ ๋ ์ด์์ ๋ช ๋ น์ ์คํํ๋ ค๊ณ ํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค(๋๋ 2.4.2 ์ด์ ๋ฒ์ ์์๋ ๊ต์ฐฉ ์ํ).
๋ฐ๋ผ์ ํ๋ก๊ทธ๋๋จธ๋ ์ฝ๋ฃจํด ๊ฐ์ ์ฐ๊ฒฐ ๊ณต์ ๋ฅผ ํผํ๊ฑฐ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์นํ์ ์ธ ์ ๊ธ์ ์ฌ์ฉํ์ฌ ๊ณต์ ์ฐ๊ฒฐ(์: ํ๋ง)์ ๋๊ธฐํํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
์ฆ, psycopg2๋ ๋ น์ ์ค๋ ๋๋ฅผ ์ข์ํ์ง ์์ต๋๋ค. ์ฐ๋ฆฌ๊ฐ ๋ฐ์ํ ๋์์ ๊ธฐ๋ฐ์ผ๋ก ์ด๊ฒ์ด ์ค๋ฅ์ ์์ธ์ด๋ผ๊ณ ์ถ์ธกํ ์ ์์ต๋๋ค. psycopg ๋ฌธ์์ ๋ฐ๋ฅด๋ฉด ์ด ๋ฌธ์ ๋ฅผ ์ฒ๋ฆฌํ๋ ์ ์๋ ๋ฐฉ๋ฒ์ ์ฝ๋ฃจํด์ ๋ํ psycopg ์ง์์ ๊ฐ๋ฅํ๊ฒ ํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค. ๊ถ์ฅ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ psycogreen ์ ๋๋ค.
psycogreen ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ ํ ์คํธ ์๋ฒ์์ ๋ฌธ์ ๋ฅผ ์ฌํํ๊ณ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๋์ง ํ์ธํ๊ฒ ์ต๋๋ค. ๋น๊ต์ ๋นจ๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ํ ์ ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
@Jwpe ๊ธฐ์ตํ๊ณ ์๋ ํ ๊ฐ๋ค์.
@benoitc ์๋ง๋ Gunicorn ๋ฌธ์ ์ด๋๊ฐ์์ ์ด๊ฒ์ ๋ถ๋ฌ์ผ ํ ๊น์? ๊ฐ์ฅ ์ข์ ์ฅ์๊ฐ ์ด๋์ธ์ง๋ ํ์คํ์ง ์์ต๋๋ค.
@davisp FAQ ์น์ ์ ์์ต๋๊น?
hmppff๋ ์ด๋ฏธ ์กด์ฌํ๋ค๋ ์ฌ์ค์ ์์ด๋ฒ๋ ธ์ต๋๋ค(http://docs.gunicorn.org/en/latest/faq.html). ๊ทธ๋์ ๊ฑฐ๊ธฐ์์ "๋ฌธ์ ํด๊ฒฐ" ์น์ ์ ๋ํ ๋งํฌ๋ฅผ ๊ฐ์ง ์ ์์ต๋๋ค. ํ์คํ์ง ์์ง๋ง ์ด๋ฌํ ์น์ ์์ virtualenv ๋ฐ ๊ธฐํ ํธ๋ฆญ์ ๋ํ ์ ๋ณด๋ฅผ ์ด๋ํ ์๋ ์์ต๋๋ค.
๊ฒฝ๊ณ ๋๋ "๋ น์ ์ค๋ ๋์ ๋ํ ์ฐธ๊ณ ์ฌํญ" ํ์ด์ง์ผ ์ ์์ต๋๋ค. ์ํผ ํ๋ ์ฑ์ด ์๋๋๋ค.
๋๋ gevent ์์
์์ ๋ค๋ฅธ ์์
์์ ํจ๊ป gunicorn์ ์คํํ๋ Heroku์์ ๊ฑฐ์ ๋์ผํ ๋์์ ๋ณด๊ณ ์์๊ธฐ ๋๋ฌธ์ ์ด ์ค๋ ๋์์ ๊ถ์ฅํ๋ ๋๋ก ๋๊ธฐ ์์
์๋ก ์ ํํ์ง๋ง ์ฌ์ ํ ๊ธฐ๋ณธ์ ์ผ๋ก ๋์ผํ ์ฌ๊ฐํ ๋ฌธ์ ๋ฅผ ๋ณด๊ณ ์์์ต๋๋ค. H12 30์ด Heroku ์ปท์คํ๋ฅผ ์ป์ ๋ค์ ์ ์ฒด dyno๋ฅผ ์ฌ์ค์ ํ ๋๊น์ง(๋๋ก๋ ํ ์๊ฐ ์ด์ ๋๋ ์ต๋ ์์ฒญ์ ๋๋ฌํ ๋๊น์ง) H12 ๋ฐ [CRITICAL] Worker Timeout
์ค๋ฅ๋ฅผ ๋ฐ๋ณตํ์ต๋๋ค. ๊ทธ๋์ ์ ๋ gunicorn ์๊ฐ ์ด๊ณผ๋ฅผ 28์ด๋ก ์กฐ์ ํ์ฌ Heroku๊ฐ ๊ทธ๊ฒ์ ๋๊ธฐ ์ ์ ์๊ฐ ์ด๊ณผ๋๋๋ก ํ์ต๋๋ค. ๋์ผํ(๋๋ ๋งค์ฐ ์ ์ฌํ) ๋ฌธ์ ๊ฐ ํ๋ฃจ์ ํ ๋ฒ ๋๋ ๋ ๋ฒ ๋ฐ์ํ๊ณ ๋ง์คํฐ ํ๋ก์ธ์ค๊ฐ ๋ค์ ์์๋ ๋๊น์ง ์ง์๋ฉ๋๋ค. ์ด๋ฒ์๋ gunicorn์ด ๋๊ธฐ ๋๋ฌธ์ H13(์ฐ๊ฒฐ ๋ซํ)์ผ๋ก ์์ํฉ๋๋ค. ์ด ์๊ฐ ๋์ ํธ๋ํฝ์ด ํฌ๊ฒ ๊ธ์ฆํ์ง ์์ต๋๋ค.
๋ค์์ ํ์ฌ procfile ํญ๋ชฉ์ ๋๋ค.
web: newrelic-admin run-program gunicorn publisher.wsgi -b 0.0.0.0:$PORT -w 4 --max-requests 1000 --timeout 28 --preload
์ผ๋ จ์ ์ด๋ฒคํธ ์ธ๋ถ์ ๋ณด:
๋จผ์ , ์ ๋ง ๊ธด(5์ด ์ด์) ์๊ฐ์ด ๊ฑธ๋ฆฌ๋ ๋ช ๊ฐ์ง ์์ฒญ์ ๋ฐ์ ๋ค์ H12 ์๊ฐ ์ด๊ณผ(์์ ์ ์๊ฐ ์ด๊ณผ๋ก ์ธํด ๋๊น)์ ํจ๊ป ์์ฒญ์ด ์คํจํ๊ณ ๋ช ๊ฐ์ง ์ถ๊ฐ ์์ฒญ์ด ์๋ฃ๋์ง๋ง ์์ธ์ ์ผ๋ก ๊ธด ์๊ฐ(20 ์ด). ๊ทธ๋๋ถํฐ ๋ค์ด๋ ธ๋ฅผ ๋ค์ ์์ํ ๋๊น์ง ์์ํ H11 30์ด heroku ์ปท์คํ์ ๋๋ค.
์ฐ๋ฆฌ๋ (python/django๋ฅผ ์คํํ๋) ์น์๋ฒ๋ก gunicorn(v 18.0)์ ์ฌ์ฉํฉ๋๋ค.
๋ค์ดํ์๊ณผ ์์ฒญ๋๊ฒ ๋์ด๋ ์์ฒญ ๋๊ธฐ์ด ์๊ฐ์ ๋ณด์ฌ์ฃผ์ง๋ง ๋ค๋ฅธ ํต์ฐฐ๋ ฅ์ ์ ๊ณตํ์ง ์๋ newrelic์ ์คํํฉ๋๋ค. NR์์ ๋ณผ ์ ์๋ ์ฒ๋ฆฌ๋์ด๋ ๊ธฐํ ๋น์ ์์ ์ธ ์กฐ๊ฑด์ ์คํ์ดํฌ๋ ์์์ต๋๋ค. ์ฐ๋ฆฌ๋ ๋ก๊ทธ ์ฒ๋ฆฌ ๋ฐ ์ค๋ฅ ์ด๋ฉ์ผ ๋ฐ์ก์ ์ํด ํ์ดํผํธ๋ ์ผ์ ์ฌ์ฉํฉ๋๋ค.
Oct 15 15:08:53 nutrislice-stockton heroku/router: at=info method=GET path=/marketingtools/api/slides/?format=json-p&callback=_jqjsp&_1381871332239= host=oldham.nutrislice.com fwd="74.138.24.95" dyno=web.2 connect=15ms service=216ms status=200 bytes=21
Oct 15 15:08:54 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/menutypes/?format=json-p&callback=_jqjsp&_1381871332232= host=oldham.nutrislice.com fwd="74.138.24.95" dyno=web.2 connect=2ms service=90ms status=200 bytes=231
Oct 15 15:08:56 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/schools/?format=json-p&callback=_jqjsp&_1381871323514= host=oldham.nutrislice.com fwd="74.138.24.95" dyno=web.2 connect=3ms service=94ms status=200 bytes=5986
Oct 15 15:09:03 nutrislice-stockton heroku/router: at=info method=HEAD path=/heartbeat/ host=stockton.nutrislice.com fwd="54.247.188.179" dyno=web.2 connect=3ms service=23ms status=200 bytes=0
Oct 15 15:09:13 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/settings/?format=json-p&callback=_jqjsp&_1381871237946= host=pcsb.nutrislice.com fwd="66.87.110.127" dyno=web.2 connect=5ms service=166ms status=200 bytes=468
Oct 15 15:09:20 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/settings/?format=json-p&callback=_jqjsp&_1381871323611= host=oldham.nutrislice.com fwd="74.138.24.95" dyno=web.2 connect=6ms service=183ms status=200 bytes=453
Oct 15 15:09:40 nutrislice-stockton heroku/router: at=info method=GET path=/ host=nps.nutrislice.com fwd="74.190.240.28" dyno=web.2 connect=1ms service=260ms status=200 bytes=35951
Oct 15 15:09:55 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/api/list/school-menu-profile/87/menu-type/43/?format=json-p&callback=jQuery18008709754704032093_1381871379465&_=1381871393589 host=nps.nutrislice.com fwd="74.190.240.28" dyno=web.2 connect=15ms service=129ms status=200 bytes=400
Oct 15 15:09:55 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/api/list/school-menu-profile/306/menu-type/187/?format=json-p&callback=jQuery180013075259909965098_1381873891397&_=1381873896600 host=sdhc.nutrislice.com fwd="72.186.96.121" dyno=web.2 connect=2ms service=33ms status=200 bytes=486
Oct 15 15:10:00 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/186/?smp=257 host=coppellisd.nutrislice.com fwd="76.199.114.157" dyno=web.2 connect=7ms service=103ms status=200 bytes=323
Oct 15 15:10:00 nutrislice-stockton app/web.2: INFO http://stockton.nutrislice.com/heartbeat/ Pinged from IP: 10.190.159.205 -- AGENT: NewRelicPinger/1.0 (269661)
Oct 15 15:10:00 nutrislice-stockton heroku/router: at=info method=HEAD path=/heartbeat/ host=stockton.nutrislice.com fwd="50.112.95.211" dyno=web.2 connect=1ms service=10ms status=200 bytes=0
Oct 15 15:10:09 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/239/?smp=341 host=edenpr.nutrislice.com fwd="75.73.177.139" dyno=web.2 connect=8ms service=334ms status=200 bytes=277
Oct 15 15:10:16 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/395/?smp=306 host=sdhc.nutrislice.com fwd="72.186.96.121" dyno=web.2 connect=1ms service=96ms status=200 bytes=245
Oct 15 15:10:20 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/391/?smp=305 host=sdhc.nutrislice.com fwd="173.170.34.126" dyno=web.2 connect=32ms service=5207ms status=200 bytes=290
Oct 15 15:10:22 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/350/?smp=305 host=sdhc.nutrislice.com fwd="173.170.34.126" dyno=web.2 connect=60ms service=7676ms status=200 bytes=1147
Oct 15 15:10:31 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/258/?smp=341 host=edenpr.nutrislice.com fwd="75.73.177.139" dyno=web.2 connect=42ms service=517ms status=200 bytes=26974
Oct 15 15:10:43 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/schools/?format=json-p&callback=_jqjsp&_1381871432885= host=ocps.nutrislice.com fwd="71.47.21.97" dyno=web.2 connect=1490ms service=9883ms status=200 bytes=1565
Oct 15 15:10:52 nutrislice-stockton heroku/router: at=error code=H13 desc="Connection closed without response" method=GET path=/ host=jordandistrict.nutrislice.com fwd="71.199.48.37" dyno=web.2 connect=1959ms service=29230ms status=503 bytes=0
Oct 15 15:10:52 nutrislice-stockton app/web.2: 2013-10-15 21:10:50 [2] [CRITICAL] WORKER TIMEOUT (pid:12)
Oct 15 15:10:52 nutrislice-stockton app/web.2: 2013-10-15 21:10:50 [2] [CRITICAL] WORKER TIMEOUT (pid:12)
Oct 15 15:10:52 nutrislice-stockton app/web.2: 2013-10-15 21:10:50 [26] [INFO] Booting worker with pid: 26
Oct 15 15:10:52 nutrislice-stockton app/web.2: 2013-10-15 21:10:50,930 (26/MainThread) newrelic.core.agent INFO - New Relic Python Agent (2.0.0.1)
Oct 15 15:10:54 nutrislice-stockton heroku/router: at=info method=GET path=/surveys/api/activesurveycount/?format=json-p&callback=_jqjsp&_1381871433429= host=henrico.nutrislice.com fwd="96.248.5.53" dyno=web.2 connect=1181ms service=20074ms status=200 bytes=32
Oct 15 15:10:55 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/schooltypes/?format=json-p&callback=_jqjsp&_1381871433374= host=henrico.nutrislice.com fwd="96.248.5.53" dyno=web.2 connect=1136ms service=20393ms status=200 bytes=142
Oct 15 15:11:01 nutrislice-stockton app/web.2: using heroku production settings
Oct 15 15:11:01 nutrislice-stockton app/web.2: WARNING /app/.heroku/python/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
Oct 15 15:11:01 nutrislice-stockton app/web.2: DeprecationWarning)
Oct 15 15:11:01 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/settings/?format=json-p&callback=_jqjsp&_1381871432922= host=ocps.nutrislice.com fwd="71.47.21.97" dyno=web.2 connect=1435ms service=23198ms status=200 bytes=486
Oct 15 15:11:03 nutrislice-stockton app/web.2: WARNING /app/.heroku/python/lib/python2.7/site-packages/django/conf/urls/defaults.py:3: DeprecationWarning: django.conf.urls.defaults is deprecated; use django.conf.urls instead
Oct 15 15:11:03 nutrislice-stockton app/web.2: DeprecationWarning)
Oct 15 15:11:05 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/schooltypes/?format=json-p&callback=_jqjsp&_1381871443300= host=martinschools.nutrislice.com fwd="99.114.229.202" dyno=web.2 connect=1089ms service=20040ms status=200 bytes=268
Oct 15 15:11:10 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/weeks/school-menu-profile/135/menu-type/63/2013/10/14/?format=json-p&callback=_jqjsp&_1381871439548= host=henrico.nutrislice.com fwd="96.248.5.53" dyno=web.2 connect=1018ms service=30001ms status=503 bytes=0
Oct 15 15:11:15 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/sales/?format=json-p&callback=_jqjsp&_1381871443267= host=martinschools.nutrislice.com fwd="99.114.229.202" dyno=web.2 connect=1096ms service=30001ms status=503 bytes=0
Oct 15 15:11:15 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/schools/?format=json-p&callback=_jqjsp&_1381871443296= host=martinschools.nutrislice.com fwd="99.114.229.202" dyno=web.2 connect=1108ms service=30000ms status=503 bytes=0
Oct 15 15:11:23 nutrislice-stockton heroku/router: at=info method=GET path=/menu/api/weeks/school-menu-profile/48/menu-type/21/2013/10/14/?format=json-p&callback=_jqjsp&_1381871449451= host=martinschools.nutrislice.com fwd="99.114.229.202" dyno=web.2 connect=1114ms service=31756ms status=200 bytes=48771
Oct 15 15:11:26 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/sales/?format=json-p&callback=_jqjsp&_1381871455129= host=pcsb.nutrislice.com fwd="66.87.110.127" dyno=web.2 connect=990ms service=30001ms status=503 bytes=0
Oct 15 15:11:26 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/schools/?format=json-p&callback=_jqjsp&_1381871455291= host=pcsb.nutrislice.com fwd="66.87.110.127" dyno=web.2 connect=1028ms service=30008ms status=503 bytes=0
Oct 15 15:11:31 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menuwidgets/179/?smp=6 host=cusdnutrition.nutrislice.com fwd="68.99.246.16" dyno=web.2 connect=2492ms service=30000ms status=503 bytes=0
Oct 15 15:11:32 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menuwidgets/192/?smp=6 host=cusdnutrition.nutrislice.com fwd="68.99.246.16" dyno=web.2 connect=2713ms service=30003ms status=503 bytes=0
Oct 15 15:11:39 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/ host=hebisd.nutrislice.com fwd="38.107.226.1" dyno=web.2 connect=2115ms service=30001ms status=503 bytes=0
Oct 15 15:11:45 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/weeks/school-menu-profile/44/menu-type/19/2013/10/14/?format=json-p&callback=_jqjsp&_1381871472583= host=pcsb.nutrislice.com fwd="66.87.110.127" dyno=web.2 connect=2168ms service=30000ms status=503 bytes=0
Oct 15 15:11:48 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/marketingtools/api/active-announcements/?format=json-p&callback=_jqjsp&_1381871476287= host=sdhc.nutrislice.com fwd="65.34.72.116" dyno=web.2 connect=1927ms service=30000ms status=503 bytes=0
Oct 15 15:11:48 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/surveys/api/activesurveycount/?format=json-p&callback=_jqjsp&_1381871476543= host=sdhc.nutrislice.com fwd="65.34.72.116" dyno=web.2 connect=2117ms service=30000ms status=503 bytes=0
Oct 15 15:11:48 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/schooltypes/?format=json-p&callback=_jqjsp&_1381871476481= host=sdhc.nutrislice.com fwd="65.34.72.116" dyno=web.2 connect=2111ms service=30009ms status=503 bytes=0
Oct 15 15:11:50 nutrislice-stockton app/web.2: 2013-10-15 15:11:32,597 (26/NR-Activate-Session/nutrislice-stockton) newrelic.core.data_collector INFO - Successfully registered New Relic Python agent where app_name='nutrislice-stockton', pid=26, redirect_host='collector-2.newrelic.com' and agent_run_id=474482914, in 40.26 seconds.
Oct 15 15:11:50 nutrislice-stockton app/web.2: INFO Successfully registered New Relic Python agent where app_name='nutrislice-stockton', pid=26, redirect_host='collector-2.newrelic.com' and agent_run_id=474482914, in 40.26 seconds.
Oct 15 15:11:52 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/marketingtools/api/active-announcements/?format=json-p&callback=_jqjsp&_1381871480294= host=sdhc.nutrislice.com fwd="65.34.72.116" dyno=web.2 connect=1689ms service=30006ms status=503 bytes=0
Oct 15 15:11:55 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/settings/?format=json-p&callback=_jqjsp&_1381871482566= host=henrico.nutrislice.com fwd="72.84.233.45" dyno=web.2 connect=2067ms service=30004ms status=503 bytes=0
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:41 [2] [CRITICAL] WORKER TIMEOUT (pid:26)
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:41 [2] [CRITICAL] WORKER TIMEOUT (pid:26)
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:41 [29] [INFO] Booting worker with pid: 29
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:41,067 (29/MainThread) newrelic.core.agent INFO - New Relic Python Agent (2.0.0.1)
Oct 15 15:11:57 nutrislice-stockton app/web.2: using heroku production settings
Oct 15 15:11:57 nutrislice-stockton app/web.2: WARNING /app/.heroku/python/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
Oct 15 15:11:57 nutrislice-stockton app/web.2: DeprecationWarning)
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:44 [2] [CRITICAL] WORKER TIMEOUT (pid:23)
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:44 [2] [CRITICAL] WORKER TIMEOUT (pid:23)
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:44 [32] [INFO] Booting worker with pid: 32
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:44,154 (32/MainThread) newrelic.core.agent INFO - New Relic Python Agent (2.0.0.1)
Oct 15 15:11:57 nutrislice-stockton app/web.2: using heroku production settings
Oct 15 15:11:57 nutrislice-stockton app/web.2: WARNING /app/.heroku/python/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
Oct 15 15:11:57 nutrislice-stockton app/web.2: DeprecationWarning)
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:48 [2] [CRITICAL] WORKER TIMEOUT (pid:14)
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:48 [2] [CRITICAL] WORKER TIMEOUT (pid:14)
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:48 [35] [INFO] Booting worker with pid: 35
Oct 15 15:11:57 nutrislice-stockton app/web.2: 2013-10-15 21:11:48,273 (35/MainThread) newrelic.core.agent INFO - New Relic Python Agent (2.0.0.1)
Oct 15 15:11:57 nutrislice-stockton app/web.2: using heroku production settings
Oct 15 15:11:57 nutrislice-stockton app/web.2: WARNING /app/.heroku/python/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
Oct 15 15:11:57 nutrislice-stockton app/web.2: DeprecationWarning)
Oct 15 15:11:57 nutrislice-stockton heroku/router: at=info method=GET path=/menuwidgets/353/?smp=306 host=sdhc.nutrislice.com fwd="72.186.96.121" dyno=web.2 connect=21ms service=76ms status=200 bytes=255
Oct 15 15:12:00 nutrislice-stockton app/web.2: 2013-10-15 21:11:54 [2] [CRITICAL] WORKER TIMEOUT (pid:13)
Oct 15 15:12:00 nutrislice-stockton app/web.2: 2013-10-15 21:11:54 [2] [CRITICAL] WORKER TIMEOUT (pid:13)
Oct 15 15:12:00 nutrislice-stockton app/web.2: 2013-10-15 21:11:54 [38] [INFO] Booting worker with pid: 38
Oct 15 15:12:00 nutrislice-stockton app/web.2: 2013-10-15 21:11:54,388 (38/MainThread) newrelic.core.agent INFO - New Relic Python Agent (2.0.0.1)
Oct 15 15:12:00 nutrislice-stockton app/web.2: using heroku production settings
Oct 15 15:12:01 nutrislice-stockton app/web.2: WARNING /app/.heroku/python/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
Oct 15 15:12:01 nutrislice-stockton app/web.2: DeprecationWarning)
Oct 15 15:12:02 nutrislice-stockton app/web.2: WARNING /app/.heroku/python/lib/python2.7/site-packages/django/conf/urls/defaults.py:3: DeprecationWarning: django.conf.urls.defaults is deprecated; use django.conf.urls instead
Oct 15 15:12:02 nutrislice-stockton app/web.2: DeprecationWarning)
Oct 15 15:12:03 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menuwidgets/353/?smp=306 host=sdhc.nutrislice.com fwd="108.9.154.78" dyno=web.2 connect=3650ms service=30006ms status=503 bytes=0
Oct 15 15:12:03 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menuwidgets/395/?smp=306 host=sdhc.nutrislice.com fwd="108.9.154.78" dyno=web.2 connect=3581ms service=30006ms status=503 bytes=0
Oct 15 15:12:06 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/settings/?format=json-p&callback=_jqjsp&_1381871492466= host=canyonsdistrict.nutrislice.com fwd="174.52.155.49" dyno=web.2 connect=3582ms service=30001ms status=503 bytes=0
Oct 15 15:12:09 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/mobile/api_version/?deviceType=iphone host=pasco.nutrislice.com fwd="173.65.148.9" dyno=web.2 connect=3837ms service=30004ms status=503 bytes=0
Oct 15 15:12:11 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/mobile/api_version/?deviceType=iphone host=canyonsdistrict.nutrislice.com fwd="174.52.155.49" dyno=web.2 connect=3987ms service=30001ms status=503 bytes=0
Oct 15 15:12:11 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/schools/?format=json-p&callback=_jqjsp&_1381871497105= host=canyonsdistrict.nutrislice.com fwd="174.52.155.49" dyno=web.2 connect=3962ms service=30001ms status=503 bytes=0
Oct 15 15:12:11 nutrislice-stockton heroku/router: at=error code=H12 desc="Request timeout" method=GET path=/menu/api/menutypes/?format=json-p&callback=_jqjsp&_1381871497128= host=canyonsdistrict.nutrislice.com fwd="174.52.155.49" dyno=web.2 connect=4020ms service=30007ms status=503 bytes=0
๊ทธ๋ฆฌ๊ณ ์ด H12 ํ์์์๊ณผ [CRITICAL] WORKER TIMEOUT์ "์ฃฝ์์ ๋์ ํ"์ ๋ง์คํฐ ํ๋ก์ธ์ค๊ฐ ๋ค์ ์์๋ ๋๊น์ง ๊ณ์๋ฉ๋๋ค.
์ด๊ฒ์ด ๊ฐ์ ๋ฌธ์ ์ด๊ฑฐ๋ ๋ค๋ฅธ ๋ฌธ์ ๋ผ๋ฉด ์ด๋ค ์์ด๋์ด๊ฐ ์์ต๋๊น? ์์ ํ ์ ์์ด ์์ต๋๊น? ๋๋ gunicorn์ด ์๊ฐ ์ด๊ณผ ํ ์์ ์ ํ๋ก์ธ์ค๋ฅผ ์ข ๋ฃํ๊ณ ์๋ก ์์ํ๊ธฐ ๋๋ฌธ์ ์ ์์ ์ผ๋ก ์ฒ๋ฆฌ๋ฅผ ์์ํ ์ ์๋ค๊ณ ์๊ฐํ์ง๋ง ๊ทธ ์ดํ์๋ ์์ฒญ์ด ๋์ฐฉํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์๋ง๋ Heroku ๋ฌธ์ ์ผ ๊ฒ์ ๋๋ค.
:+1: ์ด ๋ฌธ์ ๋ ๋ณด๊ณ ์์ต๋๋ค.
Heroku์์๋ ์ด ๋ฌธ์ ๋ฅผ ๋ณด๊ณ ์์ต๋๋ค.
@sprynmr @richardkeen gunicorn ์ ์คํํ๋ ๋ฐฉ๋ฒ๊ณผ ๊ฐ๋ฅํ ๋ชจ๋ ๋ก๊ทธ๋ฅผ ๊ณต์ ํ ์ ์์ต๋๊น? ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐ ๋ง์ ๋์์ด ๋ ๊ฒ์ ๋๋ค.
@nebstrebor ์์ฒญ ์๋ฅผ ์ ํํ์ง ์์ผ๋ฉด ์ด๋ป๊ฒ ๋๋์?
์ฐ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ด ์์ํ์ต๋๋ค.
web: newrelic-admin run-program python manage.py run_gunicorn -b "0.0.0.0:$PORT" --log-level=DEBUG -w 3 -k gevent --max-requests 250
๋ก๊ทธ ์์ค DEBUG๋ฅผ ์ฌ์ฉํ๋๋ผ๋ ์ฐ๋ฆฌ๋ ๋ฌด์จ ์ผ์ด ์ผ์ด๋๊ณ ์๋์ง์ ๋ํ ๋ก๊ทธ๋ฅผ ๋ง์ด ์ป์ง ๋ชปํ์ต๋๋ค. ํ์ฌ๋ก์๋ gevent
์ฌ์ฉํ์ง ์๋ ๊ฒ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง๋ง ์ด์์ ์ด์ง๋ ์์ต๋๋ค.
@sprynmr ์ต๋ ์์ฒญ ์๋ฅผ ์ ๊ฑฐํ๋ฉด ์ด๋ป๊ฒ ๋ ๊น์? ๋ํ ์ด๋ค ๋ฒ์ ์ gevent?
์ฐ๋ฆฌ๋ 1.0rc2
์์์ต๋๋ค. ์ต๋ ์์ฒญ ์๋ ํ์คํ์ง ์์ต๋๋ค. ์ง๊ธ ํ๋ก๋์
ํ๊ฒฝ์์ ๋ค์ ์ผ๊ณ ์ถ์ง ์์ต๋๋ค.
์์ฒญ ์ ํ ์๊ฐ ์ ๋ํ Heroku ํ์ด์ง๋ฅผ ์ฝ๊ณ ์ ํ๋ฆฌ์ผ์ด์
์ ํ ์๊ฐ well under 30 seconds, such as 10 or 15
์ ์ค์ ํ๋๋ก ์ ์ํฉ๋๋ค. gunicorn์์ timeout ๋งค๊ฐ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์ ์์ ์๋ํ์ต๋๊น?
์ด์จ๋ gevent์ ๋ํ๋๋ ๋ฌธ์ ๋ ์๋ง๋ ์ฐ๊ฒฐ์ด ์ฒ๋ฆฌ๋๋ ๋ฐฉ์ ๋๋ฌธ์ผ ๊ฒ์ ๋๋ค. ํ์ฌ ๋ฒ์ ์ ์์ ์๋ ์ด ๊ทธ๋ฆฐ๋ ์ ์ค์ ๊ฐ๋ ์์ด ๊ทธ๋ฆฐ๋ /์ฐ๊ฒฐ์ ์๋ฝํ์ต๋๋ค. ์๋ง๋ ํ์ฉ๋ ์์ผ ์ค ํ๋๊ฐ ์ค๋ซ๋์ ๋๊ธฐํ๊ณ ๋ค๋ฅธ ์ด๋ฒคํธ๊ฐ ์ฒ๋ฆฌ๋์ง ์์ gunicorn ์์ ์๊ฐ ๋ค์ ์์๋ ์ ์์ต๋๋ค. ๊ทผ๋ฐ ํ์ธํด์ผ์ง..
ํฅ๋ฏธ๋ก์ด. ์๋์, ์ฐ๋ฆฌ๋ ๊ทธ๊ฒ์ ์๋ํ์ง ์์์ต๋๋ค.
:+1: ๋ด ์์ฉ ํ๋ก๊ทธ๋จ์์๋ ์ด๊ฒ์ ๋ณด๊ณ ์์ต๋๋ค. @Jwpe / @sprynmr ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์ด ์์ต๋๊น? ์ด ๋ฌธ์ ์ ๋ํ ํ๋์ด ๋ฐ์ํ ์ง 2๊ฐ์์ด ๋์ ๊ฒ ๊ฐ์ต๋๋ค. ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์๋ ๋ฐฉ๋ฒ์ ์ฐพ์ผ์ จ๋ค๋ฉด ๋ฃ๊ณ ์ถ์ต๋๋ค.
๊ฐ์ฌ ํด์!
@dencold ์๋ํด ๋ณด์ จ์ต๋๊น https://github.com/benoitc/gunicorn/issues/588#issuecomment -29267541
๋๋ heroku์ ๊ณ์ ์ด ์์ผ๋ฏ๋ก ๊ทธ๊ฒ์ด ๋ฌด์์ ํ๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋ํ ๋์ผํ ๋ก๊ทธ๊ฐ ์์ต๋๊น?
์๋ ํ์ธ์ @benoitc๋ , ๋น ๋ฅธ ๋ต๋ณ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ๋ก๊ทธ๋ @Jwpe ๋ฐ @nebstrebor๊ฐ ๋ณด๊ณ ํ ๊ฒ๊ณผ ์ ํํ ๋์ผํฉ๋๋ค. ๋ฌธ์ ๋ฅผ ํ์ ํ๋ ๋ฐ ๋์์ด ๋๋ ๊ฒฝ์ฐ ๊ด๋ จ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ ์ฌ๊ธฐ์ ์ถ๊ฐํ๊ฒ ์ต๋๋ค. ์๋ ค์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค.
์ด์ ์๊ฒฌ์์ ์กฐ์ธ์ ๋ฐ์ gunicorn ์ ํ ์๊ฐ์ heroku ๋ผ์ฐํฐ ์ ํ ์๊ฐ๋ณด๋ค ๋ฎ๊ฒ ๊ตฌ์ฑํ๊ณ ๋์์ด ๋๋์ง ํ์ธํ๊ฒ ์ต๋๋ค. ์ ์ํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
์ด ๊ณ๋จ์ ์คํจ์ ์ค์ ์์ธ์ ์ฐพ๋ ๊ฒ์ด ๋์์ด ๋ ๊ฒ์ ๋๋ค. ํ ์์ ์๊ฐ ์คํจํ๊ณ ์ ์ฒด gunicorn ์๋ฒ๊ฐ ์์ ํ ์๋ตํ์ง ์๋ ๊ฒ์ ๋ณด๋ ๊ฒ์ ์ ๋ง ์ด์ํฉ๋๋ค. ์ง๋จ์ ๋๊ธฐ ์ํด ๋ด๊ฐ ํ ์ ์๋ ์ผ์ด ์์ผ๋ฉด ์๋ ค์ฃผ์ญ์์ค. ์ด ์๊ฐ ์ด๊ณผ๋ฅผ ๋ก์ปฌ์์ ์ฌํํ ์ ์์ต๋๋ค. heroku ์ธํ๋ผ์์๋ง ๋ฐ์ํ๋ ๊ฒ์ผ๋ก ๋ณด์ ๋๋ค.
์ฃ์กํฉ๋๋ค @dencold ์๋ฃจ์ ์ ์ฐพ์ง ๋ชปํ์ต๋๋ค. ๋งค์ฐ ์ฌ์คํ๊ณ ์ ๋นํ ๋ฒ๊ทธ์ฒ๋ผ ๋ณด์๊ณ ๋๋ ๊ทธ๊ฒ๊ณผ ์ธ์ธ ์๊ฐ์ด ์์์ต๋๋ค. ํ์์์ ๋นํธ๊ฐ ๋์์ด ๋๋์ง ๊ถ๊ธํ ๊ฒ์ ๋๋ค. ๋ค์ ๋ณด๊ณ ํฉ๋๋ค.
@dencold ๋๋ ์ ์ ๋ฌผ์ ์ฌ์ฉํ๊ณ ์๋?
@benoitc ๋ค, ์ฐ๋ฆฌ๋ ๋ํ ์๋ก์ด ์ ๋ฌผ์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
@dencold ๋ ๋ง์ฐฌ๊ฐ์ง๋ก ์ด ๋ฌธ์ ๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ํด๊ฒฐํ์ง ๋ชปํ์ต๋๋ค. ์ค๋ฅ์ ์์ธ์ ํ์ ํ๋ ๋ฐ ํฌ์ํ ์๊ฐ์ด ์์๊ณ ์๋ ์์ฒญ์ ๊ธฐ๊ฐ์ ์ค์ด๋ ๋ฐ ์ง์คํด์ผ ํ์ต๋๋ค. ๊ทธ๋ฌ๋ ์ค๋ฅ์ ์ฌ๊ฐํ ํน์ฑ(์ฌ์ฉ์๊ฐ ์ง๋ฉดํ๊ธฐ ๋๋ฌธ์)์ผ๋ก ์ธํด ์ผ์์ ์ผ๋ก ๋ฌธ์ ๋ฅผ ํผํ๊ธฐ ์ํด WSGI ์๋ฒ๋ฅผ ์ ํํ์ต๋๋ค. ๋ฐ๋ผ์ ๋ฌธ์ ๋ฅผ ์ถ๊ฐ๋ก ๋ถ๋ฅํ๊ธฐ ์ํด ๋ ์ด์ ์คํ์ ์คํํ์ง ์์์ต๋๋ค.
@Jwpe ์ต์ํ ์ ์๋ ์๋ฃจ์ ์ ์๋ํ์ต๋๊น? ๋ํ ๊ฒฐ๊ณผ๊ฐ ์ด์ํ๊ณ ๋๋ gunicorn ์์ฒด๋ก ๊ทธ๊ฒ์ ์ฌํํ์ง ์์ต๋๋ค.
์ฐจ๋จ ์๊ฐ์ด 15์ด๋ก ์ค์์ง๋ง ์ฌ์ ํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.
2014๋
1์ 26์ผ ์ผ์์ผ, Benoit Chesneau [email protected]
์ผ๋ค:
@Jwpe https://github.com/Jwpe ์ ์ด๋ ์ ์์ ์๋ ํ์ต๋๊น?
ํด๊ฒฐ์ฑ ? ๋ํ ๊ฒฐ๊ณผ๊ฐ ์ด์ํ๊ณ gunicorn์ผ๋ก ์ฌํํ์ง ์์ต๋๋ค.
๊ทธ ์์ฒด๋ก.โ
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ Gi tHubhttps://github.com/benoitc/gunicorn/issues/588#issuecomment -33316333์์ ํ์ธํ์ธ์.
.
๋ฒค ๋ก๋ฒ์ธ
CTO
์ฃผ์ํ์ฌ ๋ดํธ๋ฆฌ์ฌ๋ผ์ด์ค
866-524-3444 ๋ด์ 702
[email protected]
@Jwpe / @nebstrebor ์ด ๋ฌธ์ ์ ๋ํด ๋ค์
@benoitc ์ฐ๋ฆฌ๋ heroku ์ธ์คํด์ค์ ์ ์๋ ์๊ฐ ์ด๊ณผ ์๋ฃจ์ ์ ๊ตฌํํ์ต๋๋ค. ๋๋ ์์ผ๋ก ๋ฉฐ์น ๋์ ์ด๊ฒ์ ์ฃผ์ ๊น๊ฒ ๊ด์ฐฐํ ๊ฒ์ ๋๋ค. ์๋ก์ด ์๊ฐ ์ด๊ณผ๊ฐ ์ ์ฉ๋ ํ ๋์ผํ ๋ฌธ์ ํ์ ์ด ํ์๋๋ฉด ๋ค์ ๊ฒ์ํฉ๋๋ค.
๋์์ ์ฃผ์ ๋ชจ๋ ๋ถ๋ค๊ป ๋ค์ ํ ๋ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ๊ฒช๊ณ ์๋ ์ ์ผํ ์ฌ๋์ด ์๋๋ผ๋ ์ฌ์ค์ ์๊ฒ ๋์ด ๊ธฐ์ฉ๋๋ค. ์ฐ๋ฆฌ๊ฐ ์์ธ์ ๋ฐ๋ฅ์ ๋๋ฌํ ์ ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
@benoitc ๋ ๋ ๋ฎ์ ์๊ฐ ์ ํ์ด ์ง๋ฌ์ ์ ๋ณด๊ณ ํ๊ณ ์ถ์์ต๋๋ค. ๋ช ๊ฐ์ง ์์ ์ ์๊ฐ ์ด๊ณผ๋ฅผ ๋ณด์์ง๋ง ์ ์ฒด gunicorn ํ๋ก์ธ์ค๊ฐ ์๋ตํ์ง ์๊ฒ ๋๋ ์์ธ์ ์์ต๋๋ค. ์ด๊ฒ์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ด์ง๋ง 30์ด ์๊ฐ ์ด๊ณผ๋ก ์ธํด ์ฒ์์ ๊ณ๋จ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ ์ด์ ๋ฅผ ์์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
๊ณ์ํด์ ์์์ ์ ํ๊ณ ์ถ์์ต๋๋ค. ๋ชจ๋ ๋์์ ๋ค์ ํ ๋ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!
Raspberry PI์์ gunicorn์ผ๋ก Django๋ฅผ ์คํํ ๋ ๋์ผํ [CRITICAL] WORKER TIMEOUT ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
๋ฌด์์.
๋์ผํ [์ค์] ์์
์ ์๊ฐ ์ด๊ณผ๊ฐ ๋ฐ์ํฉ๋๋ค.
๋ฌธ์ ๋ ์์
์์ ์ค์ ์๊ฐ ์ด๊ณผ(๊ธด ์์ฒญ) ํ gunicorn์ด ์์
์๋ฅผ ์ฃฝ์ด๊ณ ์ ์์
์๋ฅผ ์์ฑํ๋ ค๊ณ ์๋ํ์ง๋ง ์ ์์
์๊ฐ TIMEOUT ์ ํ ๋ด์์ ์์ํ ์ ์๊ณ ๋ถ๋ชจ ํ๋ก์ธ์ค์ ์๋ฆด ์์น์ ๋๋ฌํ์ง ์๋๋ค๋ ๊ฒ์
๋๋ค. ๋ผ์ด๋ธ, ๊ทธ๋์ gunicorn์ ๊ทธ๊ฒ์ ๊ณ์ํด์ ์ฃฝ์
๋๋ค :(. ์ฐ๋ฆฌ์ ๊ฒฝ์ฐ ๋ฌธ์ ๋ Gevent ๋ฐ Sentry์ ๊ด๋ จ์ด ์์์ต๋๋ค(https://github.com/getsentry/raven-python/issues/305). Sentry๋ ์์์์ ๋ฉ์ถฅ๋๋ค. .
BTW ์์
์ ์์ ์๊ฐ์ ๋ํด ๋ณ๋์ ์๊ฐ ์ด๊ณผ๊ฐ ์๊ณ "์๊ฐ ์ด๊ณผ" ์๊ฐ ๋ด์ ์์ํ ์ ์๋ ์์
์ ๋ด ์ผ๋ถ ์ถ๊ฐ ๋ก๊ทธ๊ฐ ์์ผ๋ฉด ๋์์ด ๋ฉ๋๋ค.
์๊ฐ ์ด๊ณผ๋ ๋๊ธฐํ ์์ ์๋ฅผ ์ ์ธํ๊ณ ๋ ์์ฒญ ์๊ฐ ์ด๊ณผ๊ฐ ์๋๋๋ค. ๊ธด ์์ฒญ์ ์ฒ๋ฆฌํ๋ ๊ฒฝ์ฐ์๋ ๋ค๋ฅธ ์์ ์๋ ์ฌ์ ํ ์ค์ฌ์์๊ฒ ํํธ๋นํธ๋ฅผ ๋ณด๋ ๋๋ค. ์ด ๊ฒฝ์ฐ ์๊ฐ ์ด๊ณผ ์๊ฐ์ ์์ ์๊ฐ ์ด๊ณผ ์๊ฐ์ ๋๋ค.
์ด๋ค ์๋ฏธ์์ gunicorn์๋ "์์ฒญ ์๊ฐ ์ด๊ณผ"๊ฐ ์์ต๋๋ค.
์, ์์ ์ ์๊ฐ ์ด๊ณผ๋ ๋น๋๊ธฐ์ ์์ฒญ ์๊ฐ ์ด๊ณผ์ ๋ค๋ฆ ๋๋ค. ๊ทธ๋ฌ๋ ๋น๋๊ธฐ "์ปจํ ์คํธ ์ ํ"์ด ๋ฐ์ํ ์ ์๋ ํจ์ ํธ์ถ์ด ์๋ ์ฅ๊ธฐ ์คํ ์์ฒญ(์: "์์ผ - ์ฝ๊ธฐ/์ฐ๊ธฐ")์ ์์ ์ ์๊ฐ ์ด๊ณผ์ ์์ธ์ ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์์ ์ ์์ ์ ์๊ฐ ์ด๊ณผ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค(์์ฒญ์ด ์ ํ ์๋ ๊ฒฝ์ฐ). ๊ทธ๋ฌ๋ Gunicorn ๋ก๊ทธ์๋ ๋ ๊ฐ์ง ๋ค๋ฅธ ๊ฒฝ์ฐ๋ฅผ ๊ตฌ๋ถํ ์ ์๋ ๋ฐฉ๋ฒ์ด ์์ผ๋ฉฐ "WORKER TIMEOUT"์ด๋ผ๋ ๋ฉ์์ง๋ง ์์ต๋๋ค.
์์ฒญ ์๊ฐ ์ด๊ณผ ์ค์ ์ ์ถ๊ฐํด์ผ ํฉ๋๊น? ์ด๋ ๊ฒ ํ๋ฉด ์์ ์๊ฐ์ด ๊ธด ์ฑ์ด ์์ ์ ์๊ฐ ์ด๊ณผ๋ฅผ ๋ฒํ ์ ์์ต๋๋ค.
๋๋ฌธ์ ๊ทธ๋ ๊ฒ ์๊ฐํ์ง ๋ง์ญ์์ค.
1) ์์ฒญ ์คํ ์๊ฐ ์ธก์ ์ด ์ด๋ ต์ต๋๋ค. ์์ฒญ์ด ๋๋ ๋์ ๊ตฌ๊ฑธํ ๋ ์์ฐจ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
2) "์คํ ๋จ์"(์ปจํ
์คํธ ์ ํ ์ฌ์ด์์ ์คํ๋๋ ์ฝ๋์ ์)์ ์๊ฐ ์ด๊ณผ๋ฅผ ์ก๋ ๊ฒ์ gevent์์ ๋ถ๊ฐ๋ฅํ๋ค๋ ๊ฒ์ ์๊ณ ์์ต๋๋ค.
์ด๋ค ์ ์์ด ์์ต๋๊น?
์ด ๋ฌธ์ ๊ฐ ํฉ๋ฒ์ ์ธ ์๊ฐ ์ด๊ณผ ๋ฐ ์ ์ฌ์ ์ผ๋ก ๊ณ๋จ์์ผ๋ก ์ธํ ๊ฒ์ผ ๊ฒฝ์ฐ
์ฒ์ ์คํํ ๋ ์กด์ฌํ์ง ์๋ ์๋ฒ ๋ถํ๋ก ์ธํ ์๊ฐ ์ด๊ณผ๊ฐ ์์ต๋๊น?
์ฌ๊ธฐ์ ํ ์ผ์ด ์์ต๋๊น? ์๋๋ฉด ์ด ๋ฌธ์ ๋ฅผ ๋ซ์ ์ ์๊ณ ๋ ์ ์ฒ๋ฆฌํ ์ ์์ต๋๊น?
๋ค๋ฅธ ์์ค์ ์ธํ๋ผ์์ ์ด์?
2014๋
7์ 30์ผ ์คํ 1์ 14๋ถ์ "Mkrtich" [email protected]์ด ์์ฑํ์ต๋๋ค.
๋๋ฌธ์ ๊ทธ๋ ๊ฒ ์๊ฐํ์ง ๋ง์ญ์์ค.
1) ์์ฒญ ๋ฐํ์ ์ธก์ ์ด ์ด๋ ต์ต๋๋ค. ์์ฐจ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๊ตฌ๊ฑธํ๊ณ ์์ฒญ์ด ๋๋ ๋.
2) "์คํ ๋จ์"(์ฝ๋์ ์)์ ์๊ฐ ์ด๊ณผ๋ฅผ ์ก๋ ๊ฒ์ ์๊ณ ์์ต๋๋ค.
์ปจํ ์คํธ ์ ํ ์ฌ์ด์์ ์คํ) gevent์์๋ ๋ถ๊ฐ๋ฅํฉ๋๋ค.โ
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ GitHub์์ ํ์ธํ์ธ์.
https://github.com/benoitc/gunicorn/issues/588#issuecomment -50673040.
์ ์์ 2๊ฐ์ ํ์์์ ๋งค๊ฐ๋ณ์์ 2๊ฐ์ ๋ค๋ฅธ ๋ก๊ทธ๋ฅผ ๊ฐ๋ ๊ฒ์
๋๋ค.
1) ํ๋๋ ์์ฒญ ์ฒ๋ฆฌ ์ค์๋ง ์๋ํ๋ ํ์ฌ ์๊ฐ ์ด๊ณผ ๋งค๊ฐ๋ณ์์
๋๋ค.
2) ๋ ๋ฒ์งธ๋ ์์
์ ์์ ์๊ฐ ์ด๊ณผ์
๋๋ค.
์ด ๋ฌธ์ ๋ ๋ณด๊ณ
์ฐ๋ฆฌ๋ ๊ฒฐ๊ตญ Heroku์ฉ uWSGI๋ก ์ ํํ๊ณ ๋ ๋์ ์ฑ๊ณต์ ๊ฑฐ๋์ต๋๋ค... Gunicorn์ ๋ํ ์์ ์ฌํญ์ด ์๋ ๊ฒ์ผ๋ก ์๊ณ ์์ต๋๋ค. ํ์ง๋ง ์ด ์ ์์ด ํ๋ก๋์ ์๋ฒ์์ ์ด ๋ฌธ์ ๋ฅผ ๋ณด๊ณ ๋์ค์ ํด๊ฒฐ์ด ํ์ํ ์ฌ๋์๊ฒ ๋์์ด ๋ ์ ์๋ค๊ณ ์๊ฐํ์ต๋๋ค. .
@nebstrebor ์๊ฐ ์ ํ์ ๋ฎ์ถ๋ ์ ์์ ์๋ ํ์ต๋๊น?
@CrazyPython ํฐ์ผ์ด ๋ง๊ฐ๋์์ต๋๋ค. ๋ฌธ์ ๋ฅผ ์ค๋ช ํ๊ณ ๋ฌธ์ ๋ฅผ ์ฌํํ ์ ์๋ ๋ฐฉ๋ฒ์ ์ค๋ช ํ๋ ์ ํฐ์ผ์ ์ด ์ ์์ต๋๊น? ๋์ผํ ๋ฌธ์ ์ธ์ง, ๋ค๋ฅธ ๋ฌธ์ ์ธ์ง ํ์ ํ๋ ๋ฐ ํ์คํ ๋์์ด ๋ ๊ฒ์ ๋๋ค. :)
์, ์์์ ์ธ๊ธํ ๋๋ก ์ฐจ์ด๊ฐ ์์์ต๋๋ค. ๋ฌธ์ ๋ ์ฐ๋ฐ์ ์ด์๋ค
์ถฉ๋ถํ (๊ฒฐ์ฝ ๋ฒ์ํ ์ ์์์)
๊ทธ๋ ๊ฒ ํ์ธ์(1๋
์ด์ ์ง๋ฌ์ต๋๋ค). ๋๋ Gunicorn์ ์ ๋ง ์ข์ํ์ง๋ง,
๊ทธ๋ฆฌ๊ณ ์ฐ๋ฆฌ๋ ๋ฌธ์ ์์ด Heroku ์ธ๋ถ์์ ๊ทธ๊ฒ์ ์ฌ์ฉํฉ๋๋ค.
๋ฒค ๋ก๋ฒ์ธ
CTO ๋ฐ ๊ณต๋ ์ค๋ฆฝ์
์ฃผ์ํ์ฌ ๋ดํธ๋ฆฌ์ฌ๋ผ์ด์ค
[email protected]
์
- 801-735-7845
2015๋
6์ 30์ผ ํ์์ผ ์ค์ 8:08 Benoit Chesneau [email protected]
์ผ๋ค:
@nebstrebor https://github.com/nebstrebor ์ ํด๋ณด์ จ๋์?
์๊ฐ ์ด๊ณผ๋ฅผ ๋ฎ์ถ๋ ์ ์?@CrazyPython https://github.com/CrazyPython ํฐ์ผ์ด ๋ง๊ฐ๋์์ต๋๋ค.
์ ํฐ์ผ์ ์ด ์ ์์ต๋๊น? ๋ฌธ์ ๋ฅผ ์ค๋ช ํ๊ณ ์ด๋ป๊ฒ ํ ์ ์์ต๋๊น?
์ฌ์์ฐ? ๊ฐ์ ๋ฌธ์ ์ธ์ง ํ์ ํ๋ ๋ฐ ํ์คํ ๋์์ด ๋ ๊ฒ์ ๋๋ค.
๋ค๋ฅธ ๊ฒ๊ณผ ๊ณต๋ :)โ
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ GitHub์์ ํ์ธํ์ธ์.
https://github.com/benoitc/gunicorn/issues/588#issuecomment -117199606.
์ฐ๋ฆฌ๋ ์ด ๋ฌธ์ ๋ฅผ ๋ณด๊ณ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ๋ ์์ ์(--workers 2) ๋ชจ๋ ์ฅ๊ธฐ ์คํ ์์ฒญ์ ์ ํ๋ฅผ ๋๊ณ ๊ฒฐ๊ตญ ์ฃฝ๊ณ (--timeout 20) ์ฆ์ ๋ ๊ฐ์ H13์ด ํ์๋๊ณ H12 ๋ฐ WORKER TIMEOUT์ด ๋ค์ ์์๋๊ธฐ ์์ํฉ๋๋ค. ๋ค์ 10๋ถ ๋์ ๊ณ์ํด์ ์์ ์๋ ์ ํ ์๊ฐ์ ๋๋ฌํ๊ณ ๋ค์ ์์๋๊ธฐ ์ ์ ์์ฒญ์ ์ฑ๊ณต์ ์ผ๋ก ์ฒ๋ฆฌํ์ง ๋ชปํ์ต๋๋ค. ๊ทธ๋์ ์ฐ๋ฆฌ๋ dyno๋ฅผ ๋ค์ ์์ํ๊ณ ๊ณ ์ณค์ต๋๋ค.
ํ ๊ฐ์ง ํฅ๋ฏธ๋ก์ด ์ ์ ๋ค๋ฅธ ์ฌ๋์ด ์ธ๊ธํ์ง ์์๋ค๋ ๊ฒ์ ๋๋ค. ๋ฌธ์ ๊ฐ ์์๋ ๋ ๋ ๊ฐ์ H13(์๋ต ์์ด ์ฐ๊ฒฐ์ด ๋ซํ)์ ๋ณด๊ณ ๋ง์นจ๋ด SIGTERM์ ๋ฐํํ์ ๋ H13 - 48์ ํ์๋ฅผ ๋ณด์์ต๋๋ค. ์ ํํ ๋งํ๋ฉด ์ฐ๋ฆฌ๊ฐ ๋ณธ ๊ฒ๊ณผ ๋์ผํ ์์ WORKER TIMEOUT์ ๋๋ค(์ฆ๊ฐ์ ์ธ H13์ ๋ณธ ์ฒ์ ๋ ๊ฐ ์ ์ธ). ์ ํํ ๋ฌด์จ ๋ป์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ์ง๋ง ์์ฌ์ค๋ฝ๋ค์....
H13s ๋๋ H12s๋ ๋ฌด์์ ๋๊น? ์ด๊ฑฐ ํค๋ก์ฟ ์์ ๋์จ๊ฑด๊ฐ์? gunicorn์ด ๋ฌถ์ผ ํฌํธ๋ ์ด๋ป๊ฒ ์ ๊ณต๋ฉ๋๊น? heroku ํ๋ก์๊ฐ ์์ผ์ด ๋ซํ ๊ฒ์ ๊ฐ์งํ์ง ๋ชปํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
๋ํ ์ด๋ค ์์ ์๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๊น?
์, Heroku ์ค๋ฅ ์ฝ๋์
๋๋ค.
H12 - ์์ฒญ ์๊ฐ ์ด๊ณผ - ์ผ๋ฐ์ ์ผ๋ก 30์ด(https://devcenter.heroku.com/articles/error-codes#h12-request-timeout)
H13 - ์๋ต ์์ด ์ฐ๊ฒฐ ์ข
๋ฃ - (https://devcenter.heroku.com/articles/error-codes#h13-connection-closed-without-response)
ํธ์ง : ๋๋ gunicorn์ด ํ๊ฒฝ ๋ณ์๋ก ์กด์ฌํ๋ ๊ฒฝ์ฐ PORT๋ฅผ ์ฌ์ฉํ๋ค๋ ๊ฒ์ ์์์ผ๋ฏ๋ก ํฌํธ๊ฐ ๊ตฌ์ฑ๋ ๋ฐฉ์์ ๋๋ค.
๋๊ธฐ ์์ ์๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
๋ํ ์ธ๊ธํ๋ ๊ฒ์ ์์์ต๋๋ค. ์ฐ๋ฆฌ๋ gunicorn 19.3.0์ ์คํ ์ค์ ๋๋ค.
์ค๋ซ๋์ ํ๋์ด ์์๊ธฐ ๋๋ฌธ์ ๋ฌธ์ ๋ฅผ ๋ซ์ต๋๋ค. ์ง์ฐ๋ ์๊ฐ ์ด๊ณผ๊ฐ ์์ผ๋ฉด ์ ํ๋ฆฌ์ผ์ด์ ์ ์ค๋ ์์ํ๋ ๊ฒ์ด ์ข์ง๋ง ํ์ํ ๊ฒฝ์ฐ ๋ค๋ฅธ ํฐ์ผ์์ ์ํํด์ผ ํฉ๋๋ค.
ํค์ด ๋๋ ๋ํ ์๋ก์ด ์ ๋ฌผ ๊ด๋ฆฌ์ procfile์ ์ฌ์ฉํ์ฌ heroku์ gunicorn uvicorn๊ณผ ๋์ผํ ๋ฌธ์ ์ ์ง๋ฉดํ๊ณ ์์ต๋๋ค.
newrelic-admin run-program gunicorn -w 4 -k uvicorn.workers.UvicornWorker app.main:fastapi_app -b 0.0.0.0:${PORT:-5000} --log-level info --access-logfile=- --logger-class=gunicorn_color.Logger --preload
์ด๋ ๊ฒ ํ๋ฉด ์์คํ ์ด ๋ถํ ๋์๋ง์ ์ด ๋ก๊ทธ๊ฐ ํ์๋ฉ๋๋ค.
2021-03-19T13:18:19.187532+00:00 heroku[web.1]: State changed from starting to up
2021-03-19T13:18:51.964740+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=api-app-clienti-pr-49.herokuapp.com request_id=8742009a-3e56-4f83-a147-97ff84d4e30b fwd="5.89.111.249" dyno=web.1 connect=1ms service=30003ms status=503 bytes=0 protocol=https
2021-03-19T13:19:04.292784+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/api" host=api-app-clienti-pr-49.herokuapp.com request_id=85b6320a-7728-4074-87eb-b0992e7c3f9d fwd="5.89.111.249" dyno=web.1 connect=3ms service=30001ms status=503 bytes=0 protocol=https