0Pricing
Django Academy · Lektion

Gunicorn als WSGI-Server

Django mit einem geeigneten App-Server bereitstellen

Gunicorn als WSGI-Server ist eine kostenlose Django Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Django Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Django Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

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. 🎯

Häufig gestellte Fragen

Ist die Lektion „Gunicorn als WSGI-Server“ kostenlos?

Ja — der vollständige Text von „Gunicorn als WSGI-Server“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Django Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Django Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Gunicorn als WSGI-Server“?

Django mit einem geeigneten App-Server bereitstellen Du übst Django Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Django Academy zu starten?

Keine Vorkenntnisse erforderlich. Django Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „Gunicorn als WSGI-Server“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Django Academy-Lektion Code schreiben und ausführen?

Ja. Jede Django Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Gunicorn als WSGI-Server
  2. Nginx als Reverse Proxy
  3. WhiteNoise für statische Dateien
  4. Umgebungsvariablen und Aufteilung der Einstellungen
← Zurück zu Django Academy