kubo icon indicating copy to clipboard operation
kubo copied to clipboard

IPNS 30 secs filename resolve vs IPFS 0.1 second

Open Chara-Freedom opened this issue 7 months ago • 11 comments

Checklist

Installation method

dist.ipfs.tech or ipfs-update

Version

Kubo version: 0.41.0-d719fb87b
Repo version: 18
System version: amd64/linux
Golang version: go1.26.2

Config

{
  "API": {
    "HTTPHeaders": {}
  },
  "Addresses": {
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Announce": [],
    "AppendAnnounce": [],
    "Gateway": "/ip4/127.0.0.1/tcp/8080",
    "NoAnnounce": [],
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001",
      "/ip4/0.0.0.0/udp/4001/webrtc-direct",
      "/ip4/0.0.0.0/udp/4001/quic-v1",
      "/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
      "/ip6/::/udp/4001/webrtc-direct",
      "/ip6/::/udp/4001/quic-v1",
      "/ip6/::/udp/4001/quic-v1/webtransport"
    ]
  },
  "AutoConf": {},
  "AutoNAT": {},
  "AutoTLS": {},
  "Bitswap": {},
  "Bootstrap": [
    "auto"
  ],
  "DNS": {
    "Resolvers": {
      ".": "auto"
    }
  },
  "Datastore": {
    "BlockKeyCacheSize": null,
    "BloomFilterSize": 0,
    "GCPeriod": "1h",
    "HashOnRead": false,
    "Spec": {
      "mounts": [
        {
          "mountpoint": "/blocks",
          "path": "blocks",
          "prefix": "flatfs.datastore",
          "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
          "sync": false,
          "type": "flatfs"
        },
        {
          "compression": "none",
          "mountpoint": "/",
          "path": "datastore",
          "prefix": "leveldb.datastore",
          "type": "levelds"
        }
      ],
      "type": "mount"
    },
    "StorageGCWatermark": 90,
    "StorageMax": "10GB"
  },
  "Discovery": {
    "MDNS": {
      "Enabled": true
    }
  },
  "Experimental": {
    "FilestoreEnabled": false,
    "Libp2pStreamMounting": false,
    "OptimisticProvide": false,
    "OptimisticProvideJobsPoolSize": 0,
    "P2pHttpProxy": false,
    "UrlstoreEnabled": false
  },
  "Gateway": {
    "AllowCodecConversion": null,
    "DeserializedResponses": null,
    "DisableHTMLErrors": null,
    "ExposeRoutingAPI": null,
    "HTTPHeaders": {},
    "NoDNSLink": false,
    "NoFetch": false,
    "PublicGateways": null,
    "RootRedirect": ""
  },
  "HTTPRetrieval": {},
  "Identity": {
    "PeerID": "12D3KooWPZgaSPM84PKCb78vEugeJTA7X2k6WYcKV1TGv1M9FJGq"
  },
  "Import": {
    "BatchMaxNodes": null,
    "BatchMaxSize": null,
    "CidVersion": 1,
    "FastProvideRoot": null,
    "FastProvideWait": null,
    "HashFunction": "sha2-256",
    "UnixFSChunker": "size-1048576",
    "UnixFSDAGLayout": "balanced",
    "UnixFSDirectoryMaxLinks": 0,
    "UnixFSFileMaxLinks": 1024,
    "UnixFSHAMTDirectoryMaxFanout": 256,
    "UnixFSHAMTDirectorySizeEstimation": "block",
    "UnixFSHAMTDirectorySizeThreshold": "256KiB",
    "UnixFSRawLeaves": true
  },
  "Internal": {},
  "Ipns": {
    "DelegatedPublishers": [
      "auto"
    ],
    "RecordLifetime": "",
    "RepublishPeriod": "",
    "ResolveCacheSize": 128
  },
  "Migration": {},
  "Mounts": {
    "FuseAllowOther": false,
    "IPFS": "/ipfs",
    "IPNS": "/ipns",
    "MFS": "/mfs"
  },
  "Peering": {
    "Peers": null
  },
  "Pinning": {
    "RemoteServices": {}
  },
  "Plugins": {
    "Plugins": null
  },
  "Provide": {
    "DHT": {}
  },
  "Provider": {},
  "Pubsub": {
    "DisableSigning": false,
    "Router": ""
  },
  "Reprovider": {},
  "Routing": {
    "DelegatedRouters": [
      "auto"
    ]
  },
  "Swarm": {
    "AddrFilters": null,
    "ConnMgr": {},
    "DisableBandwidthMetrics": false,
    "DisableNatPortMap": false,
    "RelayClient": {},
    "RelayService": {},
    "ResourceMgr": {},
    "Transports": {
      "Multiplexers": {},
      "Network": {},
      "Security": {}
    }
  },
  "Version": {}
}

Description

When the link has a format https://dweb.link/ipfs/bafkreid3mc4oguolxageorm77ywht4ncmqcioh2jffdyb7shvuhfrqetka?filename=VERSION_W_2.80 it resolves very fast, however with format https://k51qzi5uqu5dldod6robuflgitvj276br0xye3adipm3kc0bh17hfiv1e0hnp4.ipns.dweb.link/VERSION_W_2.80 it takes a really long time for resolve, about 30 seconds in all my tests. I am selfhosting everything on my machine, with pinata it was much faster, but pinata uses older link format and is not compatible with unixfs 2025 yet. What is it?

Chara-Freedom avatar Apr 27 '26 19:04 Chara-Freedom

Image

Chara-Freedom avatar Apr 28 '26 00:04 Chara-Freedom

It takes 30 seconds for my program to resolve this link

https://github.com/user-attachments/assets/beaa8fd5-daf7-4c16-84a2-d75dbd34d6df

Chara-Freedom avatar Apr 28 '26 00:04 Chara-Freedom

https://github.com/user-attachments/assets/3ab1461a-2464-4bdd-a3c1-899cb70c777e

Chara-Freedom avatar Apr 28 '26 02:04 Chara-Freedom

That's a comparison between IPFS and IPNS resolve speed of the same link so now I'm pretty sure this is IPNS-specific bug?

https://github.com/user-attachments/assets/c6980cd5-6ca8-48a4-b122-30d418ac2ccb

Chara-Freedom avatar Apr 28 '26 03:04 Chara-Freedom

That's a comparison between IPFS and IPNS resolve speed of the same link so now I'm pretty sure this is IPNS-specific bug? 2026-04-28.05-59-10.mp4

Here IPFS resolves immediately but IPNS took 30 more seconds

Chara-Freedom avatar Apr 28 '26 03:04 Chara-Freedom

@lidel what's your opinion on this? Is it even a bug or IPNS degraded performance compared to IPFS is expected?

Chara-Freedom avatar Apr 28 '26 03:04 Chara-Freedom

Thanks for the detailed report! What you are experiencing is expected with the current IPNS-over-DHT behavior. The DHT IPNS resolution is a different process than the DHT provider lookup operation.

/ipfs/<cid> resolution is usually faster because the DHT lookup only need to hit one of the 20 closest DHT servers to the target key. If that node has a record for a reachable peer, kubo will try to fetch open a connection to that node and the routing step is over.

For /ipns/<name> resolution requires a quorum of 16 out of the 20 closest peers (see specs) to send a response before returning a value. This is done to improve robustness against stale records. In practice it means that kubo has to wait for responses of more potentially slow DHT servers, increasing the tail latency. If some servers are unresponsive, we need to wait for a timeout before trying another peer.

The relevant logic is implemented in go-libp2p-kad-dht.

Also see recent IPNS study from @probe-lab.

A solution to reduce IPNS resolution time could be to lower the quorum (wait for fewer responses), trading off robustness against stale records. This change would need to be discussed in the specs repo.

guillaumemichel avatar Apr 28 '26 08:04 guillaumemichel

Thanks for the detailed report! What you are experiencing is expected with the current IPNS-over-DHT behavior. The DHT IPNS resolution is a different process than the DHT provider lookup operation.

/ipfs/<cid> resolution is usually faster because the DHT lookup only need to hit one of the 20 closest DHT servers to the target key. If that node has a record for a reachable peer, kubo will try to fetch open a connection to that node and the routing step is over.

For /ipns/<name> resolution requires a quorum of 16 out of the 20 closest peers (see specs) to send a response before returning a value. This is done to improve robustness against stale records. In practice it means that kubo has to wait for responses of more potentially slow DHT servers, increasing the tail latency. If some servers are unresponsive, we need to wait for a timeout before trying another peer.

The relevant logic is implemented in go-libp2p-kad-dht.

Also see recent IPNS study from @probe-lab.

A solution to reduce IPNS resolution time could be to lower the quorum (wait for fewer responses), trading off robustness against stale records. This change would need to be discussed in the specs repo.

Thank you! I just needed to make sure that the behavior is expected. Before on large provider it felt faster. Well it WAS faster because after changing to self host my users said for the first time "hey why is it taking so long to launch the program" - and it checks for updates every start via resolving VERSION in IPNS. But I ultimately decided that selfhost is more adult decision and most importantly more within the initial IPFS philosophy, while automatic update checks can be turned off manually. If you are the engineer then it is you who should decide what is more important here. 30 seconds is sometimes scary especially for new users but bearable, if it was more than a minute then it would be horrible. I remain ticket open here just for people to know and for other devs to see my measurements if you want you can close it anytime.

Chara-Freedom avatar Apr 28 '26 11:04 Chara-Freedom

Thanks for the report and the videos. Building on @guillaumemichel's reply: this is not a kubo bug, but I think we can pinpoint why your IPNS path feels so much slower than the IPFS path, and it is fixable on your (the publisher) side.

I pulled your IPNS record off the network with curl -H 'Accept: application/vnd.ipfs.ipns-record' https://delegated-ipfs.dev/routing/v1/ipns/k51qzi5uqu5dldod6robuflgitvj276br0xye3adipm3kc0bh17hfiv1e0hnp4 and ran ipfs name inspect on it:

Value:    /ipfs/bafybeifr4p66hipivokkiqrryg2vf4fy2ezj5dqjjhr4kcel3z4g67nimm
TTL:      1m   (60000000000 ns)
Validity: 9012-08-21T09:24:03.434Z
Sequence: 469

The line that matters is TTL = 1m. Did you change the default and not mentioned it in bug report?

FYSA the kubo default for ipfs name publish --ttl is 5m, and gateways cache resolved IPNS records for the duration the record itself advertises (subject to their own Ipns.MaxCacheTTL cap).

With a 1-minute TTL, every public-gateway cache entry for your name expires after 60 seconds, so any visitor who lands more than a minute after the previous one forces the gateway to re-check the DHT for IPNS record update.

That re-walk is exactly the path Gui described: wait for 16/20 quorum responses from the closest DHT servers to your key, and on a slow tail you can comfortably hit ~30s.

The /ipfs/<cid> path does not pay this cost, because content routing can short-circuit the moment a single working provider responds, and once any gateway has the block it serves it from local cache.

So if yo uwant to avoid this overhead, and get IPNS closer to IPFS, and yo udont update data often, bump TTL to avoid unnecessary IPNS lookup delays.

Two other things in the record, neither directly tied to the speed problem but worth flagging:

  • Validity: 9012-08-21 (year 9012 🙃 ). Kubo defaults to now + 48h. A multi-millennium lifetime is highly unusual and means a leaked or stolen private key produces a record that any resolver will accept forever, allowing attackers to pollute DHT with old records.
  • Sequence: 469. You are republishing often. Fine, but each publish does its own DHT put, so the publishing side pays a recurring cost.

Things to try, in order of impact:

  1. Republish with a sane TTL and lifetime so caches actually hold the record:

    ipfs name publish --key=<key> --ttl=1h --lifetime=48h /ipfs/<cid>
    

    With --ttl=1h (or even the default 5m), once dweb.link or any other resolver has answered once, subsequent visitors get the cached value in milliseconds. You only pay the DHT walk on the first cold hit per cache window. This alone should eliminate the 30-second feel for everyone except the unlucky first visitor in each window.

  2. Calibrate the Pinata vs dweb.link comparison. dweb.link is a free public-good gateway with shared capacity and no SLA, and it is being phased out this year in favor of in-browser approaches like https://inbrowser.link. Pinata is a commercial service with provisioned resources and tuned resolvers behind a paid plan, so it will always win on tail latency. Numbers you collect against dweb.link today will not carry forward.

  3. For nodes you control, enable IPNS-over-PubSub. When publisher and resolver are both your own kubo nodes, set Ipns.UsePubsub to true on both ends and republish. This delivers sub-second IPNS resolution between subscribed peers, with DHT fallback for everyone else.

    • Config: https://github.com/ipfs/kubo/blob/master/docs/config.md#ipnsusepubsub
    • Spec: https://specs.ipfs.tech/ipns/ipns-pubsub-router/

For the trust-and-resilience side, the IPNS record spec covers the threat model that motivates the 16/20 quorum, but you can always speed this up by deploying your own nodes that follow your names on pubsub and dht.

Hope the above helps you / others who find this :-)

I'm closing this, as user set custom --ttl + kubo is not responsible for performance of centralized gateways like dweb.link

lidel avatar Apr 28 '26 14:04 lidel

@lidel thank you! Just to follow up, 60 seconds ttl is not a Kubo default value, but it is an IPNS inspector default value, in which this record was firstly written one year ago. Now it is being republished by Kubo. You can change the default in IPNS inspector.

Image

Chara-Freedom avatar Apr 28 '26 22:04 Chara-Freedom

Also, you mentioned Pinata, but last time when I checked Pinata did not support IPNS.

Chara-Freedom avatar Apr 28 '26 22:04 Chara-Freedom