I am writing a server with multiple gunicorn workers and want to let them all have access to a specific variable. I'm using Redis to do this(it's in RAM, so it's fast, right?) but every GET or SET request adds another client.  I'm performing maybe ~150 requests per second, so it quickly reaches the 25 connection limit that Heroku has. To access the database, I'm using db = redis.from_url(os.environ.get("REDIS_URL")) and then db.set() and db.get().  Is there a way to lower that number? For instance, by using the same connection over and over again for each worker?  But how would I do that? The 3 gunicorn workers I have are performing around 50 queries each per second.
If using redis is a bad idea(which it probably is), it would be great if you could suggest alternatives, but also please include a way to fix my current problem as most of my code is based off of it and I don't have enough time to rewrite the whole thing yet.
Note: The three pieces of code are the only times redis and db are called.  I didn't do any configuration or anything.  Maybe that info will help.
Most likely, your script creates a new connection for each request.
But each worker should create it once and use forever.
Which framework are you using?
It should have some documentation about how to configure Redis for your webapp.
P.S. Redis is a good choice to handle that :)
Python Redis on Heroku reached max clients