This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the web-development category.
Last Updated: 2025-10-26
I did some performance testing of a site using locust plus Django and ran into various constraint-related issues: (these are general to many web systems)
RuntimeError can't start new thread. Some solutions are to increase server instance size or number and modify the number of workerspgbouncer connections. You'll know this is an issue if you get errors like OperationalError connection to server at "127.0.0.1", port 6000 failed: FATAL: no more connections allowed (max_client_conn). Pgbouncer is on port 6000 on IIRC. The solution is usually to increase PGBOUNCER_MAX_CLIENT_CONN. This should be much higher than the max number of posgres connections the current DB package can take.postgres connections. This can be increased by upgrading to a bigger postgres instanceredis connections. You'll know this is an issue if you get ConnectionError max number of clients reached and the stack-trace has the redis library at the top. The solution is to scale redis up.Be aware that when you run out of resources, you will start getting various strange exceptions in other parts of the software -- things that normally work fine. Try to identify which exception came first -- and is related to resources. Usually solving this problem will make all the other exceptions go away.