当前位置:网站首页>Difference Between Stateless and Stateful
Difference Between Stateless and Stateful
2022-07-31 22:50:00 【Xiaoyu who loves programming】
Stateless vs. Stateful
- Stateful Services
Stateful service, The server records the client information of each session, so as to identify the client's identity and perform corresponding processing according to the user's identity.
- Stateless Services
Understanding stateful services, stateless services are easy to understand. The most common implementation of stateless services in practice is to use a token-based approach, namely:
- The server does not save any client session information;
- Every request from the client must carry a token, which contains authentication, signature-related information (username, role, permissions, etc.);
Problems with traditional session authentication methods
HTTP
itself is stateless, short connection, so we have our traditional Cookie-Session mode, which is in the monomerwidely used in architecture.After the user completes the login, the session information with the user is saved in the Session
of the server, and then the server responds with a SessionID
to the front end, and the front end sends this The SessionID
is stored in Cookie
, and subsequent requests carry the Cookie
information to continue to initiate the request, and the backend queries its corresponding session information to complete the request response.
There are some problems with this approach:
- Performance: Every time a session is established, the server needs to store the session information, which increases the pressure on the server to store and query, and takes up valuable storage and computing resources;
- Scalability: The server saves the user state, and it is difficult to expand horizontally. In the microservice environment, it is necessary to perform state replication and synchronization (Session synchronization, Session sharing) on each server before processing.to expand;
- CSRF attack: Because this method is based on cookie for user identification, if the cookie is intercepted, the user and the server will be attacked by cross-site request forgery;
- Cross-platform: Sessions and cookies are hard to work with on mobile apps, you cannot share server-created sessions and cookies with mobile terminals.
Workaround:
边栏推荐
- Flink_CDC construction and simple use
- 信息学奥赛一本通 1941:【07NOIP普及组】Hanoi双塔问题 | 洛谷 P1096 [NOIP2007 普及组] Hanoi 双塔问题
- "SDOI2016" Journey Problem Solution
- spark reports an error OutOfMemory "recommended collection"
- Structure of the actual combat battalion module eight operations
- 基于单片机GSM的防火防盗系统的设计
- 了解下C# 匿名方法
- #yyds干货盘点# 面试必刷TOP101:链表中环的入口结点
- 输入输出优化
- BM5 merge k sorted linked lists
猜你喜欢
VOT2021 game introduction
网易云信圈组上线实时互动频道,「破冰」弱关系社交
Interview assault 69: TCP reliable?Why is that?
Unity - by casting and cloning method dynamic control under various UGUI create and display
(26)Blender源码分析之顶层菜单的关于菜单
flowable workflow all business concepts
Count characters in UTF-8 string function
ThreadLocal
登录业务实现(单点登录+微信扫码+短信服务)
Payment module implementation
随机推荐
UVM RAL model and built-in seq
flowable workflow all business concepts
How to reduce the gap between software design and implementation
Write a database document management tool based on WPF repeating the wheel (1)
基于单片机GSM的防火防盗系统的设计
Commonly used security penetration testing tools (penetration testing tools)
Go1.18 upgrade function - Fuzz test from scratch in Go language
"The core concept of" image classification and target detection in the positive and negative samples and understanding architecture
【ACM】2022.7.31训练赛
Pytorch lstm time series prediction problem stepping on the pit "recommended collection"
Shell常用脚本:Nexus批量上传本地仓库增强版脚本(强烈推荐)
网络安全--通过握手包破解WiFi(详细教程)
Payment module implementation
The difference between adding or not adding the ref keyword when a variable of reference type is used as a parameter in a method call in C#
TestCafeSummary
IDA PRO中汇编结构体识别
Chapter Six
Interview assault 69: TCP reliable?Why is that?
The article you worked so hard to write may not be your original
Golang must know the Go Mod command