# Ping 信标

使用 Ping 信标以防止与远距离地区的玩家匹配并改善玩家体验。

## 🟢 连接质量（Connection Quality）

服务器连接质量因每位玩家而异，受多种因素影响，包括：

* Wi-Fi 信号强度（如果使用无线或移动网络），
* 互联网服务提供商状况，
* 本地网络状况，
* 使用的网络协议，
* 虚拟专用网络（VPN）的使用，
* 或特定国家/地区的限制。

为了将玩家延迟最小化并 **提供尽可能最佳的玩家匹配** 并使 [部署](/zh/learn/bian-pai/deployments.md#server-placement) 最佳化，游戏客户端 **利用 Ping 信标来实时测量延迟** 到全球若干主要网络节点。测量实际的数据包往返时间考虑了上述所有因素，并在任何给定时间点提供最准确的度量。

请记住， **信标高延迟并不等同于服务器高延迟**，因为服务器的部署密度通常高于信标。信标数量会实时平衡以实现最佳覆盖、最少必要的数据传输以及最短的测量完成时间。

除了 Edgegap 的监测之外，我们建议 **实现你自己的客户端分析** 在匹配时跟踪你的玩家人口统计和连接质量，以便能尽快发现、分类和解决问题。

## 🗼 关于 Ping 信标

检索玩家可以直接 ping 的信标列表来自：

* 配对器（Matchmaker） [深入了解](/zh/learn/pei-dui/matchmaker-in-depth.md#matchmaking-api) 从游戏客户端，
* Edgegap API [端点 /locations/beacons](https://docs.edgegap.com/api/#tag/Locations/operation/location-beacon-list) 使用 [Edgegap API 令牌](https://app.edgegap.com/user-settings?tab=tokens) （来自你的后端）。

Ping 信标可同时用于多种用途：

* 通过防止高延迟匹配来 [#measuring-round-trip-time](#measuring-round-trip-time "mention") 自动。
* 提供一个 [#hub-selection-ui](#hub-selection-ui "mention") 供玩家挑选喜爱的集线点，
* 提供一个 [#region-selection-ui](#region-selection-ui "mention") 供玩家排除远距离地区，

{% hint style="info" %}
**请求过多 429（Too Many Requests 429）** - 为确保平台稳定，我们 **对你的组织在此 API 端点施加速率限制，限制为** **40 次请求/秒（40 req/s）** 为此 API 端点实现一个 [#active-cache](#active-cache "mention") 以防触及速率限制。
{% endhint %}

{% hint style="success" %}
[#measuring-round-trip-time](#measuring-round-trip-time "mention") 使用 **ICMP、UDP 或 TCP ping 不受速率限制**.
{% endhint %}

## 🗺️ 区域选择界面

在游戏界面中提供一个可启用或禁用的区域列表，以防止用户与特定区域的其他用户匹配。

**自动禁用高延迟区域：**

* 列出所有可用信标，
* 执行 [#measuring-round-trip-time](#measuring-round-trip-time "mention") 对所有信标，
* **如果对所有信标测得的延迟超过给定阈值，则禁用该区域。**

你的阈值取决于游戏设计细节，我们建议在延迟低于 250 毫秒（ms）的区域内进行匹配。

## 📍 集线点选择界面

有些玩家更喜欢能够从详尽的位置列表中进行选择。

**自动禁用高延迟集线点：**

* 列出所有可用信标，
* 执行 [#measuring-round-trip-time](#measuring-round-trip-time "mention") 对所有信标，
* **如果测得延迟超过给定阈值则禁用集线点，**
* 在游戏界面中使用 City 信标属性标识已启用的集线点。

你的阈值将取决于游戏设计的具体要求，但我们通常建议在延迟低于 150 毫秒（ms）的集线点中进行匹配。

我们还建议在界面中使用“Hub”这个名称，或使用不同的 **名称，以免暗示这些是唯一可用的服务器位置**。Edgegap 在全球 615+ 个实体位置和 17+ 家数据中心提供商之间编排游戏服务器，以确保部署到理想位置。

## 🌡️ 测量往返时间

在游戏开发中，“ping”和“延迟”这两个术语通常指的是 [数据包往返时间](https://www.cloudflare.com/learning/cdn/glossary/round-trip-time-rtt/).

参见 [/pages/f56fbf42014b0e552701bac3a13d3792b3c70ce0#id-5.-game-integration](https://docs.edgegap.com/zh/learn/bian-pai/pages/f56fbf42014b0e552701bac3a13d3792b3c70ce0#id-5.-game-integration "mention") 用于自动 ping 测量：

关于延迟测量过程的详细概述在 [配对器（Matchmaker）](/zh/learn/pei-dui/matchmaker-in-depth.md):

<figure><img src="/files/98064d3c86b13805cb9a833ef4b5626f2ca63b23" alt=""><figcaption></figcaption></figure>

## ⏰ 高可用性

## 🧠 主动缓存

**如果不使用** [**配对器（Matchmaker）**](/zh/learn/pei-dui.md) （例如高级匹配器用户），我们建议在大规模发布前实施额外的可扩展性保障。 **创建你自己的游戏后端服务** 该服务在内存中保持一个集中缓存，向游戏客户端响应信标位置，而不必为每个客户端请求使用我们的信标列表 API。

此服务应主动 **每 60 秒发出一次单独的 API 请求以更新信标列表。**


---

# 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.edgegap.com/zh/learn/bian-pai/ping-beacons.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.
