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/autoscale-machines.html.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,29 +13,32 @@ Machines during the period of low traffic.
13
13
This blueprint will guide you through the process of configuring the
14
14
[`fly-autoscaler` app](/docs/launch/autoscale-by-metric/) in conjunction with
15
15
[Fly Proxy autostop/autostart](/docs/launch/autostop-autostart/) to
16
-
always keep a fixed number of stopped Machines ready to be quickly started
16
+
always keep a fixed number of Machines ready to be quickly started
17
17
by Fly Proxy.
18
18
19
19
## Configuring automatic start and stop
20
20
21
21
First, we will configure the app to allow Fly Proxy to automatically start and
22
-
stop Machines based on traffic demand. The auto start and stop settings apply
22
+
stop or suspend Machines based on traffic demand. The auto start and stop settings apply
23
23
per service, so you set them within the `[[services]]` or `[http_service]`
24
24
sections of `fly.toml`:
25
25
26
26
```toml
27
27
...
28
28
[[services]]
29
29
...
30
-
auto_stop_machines = true
30
+
auto_stop_machines = "stop"
31
31
auto_start_machines = true
32
32
min_machines_running = 0
33
33
...
34
34
```
35
35
36
36
With these settings Fly Proxy will start an additional Machine if all the
37
37
running Machines are above their concurrency `soft_limit` and stop running
38
-
Machines when the traffic decreases. In the next section we will configure
38
+
Machines when the traffic decreases. You can set Machines to `"suspend"` rather than
39
+
`"stop"`, for even faster start-up, but with some [limitations on the type of Machine](https://community.fly.io/t/new-feature-in-preview-suspend-resume-for-machines/20672#current-limitations-and-caveats-8).
40
+
41
+
In the next section we will configure
39
42
and deploy `fly-autoscaler` to ensure that the app always has a spare stopped
Copy file name to clipboardExpand all lines: blueprints/autostart-internal-apps.html.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ You have a private, or internal, app that communicates only with other apps on y
8
8
9
9
To use Fly Proxy autostop/autostart you need to configure services in `fly.toml`, like you would for a public app. But instead of using a public Anycast address, you assign a Flycast address to expose those services only on your private network.
10
10
11
-
This blueprint focuses on using autostart and autostop to control Machines based on incoming requests. But when you use Flycast for private apps you also get other Fly Proxy features like geographically aware load balancing.
11
+
This blueprint focuses on using autostop/autostart to control Machines based on incoming requests. But when you use Flycast for private apps you also get other [Fly Proxy features](/docs/reference/fly-proxy/) like geographically aware load balancing.
12
12
13
13
Learn more about [Flycast](/docs/networking/flycast/).
14
14
@@ -49,9 +49,9 @@ v6 fdaa:2:45b:0:1::11 private global Mar 16 2024 18:20
49
49
v4 66.241.124.11 public (shared) Jan 1 0001 00:00
50
50
```
51
51
52
-
This example app has public IPv4 and IPv6 addresses. These are the addresses automatically assigned to an app on first deploy.
52
+
This example app has public IPv4 and IPv6 addresses. These public addresses are automatically assigned to an app with services on the first deploy.
53
53
54
-
Copy the public IP addresses and run the `release` command to remove them from your app:
54
+
Copy the public IP addresses and run the `fly ips release` command to remove them from your app:
55
55
56
56
```
57
57
fly ips release <ip address> <ip address> ...
@@ -82,7 +82,7 @@ Here's an example `fly.toml` snippet:
82
82
# must be false - Flycast is http-only
83
83
force_https = false
84
84
# Fly Proxy stops Machines based on traffic
85
-
auto_stop_machines = true
85
+
auto_stop_machines = "stop"
86
86
# Fly Proxy starts Machines based on traffic
87
87
auto_start_machines = true
88
88
# Number of Machines to keep running in primary region
@@ -94,7 +94,7 @@ Here's an example `fly.toml` snippet:
94
94
```
95
95
96
96
<divclass="important icon">
97
-
**Important:** Set `force_https = false` since Flycast only works over HTTP. HTTPS isn't necessary because all your private network traffic goes through encrypted WireGuard tunnels.
97
+
**Important:** Set `force_https = false`; Flycast only works over HTTP. HTTPS isn't necessary because all your private network traffic goes through encrypted WireGuard tunnels.
98
98
</div>
99
99
100
100
Learn more about [Fly Launch configuration](/docs/reference/configuration/) and [Fly Proxy autostop/autostart](/docs/launch/autostop-autostart/).
@@ -107,7 +107,7 @@ To be reachable by Fly Proxy, an app needs to listen on `0.0.0.0` and bind to th
107
107
108
108
Run `fly deploy` for the configuration changes to take effect.
109
109
110
-
Other apps in your organization can now reach your private app using the [Flycast](/docs/networking/flycast/) IP address or `<appname>.flycast`.
110
+
Other apps in your organization can now reach your private app using the [Flycast](/docs/networking/flycast/) IP address or the`<appname>.flycast` domain.
For this demo, we will start with [MDN's Web Dictaphone](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone#web-dictaphone).
8
+
You can play with a [live demo](https://mdn.github.io/dom-examples/media/web-dictaphone/). This is about as basic of an
9
+
HTML form as you can get, and it has the added bonus of providing the ability to generate as many media files as you want using only your voice.
10
+
11
+
Your app undoubtely has many forms, and more complex forms, but once you can see the basic flow, the rest should be easy.
12
+
13
+
That demo as it currently stands is client side only, so to deploy it all you need is a web server that can deploy static assets (HTML, CSS, JS, images),
14
+
like NGINX, Apache HTTPd, or Caddy. In order to store the data in databases, we are going to need a server that can handle HTTP GET, POST, PUT, and DELETE requests.
15
+
16
+
This demo application will come in two flavors. For Node.js, we will select [Express.JS](https://expressjs.com/), and for Rails we will use [Puma](https://github.com/puma/puma).
17
+
18
+
* The names of the clips will go into a [PostgreSQL](https://www.postgresql.org/) relational database.
19
+
* The audio files themselves will be placed into a [Tigris bucket](https://www.tigrisdata.com/).
20
+
* For Node.js, the bulk of this code is in [app.js](https://github.com/fly-apps/node-dictaphone/blob/main/app.js). For Rails,
To satisfy the realtime requirement, we will need [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
24
+
and [Upstash for Redis](https://fly.io/docs/reference/redis/). The Node.js implementation is in [pubsub.js](https://github.com/fly-apps/node-dictaphone/blob/main/pubsub.js).
25
+
For Rails, the heavy lifting is done by [ActionCable](https://guides.rubyonrails.org/action_cable_overview.html), so all that is needed is
26
+
one line in [app/models/clip.rb](https://github.com/fly-apps/rails-dictaphone/blob/6bdf4f639640c9fb55530546dbbed682b65a7df9/app/models/clip.rb#L2)
27
+
and one line in [app/views/layouts/application.html.erb](https://github.com/fly-apps/rails-dictaphone/blob/6bdf4f639640c9fb55530546dbbed682b65a7df9/app/views/layouts/application.html.erb#L9).
28
+
29
+
The important thing to note is that this is all very straightforward stuff using industry standard components that you can run on your laptop, a VPS, AWS EC2, Google Compute Engine, or Azure.
30
+
31
+
If you want to see this up and running on fly.io (and certainly you do or why else would you be here?), all you need
32
+
is an empty directory and either Node or Ruby installed.
33
+
34
+
Now that we know what we are intending to accomplish, let's proceed to the exciting step: [Fire!](../fire/)
Your application is running by default on two [Machines](https://fly.io/docs/machines/).
8
+
9
+
Don't worry about cost. Both machines stop when not in use, and [autostart](https://fly.io/docs/launch/autostop-autostart/) when a new request comes in.
10
+
This is entirely configurable. You can chose to [suspend](https://community.fly.io/t/new-feature-in-preview-suspend-resume-for-machines/20672) instead of stop,
11
+
configure a [minimum number](https://fly.io/docs/reference/configuration/#the-http_service-section) of machines to leave running, or even decide never to
12
+
stop at all.
13
+
14
+
Familiarize yourself with [fly.toml](https://fly.io/docs/reference/configuration/). Make a change there -- or in fact to any part of your application -- and run `fly deploy`.
15
+
16
+
The purpose of two machines is twofold: redundancy and scalability. If the machine hosting one goes down, the other can continue on. If both are available, in times of high use both can be started to handle requests.
17
+
You can [vertically scale](https://fly.io/docs/launch/scale-machine/) the CPU and RAM on each machine.
18
+
19
+
You can also [horizontally scale](https://fly.io/docs/launch/scale-count/) to more machines. Be sure to scroll down on that page far enough to see how to scale to
20
+
multiple [regions](https://fly.io/docs/reference/regions/). If you have a co-worker on another continent, create a machine there.
21
+
22
+
And all this is made possible by [Anycast](https://fly.io/docs/networking/services/), a [load balancing proxy](https://fly.io/docs/reference/fly-proxy/), and [DNS certificates](https://fly.io/docs/networking/custom-domain/).
23
+
Be sure to read the last link if you are interested in custom domains.
This is the point where the rubber meets the road, so this is where you would expect to see where the marketing hype promised by [Speedrun](https://fly.io/speedrun) and
8
+
the [Quick Start](../getting-started/launch/) don't quite cut it. But the fact of the matter is that fly.io is honed for an excellent developer experience (DX) for full stack applications with both realtime time and object storage requirements.
Step 2: run `fly launch --from https://github.com/fly-apps/node-dictaphone` or `fly launch --from https://github.com/fly-apps/rails-dictaphone`
15
+
16
+
If you are new to fly, the second step will first take you to a place where you can register. Then it will provide a description of what you will be getting, and give you an opportunity to tweak the settings (suggestion: don't. They are fine for this demo and we will walk you through how to adjust them later). And then it will build and assemble and wire up your application.
17
+
18
+
Take your time and play with it. Open your application in multiple browser windows. Send a link to a friend on another continent and watch your browser update in realtime.
19
+
20
+
And then relax. We promised you it would be less than an hour. You are already up and running. In fact, if you are so inclined try bringing up this exact same application on another cloud provider.
21
+
We don't mind. In fact we encourage it. Just please don't count the time you spent there against the hour budget we asked you to allot to this activity.
22
+
23
+
Once you are back and/or rested up, let's explore. You've seen the code. You're up and running. Now lets take inventory.
24
+
Feel free to review the following in any order, or chose to skip ahead:
25
+
* [Your application](../application/)
26
+
* [PostgreSQL](../postgresql/)
27
+
* [Tigris](../tigris/)
28
+
* [Redis](../redis/)
29
+
30
+
Finally, as an added treat and as promised, let's add some AI functionality, in this case speech recognition using [Whisper](../whisper/).
31
+
32
+
And when you are done, join us for a [recap](../recap)
Your application comes initially configured for a single [Fly Postgres](https://fly.io/docs/postgres/) machine.
8
+
That is great for development, but for production we need redundancy and scalability. With but a [few commands](https://fly.io/docs/postgres/advanced-guides/high-availability-and-global-replication/) we can create a HA cluster in my primary region and read only replicas elsewhere.
9
+
10
+
If you are interested in a managed offering, [Supabase Postgres](https://fly.io/docs/reference/supabase/) is in public alpha.
11
+
12
+
And there is no lock in here. We have a list of [recommended external providers](https://fly.io/docs/postgres/getting-started/what-you-should-know/#recommended-external-providers), but you are free to host your database literally anywhere.
13
+
14
+
Before moving on, one last observation on the relational DB. While you want and need your application to be on the internet, you are much better off if your relational database is NOT directly exposed to the internet, but can only be accessed via your application. That’s the value of an [internal private network](https://fly.io/docs/networking/private-networking/). This too was configured automatically for you.
You are not satisfied by a `hello world` or even a `hello world` with a database application.
8
+
You know that a real world application has at a minimum the following components:
9
+
10
+
* A HTML form and a database. This database is typically a relational database.
11
+
* The ability to handle media files or documents, generally using S3.
12
+
* A multi-user and realtime component, where changes made by one person in one location are relected instantly in the browser of another person.
13
+
14
+
While this doesn't seem like a tall ask, experience has shown that in order to get such an app running smoothly, you need a whole bunch of things; here are a few examples: anycast routing, load balancers, dns certificates, web sockets, an internal private network, a relational database, an object store, and an in-memory database. And the knowledge of how to connect them all together.
15
+
16
+
Taken all together, this typically takes a **minimum** of an afternoon's worth of work, even by experts familiar with their target platform. With emphasis on the word _minimum_ as there always is a surprise, and often several.
17
+
18
+
In the next few minutes we will have all this up and running, and can leisurely explore how the pieces fit together. We even will have enough time left over
19
+
to integrate in AI functionality making use of GPUs.
20
+
21
+
With that understanding of requirements in place, lets proceed on.... [Aim](../aim/)
0 commit comments