Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
I believe that when using the DigitalOcean’s App Platform with Django, it automatically uses gunicorn as the application server if you haven’t specified a custom start command. However, you have full control over the configuration by using the “Run Command” setting in the App Platform.
To set the number of workers you can update the “Run Command” setting. Here, you can specify your custom gunicorn command:
gunicorn --worker-tmp-dir /dev/shm --workers 4 django_app.wsgi
You can adjust the --workers number as required.
If you are still getting the error that gunicorn is not found, could you share your requirements.txt file here?
Regarding your database connections issue, in your Django settings, you can use persistent database connections. This can help reduce the overhead of establishing a new connection every time one is requested:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mydatabase',
...
'CONN_MAX_AGE': 300,
}
}
The CONN_MAX_AGE setting specifies the lifetime of a database connection in seconds. Setting it to a positive value like 300 (5 minutes) allows Django to use a persistent connection for that duration.
Also, if you’re experiencing high connection loads, consider using a connection pooler like pgbouncer:
https://docs.digitalocean.com/products/databases/postgresql/how-to/manage-connection-pools/
Also keep in mind that the number of gunicorn workers is not directly related to the number of database connections. However, each worker can handle a request, and if each request results in a new database connection, they can quickly add up, especially if you’re not using persistent connections or a connection pooler.
Let me know how it goes!
Best,
Bobby