Skip to content

Commit d92e606

Browse files
authored
new: one app per user explanation (#2010)
1 parent 389f7b0 commit d92e606

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: One app per customer: why?
3+
layout: docs
4+
order: 15
5+
nav: machines
6+
---
7+
8+
We recommend that you create one app, with one or more machines, **for each customer** you have. You'll gain a lot from this:
9+
10+
* you'll be able to leverage Fly.io proxy’s load balancing
11+
* the `fly.toml` config is app-level, so you can run Machines in different regions / different sizes in the same app
12+
* your secrets live at the app level: a compromised user app cannot see other user apps' secrets; whereas if all user projects are mashed together in a mega-app, they all have access to everyone else's secrets (plus the `env` would be ginormous and unwieldy)
13+
* auto start / auto stop runs at the app level
14+
* apps are easier to transfer between orgs if you ever need move things around
15+
* there's a cleaner separation of concerns in logs
16+
* apps get isolated networks (if you pass in a network name), and machines on the same app share a private network—more on this below!
17+
* each app can still scale independently—so if you've got a _very successful user_ who needs beefier machines, you can scale them up without affecting your other users
18+
19+
A pattern where a single application has machines for all customers is _technically_ possible, but you'd lose the benefits of load balancing, and it would be challenging to make it resilient. Plus, our tooling is not really designed to list thousands of machines per app, so you'd get weird API behavior in some places.
20+
21+
## Isolated networks
22+
23+
Each Fly.io organization gets an isolated network that connects all machines in the organization using Wireguard. This is described in more detail [in our private networking docs](https://fly.io/docs/networking/private-networking/). This generally means that one can deploy, for example, one app for each service, and they will be able to connect to each other using the appropriate hostnames (`.internal` or `.flycast`) as explained in the document.
24+
25+
However, at application creation time, a `--network` parameter can be passed, to create a [custom private network](https://fly.io/docs/networking/custom-private-networks/) for that application. This subnet will not be connected to the organization’s, meaning this application will be isolated from others (although it can still provide a public internet-facing service as configured in `fly.toml`).
26+
27+
The [Custom private networks](https://fly.io/docs/networking/custom-private-networks/#private-apps-with-flycast) document details a few ways an isolated app can talk to other applications in a controlled manner, including:
28+
29+
* Application A (non-isolated) can have a `.flycast` IP address in application B’s (isolated) subnet, so they can talk to each other over that IP address. You can do this using `fly ips allocate-v6 --private -a APP_A --network APP_B_NETWORK`. App A can then contact “app-b.flycast” directly.
30+
* Using the [fly-replay header](https://fly.io/docs/networking/dynamic-request-routing/), an application can direct requests to machines in another application, even if that one resides on a private subnet.
31+
* If application B (isolated) exposes a public service, then other applications (isolated or not) can access it over the Internet using its public name.

0 commit comments

Comments
 (0)