Comparing HTTP and FTP for transferring files

前端 未结 6 1540
既然无缘
既然无缘 2020-11-28 01:51

What are the advantages (or limitations) of one over the other for transferring files over the Internet?

(I am aware of secure forms of both protocols. I\'d like to

相关标签:
6条回答
  • 2020-11-28 02:09

    One advantage of FTP is that there is a standard way to list files using dir or ls. Because of this, ftp plays nice with tools such as rsync. Granted, rsync is usually done over ssh, but the option is there.

    0 讨论(0)
  • 2020-11-28 02:17

    Here's a performance comparison of the two. HTTP is more responsive for request-response of small files, but FTP may be better for large files if tuned properly. FTP used to be generally considered faster. FTP requires a control channel and state be maintained besides the TCP state but HTTP does not. There are 6 packet transfers before data starts transferring in FTP but only 4 in HTTP.

    I think a properly tuned TCP layer would have more effect on speed than the difference between application layer protocols. The Sun Blueprint Understanding Tuning TCP has details.

    Heres another good comparison of individual characteristics of each protocol.

    0 讨论(0)
  • 2020-11-28 02:17

    I just benchmarked a file transfer over both FTP and HTTP :

    • over two very good server connections
    • using the same 1GB .zip file
    • under the same network conditions (tested one after the other)

    The result:

    • using FTP: 6 minutes
    • using HTTP: 4 minutes
    • using a concurrent http downloader software (fdm): 1 minute

    So, basically under a "real life" situation:

    1) HTTP is faster than FTP when downloading one big file.

    2) HTTP can use parallel chunk download which makes it 6x times faster than FTP depending on the network conditions.

    0 讨论(0)
  • 2020-11-28 02:17

    One consideration is that FTP can use non-standard ports, which can make getting though firewalls difficult (especially if you're using SSL). HTTP is typically on a known port, so this is rarely a problem.

    If you do decide to use FTP, make sure you read about Active and Passive FTP.

    In terms of performance, at the end of the day they're both spewing files directly down TCP connections so should be about the same.

    0 讨论(0)
  • 2020-11-28 02:22

    Both of them uses TCP as a transport protocol, but HTTP uses a persistent connection, which makes the performance of the TCP better.

    0 讨论(0)
  • 2020-11-28 02:30

    Many firewalls drop outbound connections which are not to ports 80 or 443 (http & https); some even drop connections to those ports that are not HTTP(S). FTP may or may not be allowed, not to speak of the active/PASV modes.

    Also, HTTP/1.1 allows for much better partial requests ("only send from byte 123456 to the end of file"), conditional requests and caching ("only send if content changed/if last-modified-date changed") and content compression (gzip).

    HTTP is much easier to use through a proxy.

    From my anecdotal evidence, HTTP is easier to make work with dropped/slow/flaky connections; e.g. it is not needed to (re)establish a login session before (re)initiating transfer.

    OTOH, HTTP is stateless, so you'd have to do authentication and building a trail of "who did what when" yourself.

    The only difference in speed I've noticed is transferring lots of small files: HTTP with pipelining is faster (reduces round-trips, esp. noticeable on high-latency networks).

    Note that HTTP/2 offers even more optimizations, whereas the FTP protocol has not seen any updates for decades (and even extensions to FTP have insignificant uptake by users). So, unless you are transferring files through a time machine, HTTP seems to have won.

    (Tangentially: there are protocols that are better suited for file transfer, such as rsync or BitTorrent, but those don't have as much mindshare, whereas HTTP is Everywhere™)

    0 讨论(0)
提交回复
热议问题