The server never relies on information from previous requests.

Statelessness

As per the REST (REpresentational “State” Transfer) architecture, the server does not store any state about the client session on the server side. This restriction is called Statelessness. Each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. Session state is therefore kept entirely on the client. client is responsible for storing and handling all application state related information on client side.

It also means that client is responsible for sending any state information to server whenever it is needed. There should not be anysession affinity or sticky sessions on server.

Statelessness means that every HTTP request happens in complete isolation. When the client makes an HTTP request, it includes all information necessary for the server to fulfill that request. The server never relies on information from previous requests. If that information was important, the client would have sent it again in this request.

To enable clients to access these stateless APIs, its necessary that servers also should include every piece of information that client may need to create state on it’s side.

For becoming stateless, do not store even authentication/authorization details of client. Provide credentials with the request. Each request MUST stand alone and should not be affected from previous conversation happened from same client in past.

Application State vs Resource State

Please do not confuse between application state and resource state. Both are completely different things.

Application state is server-side data which servers store to identify incoming client requests, their previous interaction details and current context information.

Resource state is the current state of a resource on server at any point of time – and it has nothing to do with interaction between client and server. It is what you get as response from server as API response. You refer to it as resource representation.

REST statelessness means being free on application state.

Advantages of Statelessness

There are some very noticeable advantages for having REST APIs stateless.

  1. Statelessness helps in scaling the APIs to millions of concurrent users by deploying it to multiple servers. Any server can handle any request because there is no session related dependency.
  2. Being stateless makes REST APIs less complex – by removing all server side state synchronization logic.
  3. A stateless API is also easy to cache as well. A specific software can decide whether or not to cache the result of an HTTP request just by looking at that one request. There’s no nagging uncertainty that state from a previous request might affect the cacheability of this one. It improves the performance of applications.
  4. The server never loses track of “where” each client is in the application, because the client sends all necessary information with each request.

Reference: Roy T. Fielding on Stateless

Statelessness Provide credentials with the request. Each request MUST stand alone and should not be affected from previous conversation happened from same client in past.的更多相关文章

  1. String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!

    <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...

  2. C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法

    C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法? Request.params , Request ...

  3. basePath = request.getScheme()+"://"+request.getServerName()+":"+r

    basePath = request.getScheme()+"://"+request.getServerName()+":"+r (2014-06-30 1 ...

  4. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+pat----------<base>元素有关

    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. ...

  5. request.get request.GET……

    发现他们是不同的. 报错: AttributeError at /add/ 'WSGIRequest' object has no attribute 'get' Request Method: GE ...

  6. 客户端的数据来源:QueryString, Form, Cookie Request[]与Request.Params[]

    在ASP.NET编程中,有三个比较常见的来自于客户端的数据来源:QueryString, Form, Cookie . 我们可以在HttpRequest中访问这三大对象. QueryString: 获 ...

  7. JSP之项目路径问题(${pageContext.request.contextPath},<%=request.getContextPath()%>以及绝对路径获取)

    本随笔这是作为一个记录使用,以备后查.项目完成之后本地部署OK,本地Linux部署OK,都可以正常的访问,可是当我把它部署到服务器上面的时候,首页可以正常访问,可是当发出请求的时候却报错误了,说找不到 ...

  8. 安卓开发笔记(十六):'Request(okhttp3.Request.Builder)' has private access in 'okhttp3.Request

    当出现了'Request(okhttp3.Request.Builder)' has private access in 'okhttp3.Request的错误的时候,实际上是我们在写代码的时候少打了 ...

  9. <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>

    <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...

随机推荐

  1. POJ-1696 Space Ant 凸包版花式水过!

                                                         Space Ant 明天早上最后一科毛概了,竟然毫无复习之意,沉迷刷题无法自拔~~ 题意:说实 ...

  2. 九度oj 题目1020:最小长方形

    题目描述:     给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内. 输入: 测试输入 ...

  3. 使用Unity做2.5D游戏教程(一)

    最近在研究Unity 3D,看了老外Marin Todorov写的教程很详细,就翻译过来以便自己参考,翻译不好的地方请多包涵. 如果你不了解2.5D游戏是什么,它基本上是个3D游戏而你可以想象是压扁的 ...

  4. BZOJ 3850: ZCC Loves Codefires【贪心】

    Though ZCC has many Fans, ZCC himself is a crazy Fan of a coder, called "Memset137". It wa ...

  5. sublime text3安装angularjs插件

    sublime能够支持AngularJS开发那绝对是一件很爽的事情.下面我一步步讲解如何为sublime安装AngularJS插件. 首先提供一个破解版的sublime text 3的下载地址:htt ...

  6. 使用Jackson在Java中处理JSON

    在工作中实际使用到Java处理JSON的情况,且有很大部分都使用的是开源工具Jackson实现的. 一.入门 Jackson中有个ObjectMapper类很是实用,用于Java对象与JSON的互换. ...

  7. 【Codeforces Round #503 (Div. 2)】

    A:https://www.cnblogs.com/myx12345/p/9843198.html B:https://www.cnblogs.com/myx12345/p/9843245.html ...

  8. EGO V2

    Original EGO: mkdir -p ~/Library/Developer/Xcode/UserData/FontAndColorThemes; cd ~/Library/Developer ...

  9. Servlet 2.4 规范之第二篇:Servlet接口

    Servlet接口是Servlet API的最核心抽象类.所有的servlets都直接实现了这个接口,或者以更通用的方式继承了这个接口的实现类.Servlet API自带了两个实现了Servlet接口 ...

  10. Oracle的memory_max_target和memory_target修改和ORA-00845: MEMORY_TARGET not supported on this system错误解决

    https://blog.csdn.net/sunny05296/article/details/56495599