0Pricing
Django Academy · レッスン

WSGI ServerとしてのGunicorn

本番用アプリケーションサーバーでDjangoを配信します

「WSGI ServerとしてのGunicorn」はCoddyKit上の無料Django Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはDjango Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Django Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Meet Gunicorn

Django's runserver is great for coding, but it is single-threaded and unsafe for the public web. In production you need a real app server. 🚀

What WSGI Is

WSGI is the standard contract between a Python web app and a server. It lets any server talk to Django without knowing its internals.

Gunicorn Speaks WSGI

Gunicorn is a production WSGI server that loads your Django app and runs it fast, stable, and concurrently across many requests.

Install It

Add Gunicorn to your environment with pip, then pin it in requirements.txt so every deploy uses the same version.

pip install gunicorn
pip freeze > requirements.txt

The wsgi.py Entry Point

Every project ships a wsgi.py exposing an object named application. Gunicorn imports exactly that object to serve your site.

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Run Gunicorn

Point gunicorn at your project's wsgi module. The dotted path mirrors how Python imports it, ending in application.

gunicorn myproject.wsgi:application

Bind an Address

Use --bind to choose the host and port. Binding to 0.0.0.0 lets the outside world reach the server, not just localhost.

gunicorn myproject.wsgi --bind 0.0.0.0:8000

Workers Handle Load

Each worker is a process serving requests in parallel. A common start is 2 times CPU cores plus 1, then tune from real traffic.

gunicorn myproject.wsgi --workers 3

Gunicorn Is Not for Static

Gunicorn runs your Python code, not files. Serving CSS and images is a job you hand to Nginx or WhiteNoise instead.

Keep It Running

A live server must survive reboots and crashes. A process manager like systemd restarts Gunicorn automatically so your site stays up.

Timeouts Matter

The --timeout flag kills workers stuck on slow requests. The default is 30 seconds, which protects you from one hung view freezing everything.

gunicorn myproject.wsgi --timeout 60

Quick Check

Let's confirm what Gunicorn actually serves.

Recap

You learned that Gunicorn is the production WSGI server that runs Django via wsgi:application, scales with workers, and leaves static files to others. 🎯

よくある質問

「WSGI ServerとしてのGunicorn」レッスンは無料ですか?

はい。「WSGI ServerとしてのGunicorn」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Django Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Django Academyコースには全4レッスンが含まれています。

「WSGI ServerとしてのGunicorn」で何を学びますか?

本番用アプリケーションサーバーでDjangoを配信します ブラウザで直接実行するハンズオンコードでDjango Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Django Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのDjango Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「WSGI ServerとしてのGunicorn」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このDjango Academyレッスンでコードを書いて実行できますか?

はい。すべてのDjango Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. WSGI ServerとしてのGunicorn
  2. Reverse ProxyとしてのNginx
  3. 静的ファイル用のWhiteNoise
  4. Environment VariablesとSettingsの分割
← Django Academyに戻る