benoitc / hackney

simple HTTP client in Erlang
Other
1.34k stars 427 forks source link

Pool queue usage optimization #549

Closed Hinidu closed 4 years ago

Hinidu commented 5 years ago

Follow up to discussions from https://github.com/benoitc/hackney/issues/547

I've replayed my old synthetic test with 500 processes making requests to httpbin.org in a loop using pool with 10 connections and connect_timeout and checkout_timeout both set to 10. And found that message queue of hackney pool do not grow indefinetely after this commit 74159da340a03f3a3a0cc944814ff4338ab07ce6 (it grows until ~300k messages on my computer and then is gradually reducing to 0) but grows indefinetely on the last released 1.14.3.

Though I think that costly filtering of pending processes queue can be avoided simply enough because pool already has a dict with these processes and I want to try to remove a process only from there and just ignore it after queue:out if the dequeued process is not the key in this dict.

I believe that it should reduce the peak size of message queue of the pool and let the pool to handle these messages faster so reducing the time when the pool is unresponsive. I'm going to try this optimization in the next few days.

benoitc commented 5 years ago

@Hinidu I just released 1.15.0 to include 74159da340a03f3a3a0cc944814ff4338ab07ce6 . Should have been done a long time ago.

Hinidu commented 5 years ago

@benoitc thanks! Great to hear that! Unfortunately I got sick so I've suspended my experiments for now.

benoitc commented 5 years ago

@Hinidu no pb I'm curious about the idea you had anyway. So feel free to share them when you feel better.

benoitc commented 4 years ago

closing issue since no discussion happened since a long time. Also coming connnectiion reuse is quite different.