Skip to content

Commit d49af05

Browse files
committed
[docs update]完善对SSE的介绍
ChatGPT 采用的就是 SSE
1 parent 30157a3 commit d49af05

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/system-design/web-real-time-message-push.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,14 @@ iframe 流的服务器开销很大,而且 IE、Chrome 等浏览器一直会处
189189

190190
iframe 流非常不友好,强烈不推荐。
191191

192-
### SSE (我的方式)
192+
### SSE (推荐)
193193

194194
很多人可能不知道,服务端向客户端推送消息,其实除了可以用`WebSocket`这种耳熟能详的机制外,还有一种服务器发送事件(Server-Sent Events),简称 SSE。这是一种服务器端到客户端(浏览器)的单向消息推送。
195195

196+
大名鼎鼎的 ChatGPT 就是采用的 SSE。对于需要长时间等待响应的对话场景,ChatGPT 采用了一种巧妙的策略:它会将已经计算出的数据“推送”给用户,并利用 SSE 技术在计算过程中持续返回数据。这样做的好处是可以避免用户因等待时间过长而选择关闭页面。
197+
198+
![ChatGPT 使用 SSE 实现对话](https://oss.javaguide.cn/github/javaguide/system-design/web-real-time-message-push/chatgpt-sse.png)
199+
196200
SSE 基于 HTTP 协议的,我们知道一般意义上的 HTTP 协议是无法做到服务端主动向客户端推送消息的,但 SSE 是个例外,它变换了一种思路。
197201

198202
![](https://oss.javaguide.cn/github/javaguide/system-design/web-real-time-message-push/1460000042192390.png)

0 commit comments

Comments
 (0)