OriginProtocol / origin-bridge

We've moved to a monorepo: https://github.com/OriginProtocol/origin/tree/master/infra/bridge
MIT License
15 stars 7 forks source link

Images in the IPFS data #18

Closed Gzing closed 6 years ago

Gzing commented 6 years ago

While pulling in IPFS data and keying that in DB was working fine, there is a performance degradation on the API side due to heavy image data in the payloads. Can we offload the images to S3 and save url's into the db?

Gzing commented 6 years ago

Is pretty straight forward to implement and seems like the right way to go, just wanted to check with everyone. OR we could not store the IPFS image data on the indexing server at all, and let the frontend get the images directly from IPFS.

joshfraser commented 6 years ago

Realize we already have Sendgrid and Twilio dependencies, but trying not to add more third-party dependencies than absolutely necessary so folks can easily run their own bridge servers without needing to signup for too many third-party services.

Feels like the images should probably be stored on IPFS and the listing JSON should include an array of IPFS hashes instead of the raw image data.

ambertch commented 6 years ago

I came across this as well when setting up the bridge server.

Where should the image IPFS hashes be stored?

DanielVF commented 6 years ago

We'll be storing the image hashes in the listing's IPFS data. We can later build something to send along the images from the query server as a part of the results, so we don't pay a latency price.

ambertch commented 6 years ago

So, an alternative to uploading the images to IPFS, then writing their hashes into the listing and uploading listing, might be adding everything into a folder and then uploading the folder.

I'm unsure if this can be done through a web client, although one benefit of this alternative implementation is that we don't essentially have X different objects around IPFS, just one folder to represent a listing.

wanderingstan commented 6 years ago

I'm late to this party and just catching up.

@Gzing: what sort of performance degradation are we talking about? Would it be acceptable for just the current test listings that we created with the images stored as data:/ URIs?

@ambertch: The "additional roundtrip to fetch the images" is not such a bad thing; it's the way HTML references images after all. The actual image data is really only needed by the browser, which is already does it this way.

EDIT: @ambertch : Great idea to upload all listing data as a "folder" if such a thing is possible from web client.

Gzing commented 6 years ago

dweb or ipfs are OK. data URI's are heavy, and current IPFS blobs weight ~1.5MB's each due to the images. If we are loading 10 test listing from bridge server with that kind of data, it's a single response/request cycle for building up the list and downloading ~10-15MB's of data.

Might be OK for now, if we are planning to just use these in the list detail endpoints.

tomlinton commented 6 years ago

I've started working on this - just wanted to confirm a few things and make sure I haven't missed any discussions on this. As I understand this is what we want:

Sound good? :smiley_cat:

wanderingstan commented 6 years ago

That sounds exactly right, @tomlinton ! I could never get a clear read on whether dweb: or ipfs: was preferred, but we might as well handle both.

We should make a parallel issue for modifying the listing creation process to store the images in ipfs, and then dweb:/ipfs: URIs in the listing json. (Or did you want to cover this also in this issue/PR)

tomlinton commented 6 years ago

Thanks @wanderingstan! I'll go with ipfs: by default but handle both. I'll cover the changes to creation in the same PR.

tomlinton commented 6 years ago

Done by #320.