Machines as Ephemeral Code Playground Backend

  1. Is this a scenario which sounds like a good fit for Machines v2?
    Hmm, there’s a lot to answer here, so I’ll break this into each need and goal of yours:
  • Some sort of custom stateless Machine vending service which is being called from our frontend
    • You could make calls to the machines api to make machines with custom sizes, names, and other settings.
  • This returns a URL to a fly.io Machine (e.g. my-code-playground-385krl.fly.dev )
    • There’s a few ways that you could do this. For one, you could create an app for each user, since each app automatically gets a URL. Another way would just be having a subdomain for each user on top of your domain, like billy.mycoolapp.fly.dev
  • The frontend communicates with that machine via REST and Websockets (code updating, invoking functions / services)
    • We have pretty solid support for HTTP apps and websockets.
    • You could use the existing autostop feature for * After a defined idle time, the Machine will stop automatically
      machines
      , which will stop a machine when it hasn’t received any traffic for a few minutes. As for defining the specific idle time, I think we support that through setting kill_timeout on that specific machine, but I could be wrong. However, you could always create your own service that uses the machines api to stop machines.
  • A cron job or something like this will clean up stale Machines
    • This would also be well serviced by an app that uses the machines API

Overall, I’d say yes, machines would be a pretty great candidate for this.
2. Is it one app with multiple machines, or many apps with a dedicated machine each?
You can do either! It really just depends on what your requirements and needs are.
3. Are there defined or practical limits in terms of apps / machines we could provision? (resource requirements more on the lower end)
You can view the machine preset sizes here. The lowest you can go in 1 shared CPU that uses 256 MB of memory.

  1. Could we map our own domain somehow?
    You should be able to, though I have less experience on this. See these docs for more information