When using a Virtual Private Server (VPS), you may come across two network protocols: TCP and UDP. Both send data over the internet, but they work differently.
Understanding these differences can help you choose the right protocol for your websites, applications, and other VPS services.
What is TCP?
TCP (Transmission Control Protocol) is a network protocol that makes sure data arrives correctly and in the right order. Before sending data, TCP creates a connection between the client and the server. It also checks whether the data arrived and resends it if something gets lost along the way.
TCP is commonly used for the following VPS services:
SSH (port 22): Securely connecting to and managing your VPS.
HTTP (port 80): Loading websites over standard HTTP connections.
HTTPS (port 443): Loading secure websites using HTTP/1.1 or HTTP/2.
SMTP (port 25): Sending emails between mail servers.
MySQL (port 3306): Connecting to databases.
TCP is a good choice for services where receiving all data in the correct order is important.
What is UDP?
UDP (User Datagram Protocol) is a network protocol that sends data without creating a connection first. Unlike TCP, UDP does not check whether data has arrived or automatically resend missing data. It also does not guarantee that data will arrive in the correct order. This makes UDP simpler and reduces the amount of work needed to send data. However, applications must handle missing or out-of-order data themselves if needed.
UDP is commonly used for the following VPS services:
DNS (port 53): Looking up domain names and their IP addresses.
WireGuard (commonly port 51820): Creating secure VPN connections.
Online game servers: Sending real-time game updates.
VoIP: Making voice calls over the internet.
HTTP/3 (UDP port 443): Loading websites using QUIC, which adds its own security and reliable delivery features.
UDP is a good choice for services that need to send data quickly or manage data delivery themselves.
TCP vs UDP: Key Differences
TCP and UDP differ in several important ways:
Connection: TCP creates a connection before sending data, while UDP sends data without one.
Reliability: TCP makes sure data arrives correctly, while UDP does not guarantee delivery.
Data order: TCP keeps data in the correct order, while UDP data may arrive out of order.
Lost data: TCP automatically resends missing data, while UDP leaves this task to the application.
Overhead: TCP uses more resources to manage data delivery, while UDP has less overhead.
Latency: TCP may delay delivery when it resends lost data, while UDP is often better suited for real-time communication.
Data format: TCP sends data as a continuous stream of bytes, while UDP sends separate packets.
Common VPS uses: TCP is commonly used for SSH, websites, and databases, while UDP is often used for DNS, VPNs, and voice calls.
Which protocol should you use on a VPS?
The right protocol depends on what you want to run on your VPS. Some examples of protocols we use.
For websites, TCP is used by HTTP/1.1 and HTTP/2. However, HTTP/3 uses UDP through a protocol called QUIC. This means modern websites may use both TCP and UDP on port 443.
For databases, TCP is usually the better option because database connections need reliable, in-order data delivery.
For VPNs, the protocol depends on the VPN software. WireGuard uses UDP, while OpenVPN supports both TCP and UDP.
Does UDP make a VPS faster?
Not always.
UDP has less overhead than TCP because it does not create a connection before sending data or automatically resend missing packets. However, that doesn't mean UDP will always be faster. Network traffic, packet loss, server performance, and application design can all affect speed. For example, a well-configured application using TCP can perform better than a poorly configured application using UDP.
The main difference is simple: TCP focuses on reliable data delivery, while UDP focuses on sending data with less overhead and fewer built-in delivery rules. Both protocols are useful on a VPS. You do not need to choose one for your entire server. Instead, use TCP or UDP based on each service's requirements.
Conclusion
TCP and UDP are both important network protocols, but they serve different purposes. TCP provides reliable data delivery, making it a good choice for websites, SSH, and databases. UDP has less overhead and is often better suited for gaming, VPNs, and real-time communication.
When using a VPS, the best choice depends on the services you run and their network requirements.
