网络
websocket
传统的HTTP1.1, 一般会使用轮询或者定时器,去请求服务器. 这样信息无法及时获取, 并且也会对服务器造成压力.
websocket则会是采用, 客户端订阅一类消息, 一旦这类消息有更新, 服务器会给client自动推送.
HTTP的长连接只能基于简单的超时(常见的是65秒).
WebSocket链接基于ping/pong心跳机制维持.
Cookie、Session、Token
Cookie:
Cookie是服务器产出的, 保留在浏览器端(所以换个浏览器就没有了), 用于帮助无状态的Web服务器, 记住用户的一些信息用的(识别用户).
Session
Cookie是存储在客户端方,Session是存储在服务端方,客户端只存储SessionId.
之所以又出现了session,是为了防止信息拦截后,用户的信息会泄露.
token
session是存储在服务器端的, 不同的服务器无法共享.
而token是一个令牌(这个令牌里面存放了服务器需要的相关信息, 这些信息经过base64编码).
服务端将令牌(经过Base64Url编码过后的用户信息)传给在客户端,每次用户请求的时候都会带上这一段信息,因此服务端拿到此信息进行解密后就知道此用户是谁了. 这种方式称为:JWT(Json Web Token)。
JWT是不加密的, 所以任何人截取了信息, 通过base64解码,都能看到信息.
但是由于JWT有签名字段, 所以数据是可以保证不被篡改的.
Token相比较于Session的优点在于,当后端系统有多台时,由于是客户端访问时直接带着数据,因此无需做共享数据的操作。同时, 由于不需要在服务端保存会话信息,特别适用于分布式微服务.
未分类
stagging environment
A staging environment (stage) is a nearly exact replica of a production environment for software testing. Staging environments are made to test codes, builds, and updates to ensure quality under a production-like environment before application deployment.
简单来说, stag就是在部署之前, 模拟线上环境的. 用来保障业务部署后, 能够正常运行.
常见的foobar foo bar是什么意思? (转)
术语foobar, foo, bar, baz和qux经常在计算机编程、计算机相关文档中,被用作占位符的名字。当变量,函数,或命令本身不太重要的时候,foobar, foo, bar,baz和qux就被用来充当这些实体的名字,这样做的目的仅仅是阐述一个概念,说明一个想法。
这些术语本身相对于使用的场景来说没有任何意义。
foobar 经常被单独使用;而当需要多个实体举例的时候,foo,bar,和baz则经常被按顺序使用。
原文:
The terms foobar, foo, bar, baz and qux are sometimes used as placeholder names (also referred to as metasyntactic variables) in computer programming or computer-related documentation.[1] They have been used to name entities such as variables, functions, and commands whose purpose is unimportant and serve only to demonstrate a concept. The words themselves have no meaning in this usage. Foobar is sometimes used alone; foo, bar, and baz are sometimes used in that order, when multiple entities are needed.
stub
- 在mock中,stub的含义就是占位符, 用于top-down模式开发.
- 在rpc中, 存在 stub_client和stub_server. 用来打包/解包, 并将消息传给真正的func处理.
+----------------+
| Client |
| +----------+ | +---------------+
| | caller | | | Server |
| |----------| | | +----------+ |
| | stub_cli |---- (over the wire) --->| stub_svr | |
| +----------+ | | |----------| |
+----------------+ | | function | |
| +----------+ |
+---------------+