You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blueprints/per-user-dev-environments.html.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ This blueprint explains how to use Fly Machines to securely host ephemeral devel
16
16
Your architecture should include:
17
17
18
18
-**Router app(s)**
19
-
- A Fly.io app to handle requests to wildcard subdomains (`*.example.com`). Uses `fly-replay` headers to transparently redirect each request to the correct app and machine. If you have clusters of users (or robots) in different geographic regions, you can spin up a router app in multiple regions (you might also want to consider a globally distributed datastore like [Upstash for Redis](https://fly.io/docs/upstash/redis/#what-you-should-know)).
19
+
- A Fly.io app to handle requests to wildcard subdomains (`*.example.com`). Uses `fly-replay` headers to transparently redirect each request to the correct app and machine. If you have clusters of users (or robots) in different geographic regions, you can spin up a router app in multiple region to increase reliability and reduce latency (you might also want to consider a globally distributed datastore like [Upstash for Redis](https://fly.io/docs/upstash/redis/#what-you-should-know)).
20
20
-**User apps (pre-created)**
21
21
- Dedicated per-user (or per-robot) Fly apps, each containing isolated Fly Machines. App and Machine creation is not instantaneous, so we recommend provisioning a pool of these before you need them so you can quickly assign upon request.
22
22
-**Fly Machines (with optional volumes)**
@@ -32,7 +32,7 @@ Your router app handles all incoming wildcard traffic. Its responsibility is sim
- Look up the correct app (and optionally machine ID) for that user.
35
-
- Issue a `fly-replay` header directing the Fly Proxy to [internally redirect the request](https://fly.io/docs/networking/dynamic-request-routing) (this should add no more than ~10 milliseconds of latency).
35
+
- Issue a `fly-replay` header directing the Fly Proxy to [internally redirect the request](https://fly.io/docs/networking/dynamic-request-routing) (this should add no more than ~10 milliseconds of latency if the router app is deployed close to the user).
36
36
- When appropriate, use [replay caching](https://fly.io/docs/networking/dynamic-request-routing/#replay-caching) to further reduce latency and load on the router app.
37
37
- Make sure you've added [a wildcard domain](https://fly.io/docs/networking/custom-domain/#get-certified) (*.example.com) to your router app (read more about the [certificate management endpoint here](https://fly.io/docs/networking/custom-domain-api/)).
In cases where the replay target does not change often under some path, you may use the `fly-replay-cache` mechanism to relieve the original app of some unnecessary load. Here's how it works:
60
+
In cases where the replay target does not change often, you can use the `fly-replay-cache` mechanism to relieve the original app of some load. Here's how it works:
61
61
- Issue a `fly-replay` header as usual
62
62
- Set `fly-replay-cache: example.com/some/path/*`
63
-
- This needs to be a path-matching pattern ending with a wildcard `/*`. This is where the cached replay is applied to.
64
-
- The domain part should not include ports; i.e. use `example.com`, not `example.com:80` or `example.com:443`.
63
+
- This needs to be a path-matching pattern ending with a wildcard `/*`. This is where the cached replay is applied.
64
+
- The domain part should not include ports; use `example.com`, not `example.com:80`.
65
65
- The pattern must also match the current path of the request.
66
66
- Set `fly-replay-cache-ttl-secs: number_of_seconds`
67
-
- This is simply a TTL attached to the replay cache. It needs to be at least 10 seconds.
68
67
69
68
If the replay target does eventually change, the replay target may proactively invalidate the cache by
70
69
- Issuing a `fly-replay` back to the origin
71
70
- Setting `fly-replay-cache: invalidate`
72
71
73
-
It is also worth noting that replay caching is an optimization, not a guarantee. Your app should _not_ depend on this mechanism to function.
74
-
The app issuing `fly-replay`s still serves as the ultimate source of truth, and we may decide to consult that app at any moment even if a replay cache has previously been set.
75
-
To ensure reliable operation, the app issuing `fly-replay`s should still have multiple instances deployed in multiple regions.
72
+
<div class="note icon">
73
+
**Note**: Replay caching is an optimization, not a guarantee. Your app should _not_ depend on this mechanism to function.
74
+
The app issuing `fly-replay` still serves as the ultimate source of truth, and we may decide to consult that app at any moment even if a replay cache has previously been set.
75
+
To ensure reliable operation, the app issuing `fly-replay` should still have multiple instances deployed in multiple regions.
76
+
</div>
76
77
77
78
## Implementation Details
78
79
@@ -88,6 +89,7 @@ For large uploads that exceed the 1MB limit, consider:
88
89
89
90
For `fly-replay-cache`, the following limitations apply:
90
91
- The `state` field cannot be set in the `fly-replay` intended to be cached
92
+
- The TTL needs to be a minimum of 10 seconds
91
93
- Only one step of lookup is performed in the cache; as such, if the target app issues another `fly-replay-cache`, the caching behavior in this case is undefined
92
94
- The `fly-replay-src` header (described below) will _not_ be set for requests replayed through the cache
0 commit comments