18 Temmuz 2016 Pazartesi

How can it be possible that HTTP is stateless, although HTTP uses TCP protocol?

- TCP is connection-oriented, stateful and reliable.
- UDP is connectionless, stateless and unreliable.
- HTTP uses most commonly TCP protocol.

By taking information above into consideration, how can it be possible that HTTP is stateless?

* HTTP does not inherit from TCP or any other lower-level protocols used to transport itself. Using one of these protocols in transport layer doesn’t mean that HTTP becomes stateful automatically or is required to be stateful [1].

HTTP will work the same without considering a transport technology such TCP, SCTP or another protocol over HTTP;

- HTTP provides a stateful connection by using TCP, but then it makes this connection disconnect. Later on, it can connect again, if it is needed. Many different connections are created while a user browses a web-site. These connections are surely stateful, but the whole, I mean the conversation, is not, because each connection in the conversation is started and ended in a way of being independent of any other connection [2].

There is good example here about what I tell above;

" Consider the phone service to be TCP and consider your relationship with distant family members to be HTTP. You will contact them with the phone service. Each call to them would be a stateful TCP connection. However, you don't constantly stay on the phone with them, as you will disconnect and call them back again at a later time. You would certainly expect them to remember what you talked about on the last call. HTTP in itself does not do that, but it is rather a function of the web server that maintains the state of the overall conversation." [3]

If you have a popular server that has a million hits per day, management of these hits is very important in this sense. Each hit consists of a quick connect and disconnect. However, if each user open a connection in your web-site, then it could potentially overwhelm your server.

As a result, HTTP itself is stateless without considering its transport technology. It means that applications have to implement another layer on top of HTTP to establish state. Session cookies are typically used for this reason [1].

References:
  1. http://superuser.com/a/825372
  2. http://whatis.techtarget.com/definition/stateless
  3. http://fixunix.com/tcp-ip/66544-tcp-stateful-protocol-then-why-not-http.html#post214883

Hiç yorum yok:

Yorum Gönder