I'm using nodeJs for mobile in a project (react-native), mainly hoping to run IPFS on mobile. I'm experiencing performance issues on the device(iPhone 6+) and simulator, Once the code runs to the ipfs-api, the CPU surges up to 100% and persists. Is it because IPFS has too many connections? Is there a way to limit connections and reduce power consumption?
In [email protected] you can manage connections with the new connection manager.
You pass connectionManager options to the IPFS constructor https://github.com/ipfs/js-ipfs#ipfs-constructor
Options for the connection manager are documented here: https://github.com/libp2p/js-libp2p-connection-manager#create-a-connectionmanager
Does that answer your question @xuruijing?
Thank you very much for your reply, I don't know how to use the connectionManager, how to configure the parameters, such as when to call, my goal was to reduce the power consumption of the CPU run time, and don't know how by connectionManager configuration can achieve this goal? In addition, I use ipfsd-ctl to start ipfs.
Do you have an example of using connectionManager in config?
Hows this:
const IPFS = require('ipfs')
const ipfs = new IPFS({
connectionManager: {
maxPeers: Infinity,
minPeers: 0,
maxData: Infinity,
maxSentData: Infinity,
maxReceivedData: Infinity,
maxEventLoopDelay: Infinity,
pollInterval: 2000,
movingAverageInterval: 60000,
defaultPeerValue: 1
}
})
Info on what the options do is here: https://github.com/libp2p/js-libp2p-connection-manager#create-a-connectionmanager
js-ipfs doesn't yet have performance profiles you can pick from so I think it'll be a case of tweaking the parameters until you find something that works for your situation.
I'm having a hard time finding where connectionManager.start() is called.. tried looking in libp2p as well as in ipfs.
Or are we suppose to handle starting and stoping ourselves? Apologies if I'm missing something really obvious 馃構
I used the latest libp2pin ipfs, and
connectionManager: {
maxPeers: 10,
minPeers: 2,
pollInterval: 10000 // ms
}.
How can I verify that this configuration works?
@mistakia the newest version of libp2p (in js-ipfs 0.31) starts the connection manager by default. Sorry about that.
@xuruijing you could verify the connection manager is doing it's job by asking the swarm.peers API.
Closing this as I think the original question has now been answered!
Most helpful comment
Hows this:
Info on what the options do is here: https://github.com/libp2p/js-libp2p-connection-manager#create-a-connectionmanager
js-ipfs doesn't yet have performance profiles you can pick from so I think it'll be a case of tweaking the parameters until you find something that works for your situation.