官术网_书友最值得收藏!

HTTP is a stateless protocol

The HTTP protocol is a stateless one. This means that every HTTP request the server receives is independent and does not relate to requests that came prior to it. For example, imagine the following scenario: a request is made for the first ten user records, then another request is made for the next ten records.

On a stateful protocol, the server remembers each client position inside the result-set, and therefore the requests will be similar to:

  • Give me the first ten user records
  • Give me the next ten records

On a stateless protocol, the requests will be a bit different. The server doesn't hold the state of its client, and therefore the client's position in the result-set needs to be sent as part of the requests:

  • Give me user records on index 1 to 10
  • Give me user records on index 11 to 20

The slight difference between these examples represents the different approaches. On stateful protocols, you assume that the server knows everything about the previous requests, while on a stateless protocol you assume the opposite—the server doesn't know anything about the previous requests, which is why you send all the necessary information with each and every request.

On the one hand, this makes web service development more challenging, since creating fast, stateless service is not an easy task. On the other hand, this enables services to scale out quickly and support millions of users rather easily.

主站蜘蛛池模板: 长岭县| 乌鲁木齐县| 牙克石市| 宜兰市| 普洱| 长子县| 赞皇县| 沽源县| 洛扎县| 黎平县| 三穗县| 广丰县| 玉树县| 齐河县| 运城市| 邛崃市| 奉化市| 新源县| 兰西县| 通江县| 健康| 抚州市| 昆明市| 宝鸡市| 普兰店市| 嘉兴市| 永吉县| 耿马| 桦南县| 项城市| 垦利县| 兴国县| 兖州市| 河池市| 云浮市| 平远县| 宝兴县| 调兵山市| 台南市| 台南县| 勐海县|