Where does IPFS store all the data?

Aneesh Kumar picture Aneesh Kumar · Nov 23, 2017 · Viewed 10.4k times · Source

I've been trying to implement and understand the working of IPFS and have a few things that aren't clear.

Things i've tried:
Implemented IPFS on my system and stored files on it. Even if I delete the files from my system and close the ipfs daemon, I am still able to access the files from a different machine through IPFS.
I've noticed there's a .ipfs folder in my home directory that contains the part of blocks of data that i add to IPFS.

Questions:
1. Are the blocks stored locally on my system too?
2. Where else is the data stored? On other peers that I am connected to? Because I'm still able to access the file if I close my ipfs daemon.
3. If this is true, and data is stored at several places, possibility of losing my data is still there, if all the peers disconnect from the network?
4. Does every peer on the network store the entire file or just a part of the file?
5. If copy of data is being distributed across the p2p network, it means the data is being duplicated multiple times? How is this efficient in terms of storage?
6. We store data uploaded by other peers too?
7. Minimum System requirements for running IPFS? We just need abundant storage, not necessarily a powerful system?

Thanks in Advance!

Answer

G. M. picture G. M. · Dec 19, 2017

When you upload something, the file is chunked by ipfs and stored in your cache folder (.ipfs).

If you check the file existance on another peer of the network (say the main gateway, ipfs.io) that peer requests the file from you and caches it too.

If later you switch off your daemon and you can still see the file on the gateway it's probably because the gateway or some other peer on the web still has it cached.

When a peer wants to download a file but it's out of memory (it can no longer cache), it trashes the oldest used files to free space.

If you want to dive deep into the technology, check first these fundamentals:

  • how git works
  • decentralized hash tables (DHT)
  • kademlia
  • merkle trees

The latter should give you an idea of how the mechanism works more or less.

Now, let's answer point by point

  1. Yes
  2. All the peers that request your file cache it
  3. You lose the file when it's no longer possible to reconstitute your file from all the peers that had a part of it cached (including yourself)
  4. One can get just a part of it, imagine you are watching a movie and you stop more, or less, at the half... that's it, you've cached just half of it.
  5. When you watch a video on YouTube your browser caches it (that means a replication!)... ipfs is more efficient in terms of traffic, let's say you switch off the browser and 2 minutes later you want to watch it again. Ipfs gets it from your cache, YouTube makes you download it again. There's also an interesting matter on the delta storage (related to git) and from where you get it (could be inside your lan... that means blazing fast) but I want to stick to the questions.
  6. If you get data, you cache it so...
  7. The main daemon is written in go. Go is efficient but not as much as writing it on C++, C, Rust... Also, the tech is pretty young and it will improve with time. The more space you have the more you can cache, CPU power isn't THAT important.

If you are interested in ways to store data in a p2p manner, here some links to interesting projects.