5

I am running a Django app on Django's development server with PostgreSQL as the backend database. I got this error:

django.db.utils.OperationalError: FATAL:  sorry, too many clients already

when I was doing a load testing using Locust. My Locust script runs the test with 100 concurrent clients:

env.runner.start(100, spawn_rate=100, wait=True)

I have seen several answers on SO, such as:

  1. Getting OperationalError: FATAL: sorry, too many clients already using psycopg2
  2. Getting "FATAL: sorry, too many clients already" when the max_connections number is not reached
  3. Django+Postgres FATAL: sorry, too many clients already

From those threads, I think I understand the cause of the error, but I am still very confused. How does it scale in real life if PostgreSQL cannot handle even 100 concurrent clients? Does it have anything to do with the fact that I am using a development server? Will it help if I use Gunicorn? If some connection clean-up is needed, is it something that I should implement in the Locust script? I am quite new in this area, so I apologize if the answers to those questions are obvious.

vanbastelaer
  • 368
  • 2
  • 15

0 Answers0