You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our typical request pattern for data on the gateway looks like this: /ipfs/bafy...cid/somefile.txt (or bafy...cid.w3s.link/somefile.txt through w3s link). When we upload, even for individual files we wrap them in a folder with one item just so they can be addressed by name
This means the steps to get to first byte are as follows:
o all content claims lookups to identify where we are pulling data from
then -
Fetch cid bafy...cid which represents the folder containing somefile.txt, so that we can determine the verifiable cid for somefile.txt (let's call that bafy...file)
Fetch cid bafy...file to get the root block of the file, which in UnixFS contains NO raw data, but rather is a list of sub-blocks that contain the file (let's call those bafy...bytes1 and bafy...bytes2)
Finally, fetch the first raw data blocks, at which point we can finally send first byte.
Step 1 is a process we are trying optimize through the indexer.
2-4 however are 3 http roundtrips, which is just not realistic to get to first byte. Two of the round trips for typically small blocks that simply point us to the next link. It's made worse cause of #299, where some of those round trips are taking multiple seconds.
The proposed solution is as follows:
use cloudflare KV to cache these blocks or even better, simply the paths within them.
After first fetch, the following entry
Key: bafy...cid/somefile.txt/0-1000000
Value: baby...bytes1
Is sufficient to eliminate 2 of the 3 round trips on next request.
This should be relatively few lines of code but will require some knowledge of UnixFS, UnixFS exporter, and Dagula to do. Recommend if a newer dev is assigned that we pair with a experienced dev on repo guidance.
The KV should have a longer lifespan and eventually global distribution.
Acceptance criteria
Demonstrate traces in honeycomb
make a request with a typical 3 round trip requirement for the first time and take the typical 3 round trips to fetch data
make a second round trip request and verify only a single round trip is made before first bytes are sent
Note: you may need to disable caching of the whole request to demonstrate this behavior in test.
The text was updated successfully, but these errors were encountered:
What
Our typical request pattern for data on the gateway looks like this:
/ipfs/bafy...cid/somefile.txt
(orbafy...cid.w3s.link/somefile.txt
through w3s link). When we upload, even for individual files we wrap them in a folder with one item just so they can be addressed by nameThis means the steps to get to first byte are as follows:
bafy...cid
which represents the folder containingsomefile.txt
, so that we can determine the verifiable cid forsomefile.txt
(let's call thatbafy...file
)bafy...file
to get the root block of the file, which in UnixFS contains NO raw data, but rather is a list of sub-blocks that contain the file (let's call thosebafy...bytes1
andbafy...bytes2
)Step 1 is a process we are trying optimize through the indexer.
2-4 however are 3 http roundtrips, which is just not realistic to get to first byte. Two of the round trips for typically small blocks that simply point us to the next link. It's made worse cause of #299, where some of those round trips are taking multiple seconds.
The proposed solution is as follows:
use cloudflare KV to cache these blocks or even better, simply the paths within them.
After first fetch, the following entry
Key:
bafy...cid/somefile.txt/0-1000000
Value:
baby...bytes1
Is sufficient to eliminate 2 of the 3 round trips on next request.
This should be relatively few lines of code but will require some knowledge of UnixFS, UnixFS exporter, and Dagula to do. Recommend if a newer dev is assigned that we pair with a experienced dev on repo guidance.
The KV should have a longer lifespan and eventually global distribution.
Acceptance criteria
Demonstrate traces in honeycomb
Note: you may need to disable caching of the whole request to demonstrate this behavior in test.
The text was updated successfully, but these errors were encountered: