How stateless server can keep session state on server side?

gstackoverflow :

I'me reading Marting Fowler's famous book Patterns of enterprise application architecture to systematize my knowledge.

I've read chapter Session and States and I a bit confused. In the first part of the chapter author recommend to use stateless server to avoid some sort of issues. Then author says that sometimes wee need to save some data on the server side - for example user cart in a internet shop. But to implement session with state we can use stateless server. Then author describes ways to save session state(client, server, database)

But after reading this chapter I don't understand what a stateless server is. How a server can be stateless if it keeps session state ?

GhostCat salutes Monica C. :

Quora has a nice definition:

A stateless service is a service that does not store any data on the application server. It reads or writes data to the database, returns a value (or not), and after that, any information on the task itself is forgotten.

Meaning: it isn't that server itself that keeps the state data. It can put it into some database. It might then provide the client with some sort of token that the client can include in future calls. And that token enables other servers to retrieve the corresponding data from say, a database.

The key point is: sure, the information needs to be stored somewhere. But that somewhere isn't the server, but some infrastructure that all the stateless servers can get to.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=305291&siteId=1