sahib / brig

File synchronization on top of ipfs with git like interface & web based UI
https://brig.readthedocs.io
GNU Affero General Public License v3.0
567 stars 33 forks source link

Finetune ipfs config and improve performance #17

Closed sahib closed 5 years ago

sahib commented 6 years ago
makew0rld commented 5 years ago

I can try and tackle this, but I need you to point me in the right direction. I mentioned gossipsub in the other issue, but I'd be happy to do more. What file should I be looking at, that will have IPFS configuration?

sahib commented 5 years ago

Thanks, any help is appreciated.

The IPFS config of brig is being set here. The defaults are used and only the keys listed there are overwritten. I already enabled gossipsub in bab1838f789276bbc42b982fd0ac1de9a34c547e.

What might be even more important than raw performance is making the connectivity more stable. Connections often time out or back off for a long time when it fails. I also often had issues when trying to connect when two machines were not in the same LAN, despite assuming that IPFS could have connected over a (slow) remote node. Also there seems to be an issue when using a port other than 4001 - I did not have time to follow up on that though.

Performance wise, IPFS seems to chew away a lot of CPU (often 100% after some time) and insane amounts of memory (> 2GB if I let it run for a long time). I tried to reduce this by setting the high and low water settings to a lower range, but this didn't seem to help.

I guess quite some of those points could be brought to the attention of the IPFS developers, but time constrained me here. I suggest you do some experimentation yourself and decide how to progress upon that. I'm glad to answer any questions as far as I can.

makew0rld commented 5 years ago

I will make a PR adding some configuration I think will help, forking from develop.

makew0rld commented 5 years ago

The PR is #24.

sahib commented 5 years ago

Side note: The changelog for v0.4.19 looks pretty cool.

makew0rld commented 5 years ago

It does, interesting stuff. I'll be happy to upgrade when it comes out.

sahib commented 5 years ago

I updated to v0.4.19 (which is now the default version brig will install in case there is no ipfs binary). Also it will set Swarm.EnableAutoNATService=true and Swarm.EnableAutoRelay=true on init by default in the hope to improve connectivity (still need to test).

I think this issue can be closed otherwise. One day I will add a documentation page describing the options that are being set, but that can wait until they settled for some time.

makew0rld commented 5 years ago

I don't think you should have done this, look at the documentation for those features.

EnableAutoRelay Enables automatic relay for this node. If the node is a HOP relay (EnableRelayHop is true) then it will advertise itself as a relay through the DHT. Otherwise, the node will test its own NAT situation (dialability) using passively discovered AutoNAT services. If the node is not publicly reachable, then it will seek HOP relays advertised through the DHT and override its public address(es) with relay addresses.

I believe you have enabled EnableRelayHop, which will advertise this node as a relay. This will increase traffic for the node, and may fail if the node isn't publicly accessible, because it can't be accessed as a relay. Making the nodes of brig users public relays is not a good idea, whether it will be successfully used or not.

If you want to set EnableRelayHop to false, then setting EnableAutoRelay would be good. My apologies if this is already the case.

EnableAutoNATService Enables the AutoNAT service for this node. The service allows peers to discover their NAT situation by requesting dial backs to their public addresses. This should only be enabled on publicly reachable nodes.

Note the last sentence. Most nodes will not be publicly reachable.

sahib commented 5 years ago

[...]

Fixed after some discussion in the matrix chat room as of 541f9efa8e1c61fd637117459b8d2eeeff820753.