I am learning rails database connection pool concept. In rails application I have defined pool size of 5.
my understanding about connection pool size is as below.
When server start rails automatically creates n number of connection defined in the database.yml file. In my case it will create 5 connection since pool size is 5.
On every http request if there is need to access database then rails will use available connection from the connection pool to serve the request.
But my question is if I hit 1000 request at a time then most of the request will not get access to database connection because my connection pool size is only 5.
Is my above understanding about rails connection pool is right??
Thanks,
This pool size is for a single process. Ofcourse, If your application is running on multiple processes, u will have 5 database connections for each of them. If your server is hit by 1000 requests concurrently, It will distribute the requests among these connections, when it gets full, rest of the requests wait for their turn.
Yes, from the docs:
source: http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html
If you use something like unicorn as http server: