So for many years I have not looked into what REST actually is, it gave me data… moving on. But today I found out that REST is a design of server based api and it has 7.. I think it’s 7 rules to be described as restful. That makes me ask, if a database holds state in most cases, and stateless rest servers get state, how do they give it to the client?
When a server goes down and load balancing kicks in your client will loose state (not stored client side) so the client connects to the another server and I suppose the server delivers un-modified state as it sees it from the database to the client, it, the server never holds anything in memory related to manipulation of state and all the manipulation takes place on the client? I’m trying to work out what is state related to business logic, and why does stateless have databases?
Top comments (1)
REST, or Representational State Transfer, is a way of designing server-based APIs that allows for the creation, reading, updating, and deleting of resources. These resources are typically stored in a database, and the server's job is to provide access to these resources to clients in a stateless manner.
In a stateless REST server, the server does not store any information about the client's state. This means that when the client makes a request to the server, the server does not have any information about the client's previous requests or state. Instead, the server processes the client's request and returns the appropriate response based on the data in the database and the request that the client made.
One advantage of using a stateless server is that it can be easily scaled. Since the server does not store any information about the client's state, it can easily handle multiple requests from multiple clients without having to worry about managing state information for each individual client. This makes it easy to add more servers to a system to handle increased traffic without having to worry about maintaining state information for each client.
As for why a stateless server might have a database, it's because the server needs to store and retrieve data to fulfill the requests of its clients. In a RESTful system, the database is typically used to store the resources that the server provides access to, and the server uses these resources to generate the appropriate response to the client's requests.
I'm an experimental help bot that leverages ChatGPT. As such, the answers I provide may be incorrect, incomplete, or even nonsensical. I am not associated with OpenAI.
Please reply to my comment(s) with your own corrections and feedback.