Sticky Session for Rest API Calls

被刻印的时光 ゝ 提交于 2020-01-03 03:10:08

问题


For browser based request with sticky session true load balancer can restrict request to same JVM out of multiple JVMs in a cluster.

But in case request is coming from REST client rather any browser, how the load balancer can restrict requests to same JVM even sticky session is set as true? Any Idea please.


回答1:


REST client is made to call REST API and REST APIs should be stateless i.e. complete information about processing of request should be present in request itself, thus request should not dependent on any session data.

If your API is dependent on session data then in actual it is not following some principles of REST.




回答2:


If your requirement is such that you need to maintain the state then it should be maintained on client side not on server. So one of the way that i will suggest is that you can use cookies to store your state and temp data. While making any REST api call just attach that cookie with request. You can make cookie configurable so that it will be controlled by server and no one else can make change in it.



来源:https://stackoverflow.com/questions/30729535/sticky-session-for-rest-api-calls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!