-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request flood in web browser #12
Comments
Note to self:
|
Update: throttling/caching helps, but is not enough. Some requests can take a very long time and will suffocate request queue because they have no built-in timeout (namely |
@lidel they are mostly calls to |
@alanshaw yeah, that confirms what I'm seeing: AFAIK autorelay feature is off on bootstrap nodes. However This means p2p-circuits are never used(!) however it works because (go-ipfs ignores multiaddr if it already has a working connection with same peerId) This means we could either remove Given the docs explicitly state that delegate needs to also be a bootstrap node (libp2p/js-libp2p#371), I'd vote for removal of |
All HTTP requests made by this module are sent to the same delegate host. Browsers throttle the number of concurrent requests per hostname, right now it is 6 per host, which suffocates the use of delegate and blocking it from being used for preload or delegated content routing. This introduces a task queue that limits the number of concurrent requests, making it safe to run in browser context. See also: libp2p/js-libp2p-delegated-content-routing#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
All HTTP requests made by this module are sent to the same delegate host. Browsers throttle the number of concurrent requests per hostname, right now it is 6 per host, which suffocates the use of delegate and blocking it from being used for preload or delegated peer routing. This change introduces task queues that limit the number of concurrent requests, making it safe to run in browser context. Optimizations: - preload calls via `refs` are known to take time, so we limit them to max two at a time - swarm.connect was the main offender (causing multiple requests to delegate), we now check if connection is already present and cache result for 1 minute removing most of redundant http requests - hostname of default delegate is changed Context: libp2p#12 Closes libp2p#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
All HTTP requests made by this module are sent to the same delegate host. Browsers throttle the number of concurrent requests per hostname, right now it is 6 per host, which suffocates the use of delegate and blocking it from being used for preload or delegated peer routing. This change introduces task queues that limit the number of concurrent requests, making it safe to run in browser context. Optimizations: - preload calls via `refs` are known to take time, so we limit them to max two at a time - swarm.connect was the main offender (causing multiple requests to delegate), we now check if connection is already present and cache result for 1 minute removing most of redundant http requests - hostname of default delegate is changed Context: libp2p#12 Closes libp2p#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
Catching up on this now, sorry for the delay.
Yes, we should remove this code. Right now we're telling the delegate to connect to us through every bootstrap as relays, which isn't going to work as they're not relays. I think this code may have made the assumption that we could be using a delegate that's not publicly dialable, which is wrong. Getting the Priority Peer or (Friend Peer) functionality in place and documenting that users should have their delegate node as a priority peer should be sufficient for us just calling refs on the delegate. All the bootstrap node stuff just needs to go away. |
This removes all code that caused swarm connect calls from delegate to self. It was not needed: delegate is one of bootstrap nodes, so we are always connected to it. libp2p#12 (comment) License: MIT Signed-off-by: Marcin Rataj <[email protected]>
@jacobheun neat! I removed bootstrap node stuff as part of #16 |
* fix: limit concurrent HTTP requests All HTTP requests made by this module are sent to the same delegate host. Browsers throttle the number of concurrent requests per hostname, right now it is 6 per host, which suffocates the use of delegate and blocking it from being used for preload or delegated peer routing. This change introduces task queues that limit the number of concurrent requests, making it safe to run in browser context. Optimizations: - preload calls via `refs` are known to take time, so we limit them to max two at a time - swarm.connect was the main offender (causing multiple requests to delegate), we now check if connection is already present and cache result for 1 minute removing most of redundant http requests - hostname of default delegate is changed Context: #12 Closes #12 * refactor: remove the need for swarm connect This removes all code that caused swarm connect calls from delegate to self. It was not needed: delegate is one of bootstrap nodes, so we are always connected to it. #12 (comment) * chore: remove unused dependencies We no longer need those (removed calls to swarm.connect) License: MIT Signed-off-by: Marcin Rataj <[email protected]>
All HTTP requests made by this module are sent to the same delegate host. Browsers throttle the number of concurrent requests per hostname, right now it is 6 per host, which suffocates the use of delegate and blocking it from being used for preload or delegated content routing. This introduces a task queue that limits the number of concurrent requests, making it safe to run in browser context. See also: libp2p/js-libp2p-delegated-content-routing#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
Adds limit of concurrent HTTP requests sent to remote API by dns and preload calls when running in web browser contexts. Browsers limit connections per host (~6). This change mitigates the problem of expensive and long running calls of one type exhausting connection pool for other uses. It additionally limits the number of DNS lookup calls by introducing time-bound cache with eviction rules following what browser already do. This is similar to: libp2p/js-libp2p-delegated-content-routing#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
Adds limit of concurrent HTTP requests sent to remote API by dns and preload calls when running in web browser contexts. Browsers limit connections per host (~6). This change mitigates the problem of expensive and long running calls of one type exhausting connection pool for other uses. It additionally limits the number of DNS lookup calls by introducing time-bound cache with eviction rules following what browser already do. This is similar to: libp2p/js-libp2p-delegated-content-routing#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
Adds limit of concurrent HTTP requests sent to remote API by dns and preload calls when running in web browser contexts. Browsers limit connections per host (~6). This change mitigates the problem of expensive and long running calls of one type exhausting connection pool for other uses. It additionally limits the number of DNS lookup calls by introducing time-bound cache with eviction rules following what browser already do. This is similar to: libp2p/js-libp2p-delegated-content-routing#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
Adds limit of concurrent HTTP requests sent to remote API by dns and preload calls when running in web browser contexts. Browsers limit connections per host (~6). This change mitigates the problem of expensive and long running calls of one type exhausting connection pool for other uses. It additionally limits the number of DNS lookup calls by introducing time-bound cache with eviction rules following what browser already do. This is similar to: libp2p/js-libp2p-delegated-content-routing#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
Adds limit of concurrent HTTP requests sent to remote API by dns and preload calls when running in web browser contexts. Browsers limit connections per host (~6). This change mitigates the problem of expensive and long running calls of one type exhausting connection pool for other uses. It additionally limits the number of DNS lookup calls by introducing time-bound cache with eviction rules following what browser already do. This is similar to: libp2p/js-libp2p-delegated-content-routing#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
Adds limit of concurrent HTTP requests sent to remote API by dns and preload calls when running in web browser contexts. Browsers limit connections per host (~6). This change mitigates the problem of expensive and long running calls of one type exhausting connection pool for other uses. It additionally limits the number of DNS lookup calls by introducing time-bound cache with eviction rules following what browser already do. This is similar to: libp2p/js-libp2p-delegated-content-routing#12 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
Adds limit of concurrent HTTP requests sent to remote API by dns and preload calls when running in web browser contexts. Browsers limit connections per host (~6). This change mitigates the problem of expensive and long running calls of one type exhausting connection pool for other uses. It additionally limits the number of DNS lookup calls by introducing time-bound cache with eviction rules following what browser already do. This is similar to: libp2p/js-libp2p-delegated-content-routing#12
Problem
I've been testing delegated routing in browser context, namely with js-ipfs embedded in Brave (ipfs/ipfs-companion#716).
It produces pretty intense list of pending requests when browsing /ipns/tr.wikipedia-on-ipfs.org 🎠 💦
Modern browsers limit the number of concurrent requests to ~6 per hostname.
Everything over the limit lands in "pending" state.
On some pages it takes a dozen of seconds for the browser to finish a pending list like the one above (it was multiple screens), and while it happens nothing else works.
When run in regular page, this flood of
swarm connect
results in slow browsing experience (nothing loads, "waiting for available socket" displayed in bottom left).In my case (Brave + chrome.sockets), coupled with regular preload requests it produced more severe
net::ERR_INSUFFICIENT_RESOURCES
:Fix
My initial idea would be to limit the number of concurrent requests using something like p-queue around these lines:
js-libp2p-delegated-content-routing/src/index.js
Lines 90 to 92 in 69f1f94
I'll prepare PR with this.
The text was updated successfully, but these errors were encountered: