This article kicks off the Networking and Optimization Series, a sub-series within the Foundations Series, focusing on essential protocols and techniques that ensure seamless data transmission and network performance. Our journey begins with TCP, the backbone of reliable communication, where we’ll explore its fundamentals, throughput calculation, and optimization techniques for modern cloud environments.
TCP, or Transmission Control Protocol, is extensively utilized for ensuring dependable data transmission across the Internet. This protocol governs the connection between two devices engaged in data exchange and oversees the division of application data into packets. Moreover, TCP is responsible for sending and receiving packets while managing their flow. Additionally, it addresses dropped packets by retransmitting them and verifies the status of received packets.
TCP has three key features that are essential to understand:
Nevertheless, TCP was initially developed for conventional networks and may not be well-suited for cloud environments. In the cloud, factors such as latency, bandwidth, congestion, and packet loss can fluctuate significantly. As a result, applications and services operating in the cloud might require the implementation of TCP optimization methods to improve their performance, scalability, and user experience.
Throughput is commonly quantified by the volume of data transmitted per unit of time, such as bits or bytes per second. Achieving a higher throughput entails sending a greater amount of data in a shorter duration. TCP incorporates flow control and windowing mechanisms, leading to variations in TCP throughput over the course of data transmission. Let's delve into the process of calculating TCP throughput between a client and a server.
For instance, as depicted in the figure above, there exists a client and a server with a link speed of 100Mbps. The round-trip time between the client and server is 40ms. Despite the availability of 100Mbps bandwidth on the link, the client experiences slow download speeds while attempting to retrieve files from the server. Consequently, it will still require time to complete file downloads.
It may be beneficial to conduct a packet capture between the client and server in order to gain further insight into the current throughput of this transfer. The capture can be executed on either the client or intermediate nodes. The primary objective of the packet capture is to determine the TCP window that the client transmits to the server. For instance, we have observed that the TCP window sent by the client to the server is 65000 bytes, as illustrated in the figure above. It's important to note that TCP window size is always expressed in bytes. You can refer to TCP header for a detailed understanding of TCP fields.
TCP throughput(bps) = Window Size(bits) / RTT (sec)
TCP throughput: Speed calculated in bits per second.
Window Size: As bits in bps. Convert the window bytes to bits i.e. multiply by 8.
RTT: Round trip time measured in milliseconds. Covert to second i.e. divide by 1000. Finally, let’s add the figures discussed in this formula to get the TCP throughput
Window Size in bits: 65000*8 = 520000 bits
RTT in seconds: 40/1000 = 0.04
520000/0.04 = 13000000 bps which is 13Mbps
Therefore, based on the calculation above, we can determine that with a window size of 65000 bytes and an RTT of 40ms, the throughput is approximately 13Mbps. This value is significantly lower than the capacity of the link. Despite the server's ability to transmit more data over the network, the reduced window size communicated by the client has led to fewer bytes in transit, consequently slowing down the download speed. To address this issue and enhance TCP throughput, it may be necessary to make adjustments to the TCP window size on the client side.
Based on the explanation of TCP throughput above. We can see there are so many techniques to optimize TCP throughput.
The process involves adjusting the parameters and settings of TCP to align with the characteristics and demands of the cloud network. To enhance the throughput, latency, and reliability of TCP connections, we can fine-tune the following parameters:
This process involves transferring TCP processing tasks from the application server to a specialized device, like a network interface controller (NIC), load balancer, or proxy server. This can be highly beneficial as it helps to alleviate resource constraints on the system and enables it to manage additional connections.
This technique aims to decrease latencies and address TCP issues by dividing a connection that would result in a high round-trip time into smaller segments. Split TCP allows the client's TCP connection to end within a server’s proximity to the user, while a distinct TCP connection is set up to the origin, potentially having a significant round-trip time (RTT). The diagram below depicts how three users from various geographical locations connect to a server close to their respective locations. Subsequently, the server maintains an enduring connection with the origin in Europe.
Establishing a TCP connection involves 3-5 roundtrips from the client to the server. The architecture of the server plays a crucial role in optimizing this process. By minimizing the number of round trips, "short connections" between end users and servers reduce latency, resulting in improved performance. On the other hand, "long connections" between servers and origins can be pre-established and reused for multiple user requests to enhance connectivity efficiency. Notably, when setting up an SSL/TLS (Transport Layer Security) connection, Split TCP's impact is amplified due to additional round trips required for securing the connection.
These protocols are designed to enhance performance and functionality compared to TCP for specific cloud scenarios and applications. Consider the case of an eCommerce website as an example.
This approach involves assessing the functionality, performance, and reliability of TCP in a network environment. It includes simulating various scenarios to evaluate TCP connection behavior and measure parameters such as throughput, latency, and packet loss. Conducting TCP tests can help identify issues, optimize settings, and ensure reliable and efficient connections for smooth communication and data transfer. By using tools like synthetic monitoring or methods to test latency, bandwidth, throughput, packet loss, jitter, and retransmission rate of TCP connections we can enhance network performance and validate implementations across devices and platforms.:
These tools enable us to monitor the establishment of low-level TCP connections on specific ports of designated hosts. This ensures the availability of important services like SSH (22), HTTP (80), HTTPS (443), and any custom microservices operating on other ports.
In summary, conducting TCP testing can assist in pinpointing and understanding the underlying issues related to TCP, as well as confirming and validating the impacts of TCP optimization methods. Understanding TCP is just the beginning. Reliable communication across the Internet also relies on protocols like the Domain Name System (DNS), which acts as the Internet’s address book. In our next article, part of the Networking and Optimization Series, we’ll explore how DNS resolves domain names into IP addresses, its role in cloud performance, and tips to optimize it for modern environments.
The Genesis Cloud team 🚀
Never miss out again on Genesis Cloud news and our special deals: follow us on Twitter, LinkedIn, or Reddit. Sign up for an account with Genesis Cloud here.
If you want to find out more, please write to contact@genesiscloud.com.