Why Tcp faster than http?

King Chan picture King Chan · Oct 26, 2011 · Viewed 9.7k times · Source

I had a discussion with my manager, he said tcp is faster than http because of tcp is work on layer lower than http.

Then I remember about the OSI Model that I learnt in university, so I think what he meant is because http work on application layer but tcp work on transport layer (which is 2 layers belows) so is faster...

So my questions is:

  1. Is lower layers works faster than upper layers is becasue there is less layers need to access when doing data transfers betweens two computers?

  2. If so, that's mean when we use tcp (i.e with WCF), the commnicuation will be start at transport layers => down to physical layer => another computer's physical layer => up to transport layers? But I throught the data still need to be understand by the application, so it will still has to goes up to Application layer?

Thanks in advance.

Answer

Marcelo Cantos picture Marcelo Cantos · Oct 26, 2011

There is always a layer above TCP. The question is really about how much overhead the stuff above TCP adds. HTTP is relatively chunky because each transmission requires a bunch of header cruft in both the request and the response. It also tends to be used in a stateless mode, whereby each request/response uses a separate TCP session. Keep-alives can ameliorate the session-per-request, but not the headers.