What is an instance and how do I create multiple instances?

Hi all.
I’m new to fly.io, and a few other things. After some discussion on twitter with a staffer, I have some questions.

In the discussion the staffer mentions an “instance”. How is this defined within fly.io?
How do I create and run multiple instances?
Is this different from a process?
Is it related to docker?

I’m also new to docker, so I’m not familiar with any termonolgy there either.

I managed to get set up with an example project, running node.

Hobby project concept:
I’m creating a bot to enable people to play a game via twitter.
Using a cron based on twitter rate limit, fetch new mentions and process.
Processing tweets creates jobs on cloudflare workers.
Cloudflare workers must run fast, and so will mostly make requests to the fly.io server.
Server will run worker task, accessing database, and potentially creating more jobs on the worker system.

I had planned to use PM2 to manage the cron(using a cron style reset config), but the staffer suggested I should use two “instances”, as the cron and the http server didn’t interact.

(I’m aware I could use another worker system, but part of the technical challenge to myself is to see if I can use cloudflare workers to make this happen. I’m also hosting the database elsewhere.)

Background on me:
I have almost a decade of experience in web development and currently work on a large node application. I do not however have experience with devops, as our org has their own team to handle such things. (I tried docker many years ago, so I’m familiar with what it does, just not how to use it.)

An application on Fly is, effectively a process running on its own VM. This is an instance of the application. When the capacity of an instance, defined by the number of concurrent connections, is exceeded, Fly automatically creates a new instance to run alongside it in the same region. Instances are created in regions selected by the user and created in response to rules. It is different from a process on a typical OS, because there’s only one process running in an instance and generally there’s no forking or launching other processes.

Docker implements a similar model for its own runtime. Docker-compose is a Docker tool which lets you coordinate multiple different instances to give the appearance of multi-process applications running.

On Fly, we just let you make another app, which you can deploy and coordinate with other components (in their own apps) as needed.

Thanks for your reply.
So if I understand correctly, if I want to run two processes, I should run them as two separate applications?

How does this effect the CPU and Memory tier I use? Will multiple applications share CPU and Memory, or will I in effect, be using at least 2x micro-1x?

If I’ve missunderstood, and you’re not suggesting two applications, how do I go about running two processes?

Yes, if they are independent of each other, then run two applications.

Multiple applicatons do not share CPU and memory. It will be (if untouched x2 micro2x VMs… scale the vm size down to get x2 micro1x instances)

Thanks for the info.
How do I go about scaling it down by default?
Assume it’s an option or config I’ve missed?

Run flyctl scale vm micro-1x

The scaling options are under the flyctl scale command - See https://fly.io/docs/scaling/

Hi there,
I didn’t find more related topic for my question so decided to ask here.
I got a django app with multiple other docker images like postgres, redis, selenium and a data volume.
currently i use docker-compose to run multiple images.
so in an specific app i can’t have more than one docker image,
but can i have multiple app that communicate with each other on different (internal) ports?

@mahdikhashan1 not yet! We’re rolling out private networking very soon, which will solve part of that for you. We’re hoping to make “launch Docker compose on Fly” reasonably easy soon, but it’s not something you can do very well yet.