Torrent Piece Size

From VuzeWiki
Jump to: navigation, search

How big should the pieces in a torrent be?

Contents

[edit] Why does size matter?

  1. BitTorrent works with pieces.
    • The size of the torrent file itself is proportional to the number of pieces. The more pieces, the bigger. Anyone distributing or hosting torrent files will want to keep them small.
    • The data is sliced up in pieces so you can get small amounts of verifiable data from several peers at a time. Each time a piece is fully downloaded, it will be checked (using the SHA1 algorithm) against what the torrent file tells your client it should be.
    • The protocol relies on the spreading of pieces in the swarm. The "tit-for-tat" mechanism works great, but only when you have some data already. So the first pieces are generally the hardest to get. The smaller the pieces, the easier they are to get.
  2. BitTorrent works with pieces all the time.
    • The rule for choosing which piece to download next is rarest first, and random if all the pieces are equally available. So the BT client has to collect every piece each peer it is connected to has, compute their availability and choose the piece to download. And that, each time it has to choose a new piece. The more pieces, the more RAM and CPU.
    • Each time a piece is received, a "HAVE" message is sent to all the peers you're connected to let them know you have that piece. The more pieces, the more bandwidth "wasted" in protocol data.

[edit] The right size

The size of the torrent file, the amount of RAM and CPU used and the waste of bandwidth point towards a big piece size. Taking into account the difficulty to get the first pieces, that size decreases.

All in all, a torrent should have around 1000-1500 pieces, to get a reasonably small torrent file and an efficient client and swarm download.

On the other hand, too large pieces (4 MB and larger) can slow down piece distribution, as a single piece will have 256 or more 16 kB "blocks", which are the actual smallest transmission units in the bittorent protocol. That will lead to rather large "transmission-in-progress" data amounts (unfinished pieces) for each client. One should consider very carefully before creating piece sizes over 1 MB even for large torrents.

Examples
File size 350MB 700MB 1400MB
Piece size 64kB 256kB 512kB 64kB 1MB
Number of pieces 5600 1400 700 11200 1400
Torrent size 120kB 30kB 15kB 240kB 30kB