# 何时应考虑使用应用层 WebSockets？

第 7 层 WebSockets 应在需要客户端和服务器之间进行实时、双向和持久通信时使用。这是因为 WebSockets 通过维持客户端和服务器之间的持久连接，实现了高效和低延迟的通信，避免了每次请求都需要建立和断开新连接的开销。

WebSockets 的一些常见用例包括：

1. 在线游戏：WebSockets 可用于创建需要玩家与服务器之间低延迟通信的实时多人游戏。
2. 聊天应用：WebSockets 可用于创建需要实时消息和通知的聊天应用。
3. 协作编辑：WebSockets 可用于实现多个用户之间的实时协作，例如文档编辑应用。
4. 实时监控和通知：WebSockets 可用于提供事件的实时更新和通知，例如股票价格、天气更新或社交媒体动态。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/welcome/cn/global-accelerator/faq/when-should-i-consider-using-layer-7-websockets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
