api: Initializing connection - Slow - 7 Seconds+
Connecting to any network with polkadot.js is slow and usually takes 7/8 seconds or more regardless of the network speed.
- Polkadot, hosted by parity - 7.64s stalled
- Polkadot, hosted by web3 - 6.64s stalled
- Kusama, hosted by parity - 5.49s stalled
This behavior is consistent across networks and can be noticed also in https://polkadot.js.org/apps/
This issue pertains even in subsequent connections Is there any way we can bring it to 1/2 secs? client-side caching, preload registry etc?
Can be tested locally with following
import { ApiRx, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://kusama-rpc.polkadot.io/')
const api$ = new ApiRx({ provider }).isReady;
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (8 by maintainers)
Result
kusamaWithMetaReady: 3675.406982421875 ms
kusamaWithoutMetaReady: 5543.93603515625 ms
Definite improvement 👍
This helps.
I can improvise loading time for subsequent new WebSocket instances by caching metadata of the first WS Instance for Websites and Electron using persistent data indexdb or AsyncStorage for React Native. And preload it for serverless nodeJs WS instances
Tx
It is updated on upgrades. (Hence being keyed by genesisHash and specVersion in the options)
It is the actual hex metadata as retrieved from the chain, e.g locally is is via
curl -H "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "state_getMetadata", "params":[]}' http://localhost:9933