Q&A
FTP vs. HTTP
Overview
Both protocols move data over the internet, but they were designed for different jobs. FTP is a dedicated file-transfer protocol with a distinctive dual-connection design. HTTP is the foundation of the web - a simple, stateless protocol for fetching and submitting resources. Understanding their architectural differences clarifies when each is appropriate.
graph TD
A[Transfer data over TCP] --> B[FTP: dedicated file transfer]
A --> C[HTTP: web resource request/response]
B --> B1[Two connections: control + data]
B --> B2[Stateful session, up/download]
C --> C1[Single connection, stateless]
C --> C2[Request methods: GET/POST/...]
style C fill:#1e1b4b,color:#fff
FTP (File Transfer Protocol)
- Purpose: transfer files (upload and download) between client and server.
- Connections: uses two - a control connection (port 21) for commands, and a separate data connection (port 20 in active mode, or a negotiated port in passive mode) for the file bytes.
- State: maintains a session - you log in, change directories, list files, transfer, log out.
- Auth: username/password (or anonymous). Plain FTP sends credentials and data unencrypted.
- Modes: active vs passive (passive is firewall-friendly, with the server providing a port the client connects to).
- Secure variants: FTPS (FTP over TLS) and SFTP (SSH File Transfer Protocol - a different protocol over SSH, despite the similar name).
HTTP (HyperText Transfer Protocol)
- Purpose: request and deliver web resources - HTML, images, APIs, downloads.
- Connections: a single connection per request-response (with keep-alive/multiplexing in HTTP/1.1 and HTTP/2).
- State: stateless - each request is independent; state is layered on via cookies/tokens.
- Methods:
GET,POST,PUT,DELETE, etc., with status codes (200, 404, 500…). - Secure variant: HTTPS (HTTP over TLS) - now the norm.
- Metadata: rich headers (content type, caching, compression, ranges).
Side-by-Side
| Dimension | FTP | HTTP |
|---|---|---|
| Primary purpose | File transfer | Web resources / request-response |
| Connections | Two (control + data) | One |
| State | Stateful session | Stateless |
| Default ports | 21 (control), 20 (data) | 80 (HTTP), 443 (HTTPS) |
| Direction | Upload & download equally | Mainly download (GET); upload via POST/PUT |
| Encryption | None by default (FTPS/SFTP add it) | HTTPS standard |
| Resume/partial | Yes | Yes (HTTP Range requests) |
| Best for | Bulk/legacy file transfer | Web, APIs, most downloads |
When to Use Which
- HTTP/HTTPS for virtually all modern needs: websites, APIs, file downloads (a download link is just an HTTP GET), and even uploads (multipart POST). It's firewall-friendly, encrypted, and ubiquitous.
- FTP/SFTP for legacy systems, large batch file transfers between servers, or workflows already built around FTP. For anything new requiring secure file transfer, prefer SFTP or HTTPS over plain FTP.
Security Note
Plain FTP transmits credentials and file contents in clear text - a serious risk on untrusted networks. Use SFTP (over SSH) or FTPS (over TLS) instead, or deliver files over HTTPS. This security difference is often the deciding factor today.
Why This Matters in Interviews
Networking/systems interviews use this to test protocol fundamentals. Key points: both are TCP application-layer protocols; FTP's distinctive two-connection (control + data) design and stateful sessions vs HTTP's single-connection, stateless request-response; default ports; and the security gap (plain FTP is unencrypted → use SFTP/FTPS/HTTPS). Knowing active vs passive FTP modes and that SFTP is actually an SSH-based protocol (not "FTP with S") are strong details.
Common Pitfalls
- Thinking SFTP is just "secure FTP" - it's a distinct SSH-based protocol, not FTPS.
- Forgetting FTP uses two connections (a frequent gotcha and the source of firewall issues).
- Assuming plain FTP is secure (it isn't - credentials/data are clear text).
- Overlooking that HTTP can do uploads (POST/PUT) and resumable/partial downloads (Range).
References
- HTTP overview (MDN): https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
- FTP (RFC 959): https://www.rfc-editor.org/rfc/rfc959