12-point comparison of FTP protocol and HTTP protocol (file upload/download)

Original link: https://www.oschina.net/news/28162/http-vs-ftp

Many sites, such as facebook or some blogs, allow users to upload or download files, such as images from forums or blog systems. In this case, there are usually two options for uploading files to the server, that is FTP protocol and HTTP protocol.

Here are some differences between the two:

1. The HTTP protocol is used to browse websites, while FTP is used to access and transfer files. FTP file transfer means uploading and maintaining websites in batches, while HTTP file transfer is more about providing file transfer for end users, such as Movies, pictures, music, etc.

2. HTTP and FTP clients: The usual HTTP client is a browser, and the FTP service can be accessed through the command line or the user's own GUI client.

3. HTTP header: HTTP header contains metadata, such as the date of last change, encoding method, server name version and other information, which do not exist in FTP.

4. FTP appeared about 10 years earlier than HTTP.

5. Data format: FTP can transmit ACSII data or data in binary format, while HTTP only uses binary format.

6. Pipelining in HTTP: HTTP supports pipelining, which means that the client can send the next request before the previous request is processed. The result is that some server-client round-trip delays are saved before requesting data multiple times. FTP does not have this support.

7. Dynamic ports in HTTP: One of the biggest problems with FTP is that it uses two connections. The first connection is used to send control commands. When receiving or sending data, it opens a second TCP connection. Whereas HTTP uses dynamic ports in both directions.

8. Persistent connections in HTTP: For an HTTP session, a client can maintain a single connection and use it for any number of data transfers. FTP creates a new connection every time there is data needed. The experience of repeatedly creating new connections is not good, because each time a connection is created, both parties have to handshake for verification, which consumes a lot of time.

9. Compression algorithm in HTTP: HTTP provides a way for the client and the server to negotiate and choose among some compression algorithms. Among them, gzip is arguably the most influential one, and such a complex algorithm does not exist in FTP.

10. HTTP supports proxy: A great feature of HTTP is that it supports proxy. This function is built in the protocol, but FTP does not support it.

11. What makes FTP stand out is that this protocol is directly oriented to the file level. This means that FTP has, for example, a command to list directories on a remote server, whereas HTTP does not have this concept.

12. Speed: Probably the most common question: which one transfers faster?

什么使FTP服务更快?

1、没有在发出的数据中加入meta-data,仅传输原二进制文件。

2、没有过度的分块编码

什么使HTTP服务更快?

1、重用已存在的持久连接,从而有更好的TCP表现。

2、流水线的支持使得从同一个服务器上请求多个文件更快。

3、自动的压缩机制使得传输的数据更少。

4、没有命令/应答机制最大限度的减少了往返时延。

总结:当然最终的结果会因具体的情况而异,但我想说的是,单次传输一个静态的文件,很难衡量两者的区别。
对单个的小文件来说,FTP传输更快,当传输多个文件时,HTTP更快。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325710823&siteId=291194637