Ada Developers Academy Capstone: Day 15 and part of 16
Rufus Schedulers uses threads… and a pool sounds good!
Okay, so I could only make 5 requests before the server gave me issues. As it turns out, “When your thread doesn’t have a connection yet, it will get one from the pool. (If all connections in the pool are in use, it will wait until one is returned from another thread. Eventually timing out and throwing ConnectionTimeoutError).” I did so much reading to find this answer, including these responses to questions and articles…
- ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5.000 seconds
- Concurrency and Database Connections in Ruby with ActiveRecord
- Rails Database Pooling
And after all of the tries of changing code and all of the reading, it was this StackOverflow response really helped me understand what was happening →Connection pool issue with ActiveRecord objects in rufus-scheduler
In the end, I increased the API’s connection pool size, added
ActiveRecord::Base.connection_pool.release_connection to my code. All together it seems to work great!!
But seriously, it’s hot outside so all this talk about pools has me really craving to be in one.