Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCP Vs. Http Benchmark

Tags:

http

tcp

I am having a Web application sitting on IIS, and talking with [remote]Service-Machine. I am not sure whether to choose TCP or Http, as the main protocol.

more details:

  1. i will have more than one service\endpoint
  2. some of them will be one-way
  3. the other will be two-ways
  4. the web pages will work infront of the services
  5. we are talking about hi-scale web-site

I know the difference pretty well, but I am looking for a good benchmark, that shows how much faster is the TCP?

like image 726
rabashani Avatar asked Jul 28 '09 20:07

rabashani


People also ask

Which is faster TCP or HTTP?

In theory, an optimally designed / implemented solution using TCP will be faster than one that uses HTTP.

Which is better TCP or HTTP?

The Main Differences Between HTTP and TCP HTTP typically uses port 80 – this is the port that the server “listens to” or expects to receive from a Web client. TCP doesn't require a port to do its job. HTTP is faster in comparison to TCP as it operates at a higher speed and performs the process immediately.

What's the difference between TCP and HTTP?

HTTP is a Hypertext Transfer Protocol, whereas TCP full form is Transmission Control Protocol. HTTP is utilized to access websites, while TCP is a session establishment protocol between client and server. HTTP uses port 80 and TCP uses no port. HTTP doesn't need authentication, whereas, TCP uses the TCP-AO.

Does HTTP go over TCP?

Designed in the early 1990s, HTTP is an extensible protocol which has evolved over time. It is an application layer protocol that is sent over TCP, or over a TLS-encrypted TCP connection, though any reliable transport protocol could theoretically be used.


2 Answers

HTTP is a layer built ontop of the TCP layer to some what standardize data transmission. So naturally using TCP sockets will be less heavy than using HTTP. If performance is the only thing you care about then plain TCP is the best solution for you.

You may want to consider HTTP because of its ease of use and simplicity which ultimately reduces development time. If you are doing something that might be directly consumed by a browser (through an AJAX call) then you should use HTTP. For a non-modern browser to directly consume TCP connections without HTTP you would have to use Flash or Silverlight and this normally happens for rich content such as video and/or audio. However, many modern browsers now (as of 2013) support API's to access network, audio, and video resources directly via JavaScript. The only thing to consider is the usage rate of modern web browsers among your users; see caniuse.com for the latest info regarding browser compatibility.

As for benchmarks, this is the only thing I found. See page 5, it has the performance graph. Note that it doesn't really compare apples to apples since it compares the TCP/Binary data option with the HTTP/XML data option. Which begs the question: what kind of data are your services outputting? binary (video, audio, files) or text (JSON, XML, HTML)?

In general performance oriented system like those in the military or financial sectors will probably use plain TCP connections. Where as general web focused companies will opt to use HTTP and use IIS or Apache to host their services.

like image 62
Darwyn Avatar answered Sep 20 '22 17:09

Darwyn


The question you really need an answer for is "will TCP or HTTP be faster for my application". The answer is that it depends on the nature of your application, and on the way that you use TCP and/or HTTP in your application. A generic HTTP vs TCP benchmark won't answer your question, because the chances are that the benchmark won't match your application behaviour.

In theory, an optimally designed / implemented solution using TCP will be faster than one that uses HTTP. But it may also be considerably more work to implement ... depending on the details of your application.

There are other issues that might affect your choice. For example, you are less likely to run into firewall issues if you use HTTP than if you use TCP on some random port. Another is that HTTP would make it easier to implement a load balancer between the IIS server and the backend systems.

Finally, at the end of the day it is probably more important that your system is secure, reliable, maintainable and (maybe) scalable than it is fast. A sensible strategy is to implement the simple version first, but have plans in your head for how to make it faster ... if the simple solution is too slow.

like image 32
Stephen C Avatar answered Sep 22 '22 17:09

Stephen C