performancehttpnetwork-programmingtcpsystem-design

why they use http in apis (mobile / desktop / web / ...) , isn't http just for web


Essentially, what I'm asking is, why use HTTP for anything when TCP alone could suffice? HTTP operates on top of TCP, so by sticking to TCP alone, you simplify parsing and avoid the added complexity of HTTP.

I came across an article discussing WhatsApp's tech stack, noting their use of HTTP for their mobile app. It immediately occurred to me that sticking solely to TCP could potentially enhance performance.

article : https://intuji.com/whatsapp-tech-stack-explored/


Solution

  • There are many reasons to stick with a technology even if it does not look like the most optimal suited to the problem. At the end it is about weighing advantages against disadvantages.

    As for the advantages:

    Compared to these advantages the disadvantage of some more overhead is acceptable. Also, if any theoretical performance advantages of a protocol with less overhead are really noticeable in practice is questionable. The network performance is usually dominated by the latency of the link and not by the (small) overhead of the communication protocol.