Stateful and stateless servers

Source: Internet
Author: User

1. stateless and statefulServer

Information maintained by the server related to ongoing client interaction activities is called status information. A server that does not save status information is called a stateless server, or a stateful server.

The high efficiency requirement allows the designer to save the status information on the server. Saving a small amount of information on the server can reduce the size of the exchanged packets between the customer and the server, and make the server quickly respond to requests. In essence, the status information allows the server to remember previous client requests and calculate the progressive response when new requests arrive. In contrast, stateless servers are used to ensure protocol reliability. If a message is lost, duplicated, transmitted out of order, or the client's computer crashes and restarts, the status information will go wrong. If the server uses incorrect status information when calculating the response, it is possible to make an error response.

In ideal conditions (that isNetworkReliable transmission of all packets and the computer will never crash). Saving the status information of each ongoing interaction on the server can reduce the packet size and simplify the processing.

In general, only complex protocols are used to solve the problem of unreliable transmission andSystemTo maintain the correct status information. In summary:

In the real Internet, machines may crash and restart, and packets may be lost, delayed, duplicated, or transmitted out of order. Using a stateful server may lead to complicated application protocols, this Protocol is difficult to design, understand, and implement correctly.

2. Stateless is a protocol Problem

Whether a server is stateless or stateful depends on the application protocol rather than the implementation. If the application protocol specifies that the meaning of a message depends on the previous message to some extent, stateless interaction is impossible.

Essentially, the focus of stateless issues lies in whether the application protocol is responsible for reliable transmission. To avoid problems and ensure interaction reliability, the application protocol designer must ensure that each packet is unambiguous. That is to say, messages cannot depend on whether they are delivered in order or on messages already delivered. Essentially, the Protocol designer must ensure that the server gives the same response no matter when or how many requests arrive. Idempotent refers to a mathematical operation that always produces the same result. In this term, these protocols ensure that the server gives the same response no matter how many times the message arrives.

If a lower-layer network on the Internet may duplicate or delay messages, or send messages in an out-of-order manner, or the computer running the customer's application may crash unexpectedly, the server must be stateless. If the application protocol is designed to be idempotent for each operation, the server can only be stateless.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.