fly-atc 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 84eacfefce4abf1b07ac2dd417b1cc98027d64241af482c353bbb99f8c89b16f
4
+ data.tar.gz: 34a3bea58d8b09bd99b4da8633d1b8252b967dd0b588ae1dfc41a1a0ca2015ed
5
+ SHA512:
6
+ metadata.gz: '09c2649081775270809efec3abe745b8514b4ecd450b10e587f231d3f4cacdae1bc05c96c5adbdc3a286e23b70b2587fa205fa4e3bf7e30d7ac3367a553cde07'
7
+ data.tar.gz: 1c97f8b362c03cff6b26f94a250cb3b5fd332adb82506218da54f8f4a8c139940348dc7a2096941ce8327e23156f6dda8d3a90ee821517a0b8a4a5f7175e4bc5
data/MIT-LICENSE ADDED
@@ -0,0 +1,85 @@
1
+ Copyright (c) Sam Ruby
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ ---
23
+
24
+ Includes code made available under the same license:
25
+
26
+ Copyright (c) 37signals, LLC
27
+
28
+ Permission is hereby granted, free of charge, to any person obtaining
29
+ a copy of this software and associated documentation files (the
30
+ "Software"), to deal in the Software without restriction, including
31
+ without limitation the rights to use, copy, modify, merge, publish,
32
+ distribute, sublicense, and/or sell copies of the Software, and to
33
+ permit persons to whom the Software is furnished to do so, subject to
34
+ the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be
37
+ included in all copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
40
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
41
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
42
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
43
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
44
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
45
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46
+ Copyright (c) 37signals, LLC
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of this software and associated documentation files (the
50
+ "Software"), to deal in the Software without restriction, including
51
+ without limitation the rights to use, copy, modify, merge, publish,
52
+ distribute, sublicense, and/or sell copies of the Software, and to
53
+ permit persons to whom the Software is furnished to do so, subject to
54
+ the following conditions:
55
+
56
+ The above copyright notice and this permission notice shall be
57
+ included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
60
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
62
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
63
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
64
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
65
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66
+ Copyright (c) 37signals, LLC
67
+
68
+ Permission is hereby granted, free of charge, to any person obtaining
69
+ a copy of this software and associated documentation files (the
70
+ "Software"), to deal in the Software without restriction, including
71
+ without limitation the rights to use, copy, modify, merge, publish,
72
+ distribute, sublicense, and/or sell copies of the Software, and to
73
+ permit persons to whom the Software is furnished to do so, subject to
74
+ the following conditions:
75
+
76
+ The above copyright notice and this permission notice shall be
77
+ included in all copies or substantial portions of the Software.
78
+
79
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
80
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
82
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
83
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
84
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
85
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # fly-atc
2
+
3
+ A SaaS toolkit for converting a personal application into a efficient, siloed, multi-tenant application, where each user of your application is assigned a dedicated virtual machine.
4
+
5
+ ** Work in Progress **
6
+
7
+ ## Usage
8
+
9
+ This is all TBD at this point, but for Rails projects it is likely to go something like this:
10
+
11
+ * Replace thruster with fly-atc in Gemfile and Dockerfile
12
+ * Define your tenants in a config file, probably YAML.
13
+
14
+ For non-Rails projects, the process is likely going to be similar:
15
+
16
+ * Follow the instructions for using thruster with your framework, but substitute fly-atc for thruster.
17
+ * Define your tenants in a config file, probably YAML but JSON could also be supported.
18
+
19
+ Fly.io's dockerfile generators will be able to help with this.
20
+
21
+ For approximately $1 US per month, you can run:
22
+ * [1 performance machine with 2Gb of RAM, 10GB of bandwidth, and 5GB of storage for 15 hours/month](https://fly.io/calculator?m=0_0_0_0_0&f=c&b=iad.10&a=no_none&r=shared_0_1_iad&t=10_100_5&u=0_1_100&g=1_performance_15_1_2048_iad_1024_0).
23
+ * [1 shared machine with 1Gb of RAM, 10GB of bandwidth, and 5GB of storage for 80 hours/month](https://fly.io/calculator?m=0_0_0_0_0&f=c&b=iad.10&a=no_none&r=shared_0_1_iad&t=10_100_5&u=0_1_100&g=1_shared_80_1_1048_iad_1024_0).
24
+
25
+ Vertical scaling can be achieved by adding more machines.
26
+
27
+ ## Motivation
28
+
29
+ I've been running my [Showcase](https://github.com/rubys/showcase?tab=readme-ov-file#showcase) software for nearly three years. Things have changed over time that I now want to take advantage of. I want take the opportunity to package those changes in the form of a toolkit that others can take advantage of.
30
+
31
+ From Wikipedia description of [SaaS](https://en.wikipedia.org/wiki/Software_as_a_service):
32
+
33
+ > SaaS customers have the abstraction of limitless computing resources, while [economy of scale](https://en.wikipedia.org/wiki/Economy_of_scale) drives down the cost. SaaS architectures are typically [multi-tenant](https://en.wikipedia.org/wiki/Multi-tenant); usually they share resources between clients for efficiency, but sometimes they offer a siloed environment for an additional fee.
34
+
35
+ The focus of this toolkit is efficient, siloed, multi-tenant applications *with no changes to the application*, taking advantage of:
36
+
37
+ * [Auto-suspend](https://community.fly.io/t/autosuspend-is-here-machine-suspension-is-enabled-everywhere/20942) - Virtual Machines that pop into existence when needed and disappear when not in use.
38
+ * [SQLite ready for production](https://rubyonrails.org/2024/11/7/rails-8-no-paas-required#getting-sqlite-ready-for-production) - raw performance coupled with operational compression of complexity; see [Supercharge the One Person Framework with SQLite: Rails World 2024](https://fractaledmind.github.io/2024/10/16/sqlite-supercharges-rails/).
39
+ * [Litestream](https://litestream.io/) - No-worry backups. Virtual machines can be literally destroyed and recreated elsewhere and start back up exactly where they left off.
40
+ * [Tigris Global Storage](https://fly.io/docs/tigris/) - globally caching, S3-compatible object storage.
41
+
42
+ That's a lot of moving parts. I've documented my [current architecture](https://github.com/rubys/showcase/blob/main/ARCHITECTURE.md) and published a [blueprint](https://fly.io/docs/blueprints/shared-nothing/).
43
+
44
+ The goal of fly-atc is to enable you configure multiple tenants and then not worry about this further, enabling you to focus on your application.
45
+
46
+ ## Approach
47
+
48
+ For illustrative purposes consider a SaaS Calender application implemented in Ruby on Rails using SQLite3 as the database. (My showcase application is a bit more involved than a calendar, but those details aren't important).
49
+
50
+ Key concepts:
51
+
52
+ * Each user/customer has a primarly location, and is assigned a single machine near that location. Such machines can be accessed from anywhere, but have lower latency near that location.
53
+ * Each user can have multiple calendars. Each calendar is associated with a single tenant on the user's machine. Each tenant consists a running instance of the web server application with one ([or more](https://rubyonrails.org/2024/11/7/rails-8-no-paas-required#a-solid-reduction-of-dependencies)) databases.
54
+
55
+ With that in mind, consider the following URL paths:
56
+
57
+ * `/bellevue/2025/winter/`
58
+ * `/bellevue/2025/summer-medal-ball/`
59
+ * `/bellevue/2025/summer-showcase/`
60
+ * `/boston/2025/april/`
61
+ * `/boston/2025/mini-comp/`
62
+ * `/boston/2025/october/`
63
+ * `/livermore/2025/the-music-of-prince/`
64
+ * `/livermore/2025/james-bond/`
65
+ * `/raleigh/2025/disney/`
66
+ * `/raleigh/2025/in-house/`
67
+
68
+ The first segment of the path identifies the user, and therefore the machine. The next two segments combined identify the tenant on that machine. This is but a subset of the planned showcases, you can see a [full list](https://smooth.fly.dev/showcase/) or even a [map](https://smooth.fly.dev/showcase/regions/) (click on the arrows under the map to move to different continents).
69
+
70
+ `fly-atc`'s responsibilities are to:
71
+ * Route requests to the correct machine
72
+ * Ensure databases are present/restored from backup
73
+ * Start/stop tenants as required
74
+ * Hand off requests to tenants
75
+
76
+ Rails 8 introduces [thruster](https://rubyonrails.org/2024/11/7/rails-8-no-paas-required#enter-kamal-2--thruster). `fly-atc` is a replacement for thruster:
77
+ * thruster requires no configuration, is limited to a single tenant.
78
+ * fly-atc enables multiple tenants, based on your configuration.
79
+
80
+ ## Implementation
81
+
82
+ Based on:
83
+ * [Thruster](https://github.com/basecamp/thruster) ([announcement](https://dev.37signals.com/thruster-released/))
84
+ * [tinyrp](https://github.com/pgaijin66/tinyrp) ([docs](https://prabeshthapa.medium.com/learn-reverse-proxy-by-creating-one-yourself-using-go-87be2a29d1e))
85
+
86
+ Near term plans:
87
+
88
+ * Remove certificate/https support
89
+ * Add launch on request / shutdown on idle
90
+ * Add [fly-replay](https://fly.io/docs/networking/dynamic-request-routing/)
91
+
92
+ On the radar:
93
+
94
+ * Support for targets other than fly.io.
95
+ * Support for platforms other than Rails, likely starting with Node, and focusing on popular ORMs: [Prisma](https://www.prisma.io/), [TypeORM](https://typeorm.io/), and [Sequelize](https://sequelize.org/).
96
+ * Dashboard. One should be able to deploy new users and make other configuration changes using only your cell phone. I [do this today](https://github.com/rubys/showcase/blob/main/ARCHITECTURE.md#administration) with my showcase application.
data/exe/fly-atc ADDED
@@ -0,0 +1,11 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ PLATFORM = [ :cpu, :os ].map { |m| Gem::Platform.local.send(m) }.join("-")
4
+ EXECUTABLE = File.expand_path(File.join(__dir__, PLATFORM, "fly-atc"))
5
+
6
+ if File.exist?(EXECUTABLE)
7
+ exec(EXECUTABLE, *ARGV)
8
+ else
9
+ STDERR.puts("ERROR: Unsupported platform: #{PLATFORM}")
10
+ exit 1
11
+ end
@@ -0,0 +1,3 @@
1
+ module FlyAtc
2
+ VERSION = "0.0.1"
3
+ end
data/lib/fly-atc.rb ADDED
@@ -0,0 +1,4 @@
1
+ module FlyAtc
2
+ end
3
+
4
+ require_relative "fly-atc/version"
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fly-atc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sam Ruby
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: An HTTP/2 proxy for mutli-tenant production deployments
14
+ email: rubys@intertwingly.net
15
+ executables:
16
+ - fly-atc
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - MIT-LICENSE
21
+ - README.md
22
+ - exe/fly-atc
23
+ - lib/fly-atc.rb
24
+ - lib/fly-atc/version.rb
25
+ homepage: https://github.com/rubys/fly-atc
26
+ licenses:
27
+ - MIT
28
+ metadata:
29
+ homepage_uri: https://github.com/rubys/fly-atc
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.5.18
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: A SaaS toolkit
49
+ test_files: []