# Ping Beacons

Use Ping Beacons to prevent matching with players in a far regions and improve player experience.

## 🟢 Connection Quality

Server connection quality varies for each player and is impacted by many factors, including:

* wifi signal strength (if wireless or mobile),
* Internet Service Provider condition,
* local network conditions,
* networking protocol used,
* usage of Virtual Private Networks (VPNs),
* or country-specific restrictions.

In order to minimize player ping and **provide the best possible player match** and make [#server-placement](https://docs.edgegap.com/learn/deployments#server-placement "mention") optimal, game clients **utilize Ping Beacons to measure latency** to several major networking nodes worldwide in real time. Measuring real packet round-trip time accounts for all of the factors mentioned above and provides the most accurate metric at any given point in time.

Keep in mind that **high beacon ping doesn’t equate to high server ping**, since servers are populated more densely than beacons. Number of beacons is balanced real-time for best coverage, least required data transfer, and shortest time to complete measurement.

In addition to Edgegap’s monitoring, we recommend **implementing your own client-side analytics** to keep track of your player demographics and connection quality when matchmaking, so issues can be discovered, triaged, and resolved as fast as possible.

## 🗼 About Ping Beacons

Retrieve a list of beacons that players can ping directly from:

* Matchmaker [#matchmaking-api](https://docs.edgegap.com/matchmaking/matchmaker-in-depth#matchmaking-api "mention") from a game client,
* Edgegap API [endpoint /locations/beacons](https://docs.edgegap.com/api/#tag/Locations/operation/location-beacon-list) using [Edgegap API token](https://app.edgegap.com/user-settings?tab=tokens) (from your backend).

Ping beacons may be used for multiple purposes simultaneously:

* prevent high latency matches by [#measuring-round-trip-time](#measuring-round-trip-time "mention") automatically.
* provide a [#hub-selection-ui](#hub-selection-ui "mention") for players to cherry-pick favorite hubs,
* provide a [#region-selection-ui](#region-selection-ui "mention") for players to exclude far away regions,

{% hint style="info" %}
**Too Many Requests 429** - to ensure platform stability, we **rate limit your organization at** **40 req/s** for this API endpoint. Implement an [#active-cache](#active-cache "mention") to prevent hitting the rate limit.
{% endhint %}

{% hint style="success" %}
[#measuring-round-trip-time](#measuring-round-trip-time "mention") using **ICMP, UDP, or TCP ping is not rate limited**.
{% endhint %}

## 🗺️ Region Selection UI

Prevent users matchmaking against other users in a particular region by offering a list of regions to enable or disable in your game UI.

**Automatically disable high latency regions:**

* list all available beacons,
* perform [#measuring-round-trip-time](#measuring-round-trip-time "mention") to all beacons,
* **disable region if measured latency against all beacons exceeds a given threshold.**

Your threshold depends on game design specifics, we recommend matching in regions with latency below 250ms (milliseconds).

{% hint style="info" %}
To let players override [#server-placement](https://docs.edgegap.com/learn/deployments#server-placement "mention") provide beacon IP when [matchmaking](https://docs.edgegap.com/matchmaking/matchmaker-in-depth#endpoint-tickets) or [deploying](https://docs.edgegap.com/docs/api/dedicated-servers#deployments). For best player experience, warn players this may result in increased latency due to remotely located server.
{% endhint %}

Some players with high ping to all beacons due to ISP[^1] issues or slow connection (e.g. wireless/mobile) may cause lags and degrade game experience for others. To mitigate this issue:

* Gradually expand allowed latency maximum and difference (see [Advanced Example Config](https://docs.edgegap.com/matchmaking#advanced-example)),
  * players with high ping may have to wait longer than usual to find a match.
* Alternatively, allow players to override measurement with manual region selection, only sending fake ping values for the player-selected regions only (e.g. 25ms for fast match),
  * this may negatively impact player experience of the players' teammates and opponents.

{% hint style="info" %}
**High beacon ping doesn’t always result in high server ping**. Deployments are available in more locations than beacons. Beacons are orchestrated in real time to prioritize global coverage and reliability.
{% endhint %}

{% hint style="success" %}
See [matchmaking](https://docs.edgegap.com/learn/matchmaking "mention") for **automated ping measurement using our SDKs**.
{% endhint %}

## 📍 Hub Selection UI

Some game players prefer being able to select from an exhaustive list of locations.

**Automatically disable high latency Hubs:**

* list all available beacons,
* perform [#measuring-round-trip-time](#measuring-round-trip-time "mention") to all beacons,
* **disable hubs if measured latency exceeds a given threshold,**
* identify enabled Hubs in game UI using the City beacon property.

Your threshold will depend on your game design specifics, but we generally recommend matching in Hubs with latency below 150ms (milliseconds).

We also recommend choosing the name “Hub” in your UI, or a different **name that does not imply these are the only server locations available**. Edgegap orchestrate game servers worldwide across 615+ physical locations and 17+ data center providers to ensure deployment to the ideal location.

{% hint style="info" %}
To let players override [#server-placement](https://docs.edgegap.com/learn/deployments#server-placement "mention") provide beacon IP when [matchmaking](https://docs.edgegap.com/matchmaking/matchmaker-in-depth#endpoint-tickets) or [deploying](https://docs.edgegap.com/docs/api/dedicated-servers#deployments). For best player experience, warn players this may result in increased latency due to remotely located server.
{% endhint %}

Some players with high ping to all beacons due to ISP[^1] issues or slow connection (e.g. wireless/mobile) may cause lags and degrade game experience for others. To mitigate this issue:

* Gradually expand allowed latency maximum and difference (see [Advanced Example Config](https://docs.edgegap.com/matchmaking#advanced-example)),
  * players with high ping may have to wait longer than usual to find a match.
* Alternatively, allow players to override measurement with manual region selection, only sending fake ping values for the player-selected regions only (e.g. 25ms for fast match),
  * this may negatively impact player experience of the players' teammates and opponents.

{% hint style="info" %}
**High beacon ping doesn’t always result in high server ping**. Deployments are available in more locations than beacons. Beacons are orchestrated in real time to prioritize global coverage and reliability.
{% endhint %}

{% hint style="success" %}
See [matchmaking](https://docs.edgegap.com/learn/matchmaking "mention") for **automated ping measurement using our SDKs**.
{% endhint %}

## 🌡️ Measuring Round-Trip Time

In game development both terms “ping” and “latency” usually refer to [packet Round-Trip Time](https://www.cloudflare.com/learning/cdn/glossary/round-trip-time-rtt/).

See [#id-5.-game-integration](https://docs.edgegap.com/matchmaking#id-5.-game-integration "mention") for automatic ping measurement:

* Unity [#matchmaking-sdk](https://docs.edgegap.com/unity/developer-tools#matchmaking-sdk "mention") by Edgegap:
  * [install package using Unity Package Manager for free](https://github.com/edgegap/edgegap-unity-gen2-sdk?tab=readme-ov-file#install-with-git-recommended),
  * [import simple example script](https://github.com/edgegap/edgegap-unity-gen2-sdk?tab=readme-ov-file#import-simple-example) and customize for your needs,
* Unreal Engine [#integration-kit](https://docs.edgegap.com/unreal-engine/developer-tools#integration-kit "mention"):
  * [install from Fab Marketplace](https://www.fab.com/listings/ff17ad88-12a1-49cf-9a41-31695ed11e16) (free for Personal use),
  * [import simple example blueprint](https://blueprintue.com/blueprint/m33u1okj/) and customize to your needs.

Detailed overview of latency measurement process in [Matchmaker](https://docs.edgegap.com/learn/matchmaking/matchmaker-in-depth):

<figure><img src="https://3027732442-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR0dHSFv9ymoC0DO5G8J%2Fuploads%2Fn6ke8Ed6jijjdlPQ4CfP%2Fimage.png?alt=media&#x26;token=c85c70b2-73af-4980-a962-488393d264e6" alt=""><figcaption></figcaption></figure>

## ⏰ High Availability

{% hint style="danger" %}
Beacons are automatically rescaled in real time - adding/removing/replacing existing beacons. Your clients and backend should account for this and **reload list of beacons before each matchmaking round**.
{% endhint %}

## 🧠 Active Cache

**If not using** [**Matchmaker**](https://docs.edgegap.com/learn/matchmaking) (e.g. Advanced Matchmaker users), we recommend implementing additional scalability insurance before a large scale release. **Create your own game backend service** which keeps a centralized cache in memory, responding with beacon locations to game clients without using our Beacons List API for each client request.

This service should actively **make a single API request to update list of beacons every 60 seconds.**

[^1]: Internet Service Provider


---

# 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/learn/orchestration/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.
