fetch
fetch copied to clipboard
Investigate improvement on session cache
I have a scenario where many h2c requests (~ 200) will be launched/connected to the same origin nearly at the same time.
As they enter request()
in h2.js, all of these request look up in the cache and there is no entry yet because the cache entry isn't made until the connect
event callback is made.
Then when each of these 200 requests connect, they write/overwrite the cache entry with their session. We have a long idleSessionTimeout (~ 1 hour) so all of these sessions stick around unnecessarily, not able to be re-used except the winner/last one to connect and write to the cache.
Describe the solution you'd like Investigate adding some "self cleanup" to minimize resource utilization, removing any unusable http2 sessions that are left open in scenarios like this.
Spitballing here... perhaps:
- in the connect callback add a check to see if a cache entry already exists for the origin key and if so dont update the cache
- and if the session wasn't cached close out the session after its stream completes
(might be too simplistic, but something along these lines would improve this situation)