Skip to content

Commit 25f7700

Browse files
authored
Replay & preferred regions syntax documentation (#2211)
* Note `apac` as valid placement region * Brief docs update for replay region preference lists
1 parent 5030ac8 commit 25f7700

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

machines/guides-examples/machine-placement.html.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ You can use geographic aliases like `us`, `eu`, or `sa` to fan out across a broa
3636

3737
| Alias | Area|
3838
|---------|------------------------|
39+
| `apac` | Asia-Pacific |
3940
| `eu` | Europe |
4041
| `na` | North America |
4142
| `sa` | South America |
4243
| `us`, `usa` | United States |
43-
44+
4445

4546
### Examples:
4647

networking/dynamic-request-routing.html.markerb

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Your app can add a `fly-replay` header to its response. The `fly-replay` header
2727

2828
|Field |Description |
2929
|---|---|
30-
|`region` | The 3-letter code for the [region](/docs/reference/regions/) to route the request to |
30+
|`region` | The region(s) to route the request to. Accepts comma-separated list of [region codes](/docs/reference/regions/) |
3131
|`instance` | The ID of a specific Machine to route to |
3232
|`prefer_instance` | The ID of a specific Machine to route to, if possible |
3333
|`app` | The name of another app (in same organization) to route to |
@@ -36,11 +36,21 @@ Your app can add a `fly-replay` header to its response. The `fly-replay` header
3636

3737
### Example Usage
3838

39-
Route to specific region:
39+
Route to a specific region:
4040
```
4141
fly-replay: region=sjc
4242
```
4343

44+
Route to one of the given regions, in order of preference:
45+
```
46+
fly-replay: region="iad,ord,us,na"
47+
```
48+
49+
Route to a preferred region, or fallback to any available machine:
50+
```
51+
fly-replay: region="sjc,any"
52+
```
53+
4454
Route to specific Machine:
4555
```
4656
fly-replay: instance=00bb33ff
@@ -53,9 +63,26 @@ fly-replay: app=app-in-same-org
5363

5464
You can combine multiple fields:
5565
```
56-
fly-replay: region=sjc;app=app-in-same-org
66+
fly-replay: region="sjc,any";app=app-in-same-org
5767
```
5868

69+
<div class="note icon">
70+
**Note**: A comma-separated list of regions must be quoted.
71+
</div>
72+
73+
### Geographic groups and aliases
74+
75+
When replaying to a region, you can use geographic aliases like `us`, `eu`, or `sa` to target a broader area.
76+
77+
| Alias | Area|
78+
|---------|------------------------|
79+
| `apac` | Asia-Pacific |
80+
| `eu` | Europe |
81+
| `na` | North America |
82+
| `sa` | South America |
83+
| `us`, `usa` | United States |
84+
| `any` | Earth |
85+
5986
## Replay JSON Format
6087

6188
Your app can set the response content-type to `application/vnd.fly.replay+json` and include replay instructions in the response body.
@@ -67,7 +94,7 @@ The `application/vnd.fly.replay+json` replay body accepts the following fields:
6794

6895
|Field |Description |
6996
|---|---|
70-
|`region` | The 3-letter code for the [region](/docs/reference/regions/) to route the request to |
97+
|`region` | The region(s) to route the request to. Accepts comma-separated list of [region codes](/docs/reference/regions/) |
7198
|`instance` | The ID of a specific Machine to route to |
7299
|`prefer_instance` | The ID of a specific Machine to route to, if possible |
73100
|`app` | The name of another app (in same organization) to route to |
@@ -87,6 +114,7 @@ Route to another app, and modify the request:
87114
```json
88115
{
89116
"app": "target-app",
117+
"region": "iad,us",
90118
"transform": {
91119
"path": "/new/path?param=value",
92120
"delete_headers": ["x-unwanted-header", "cookie"],
@@ -190,7 +218,13 @@ For cases where `fly-replay` isn't suitable, Fly.io provides two alternative req
190218
fly-prefer-region: ams
191219
```
192220

193-
Attempts to route directly to a specific region. Falls back to nearest region with healthy Machines if target region is unavailable. Useful for large uploads that can't be replayed.
221+
Attempts to route directly to specific region(s). You can specify multiple regions as comma-separated values for fallback preferences:
222+
223+
```
224+
fly-prefer-region: iad,ord,us
225+
```
226+
227+
Falls back to the next region in the list, or to the nearest region with healthy Machines if none of the specified regions are available. Useful for large uploads that can't be replayed.
194228

195229
### The fly-prefer-instance-id Header
196230

networking/services.html.markerb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,16 @@ The HTTP handler adds a number of standard HTTP headers to requests, and a few F
123123
| `Fly-Region` | Original incoming connection region |
124124
| `Fly-Preferred-Instance-Unavailable` | The ID of a preferred instance that the proxy could not route to |
125125

126-
You can set a preference on HTTP requests for which region you would like to connect to:
126+
You can set a preference on HTTP requests for which region you would like to connect to. You can specify a single region or multiple regions in order of preference:
127127

128128
```
129-
Fly-Prefer-Region: region-code
129+
Fly-Prefer-Region: iad
130+
```
131+
132+
Or with multiple preferences (tries regions in order):
133+
134+
```
135+
Fly-Prefer-Region: iad,ord,us,na
130136
```
131137

132138
You can set a preference for a specific machine instance:

0 commit comments

Comments
 (0)