On Friday, August 24, 2012 9:22:31 AM UTC-7, Ravi wrote:
>
> On Thursday, August 23, 2012 8:34:50 PM UTC-7, Jeremy Evans wrote:
>
>> With that configuration, you'll get an error if a thread waits more than 
>> 30 seconds and still cannot acquire a connection.  
>>
>
> The default setting is 5sec. So increasing to 30 may reduce the timeout 
> issue. 
>

Correct.  Assuming your threads can wait 30 seconds for a connection, it 
may be an OK fix. 

>
> You might want to increase the sleep time, as otherwise you can end up 
>> with a lot of threads waking up, seeing there are no available connections, 
>> and going back to sleep. 
>>
> This might increase the overall throughput time.
>

Key word being "might".  It depends on the current bottleneck.  If you are 
also bottlenecked on the CPU, then increasing pool_sleep_time may decrease 
running time in certain situations.
 

>  Also the way Sequel's connection pools currently work, threads are not 
>> serviced in order of request.  So you can end up with a situation like this:
>>
>>   1) thread A requests a connection from the pool, none in pool, so 
>> sleeps for sleep time
>>   2) thread B returns a connection to the pool
>>   3) thread B requests a connection from the pool, gets the one it just 
>> returned
>>   4) go to 1)
>>
>> This is obviously a non-optimal situation, but it's not a major issue as 
>> in general practice you should make sure your connection pool is large 
>> enough that threads are rarely if ever waiting for connections.
>>
>> I'd be open to fixing this so that thread A gets the connection 
>> immediately when thread B checks it in, but it requires a Queue class where 
>> Queue#pop accepts a timeout.  Currently, ruby's Queue class only takes a 
>> single non-block flag, so it isn't suitable.
>>
>
> There is an option called :connection_handling in 
> Sequel::ThreadedPoolConnection class. Changing that to :queue can also the 
> issue you are talking about, default is :stack. 
> I have not used that though, still need to figure out if I can set at the 
> time of connection, Sequl.connect(......., :connection_handling=>:queue).
>

:connection_handling=>:queue can reduce the risk of connection staleness, 
but will not affect thread fairness in the example I used above.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/VQVlU_llX2IJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to