Can Fly.io run on-demand machines?

Context: I am building a recruitment platform which which have a module of Technical round, where i want to provide candidates a dedicated isolated environment (2cpu , 4gb ram). for this I have a docker image in which i have packed all the necessary elements (ide, dev env tools etc).

Requirement: I am looking if FLY.io can help me run those docker containers on the fly per candidate, I want to control the start, end of machines with exact hardware config and want full control on spinning up multiple parallel machines and close them. So I want Fly.io can help me achieve this and would like to have a rough estimation on cost

Yes, this is a good use for Fly. You can play with the calculator to understand what costs would look like for your region.

A good technique for per-user machines that have a limited lifetime (e.g. for running a technical test) is just to run a timer in your main application, initiate a shutdown at the expiry of the timer, and then exit. A machine whose primary process has exited will itself exit.

For the machines themselves, I would use Machines rather than Sprites, unless you feel that the user would be stepping away from their work and then wanting to come back to it. Either way, I assume you will have some kind of always-on control machine that spins up instances, keeps track of login credentials, shows what is presently running, allows admins to terminate sessions early, etc.

Additional thought - do you have a tech spec already, and a projected monthly budget? One thing you may wish to pin down early is whether you’ll need a relational database.

Fly has Managed Postgres, but the starting price is a fair bit above the peppercorn prices for small machines; if you have project funding then this won’t be a bother for you, but you want to keep a handle on costs, or you prefer MySQL etc, then you’d have to seek another solution (another managed provider or, if you really want to be a DBA, run it on Fly yourself).

I checked the calculator, but my concern is let’s say my computer memory and storage all bundled in a machine is 100$/mo. But all my real runtime of machine was just 15 days so dono just get cost of duration i run.? And I also see there is cost of unused machine ? Can’t I destroy the machine and prevent that cost?

Regarding your databases related cost. I don’t need additional databse. As I provide everything in self hosted container image

OK. Let’s say that a month is 720 hours (24 * 30). So a machine at the rate you specify is $0.1388 per hour to run. If a test takes two hours then that’s $0.277 for one candidate. If you have 100 candidates in a month, and they use the full two hours each, that’s $27.77 spend that month. (In practice some candidates might finish early, and some may quit the test without finishing, so of course these numbers will vary).

Yes, machines that are exited or destroyed don’t cost anything. Data volumes are an exception, but they are exceptionally cheap, and I don’t think you’d need them for this case anyway. (Fly volumes are not NFS - they are on the bare-metal host, and can cause some issues, so ask questions if you think you might need them).

For what it’s worth, I think 4GB RAM and 2 (performance) CPUs may be an over-specification. What do you expect candidates to be doing to need all that resource?

Per my note about a control machine, you don’t need this if you’re happy to run a console command for every candidate. My assumption was/is that you’d want to make this self-serve, so candidates can click a button to provision the resource, and click a button to declare themselves finished, etc.

Can you please describe the issues that I might take note of? As far as my usecase is concerned I don’t mind if storage is attached to real physical machine or is a NFS. Because I will need that storage only for time period when a candidate is active. once a candidate is gone I dont need that machine at all.

I will be running a docker container that will provide candidates an environment to develop, test and execute their project. They will get an IDE, a browser and other development environment like node, python, postgresql, mongodb etc. And so that they can run their project properly we need to provide them atleast 2 core nd 4GB ram

Well I was thinking to control machines via api. So admin can provision the machines on-demand for candidates.

So my main question regarding billing remain same.

As per my machine config I have $86.19/mo, which translates to ~ $0.1197/hr.
So if i create one machine per candidate. and I have 100 candidates in a month for two hours each , that will cost me $23 per month. Correct?

Volumes are permanent storage that survive a reboot. The trouble they cause is if a machine needs to be switched back on, it must be deployed to the same host in order to attach to the volume. If that machine host has run out of space for new machines, that is not possible, so the deploy fails.

Since all machines have an ephemeral disk, you could just use that. The only trouble you’d have is that the candidate would lose everything if they crash their machine. If you want to resolve that, then a volume would not be a problem in your case, since you’d rarely have to redeploy - presumably in a crash scenario. (In the machine creation code it is a good idea to try several fallback regions, but that’s good practice anyway).

Yep, and you can use a low spec machine for this.

Correct, excluding the cost of your always-on control node. That cost should be minimal.

Final thought; I believe sprites can be created via an API too. They are a newer product and some wrinkles have been reported in this forum. However, there is no harm in you trying them, to see if you like them. I personally would stick with machines for now, but it is good to have the choice.