Scaling an application is a complex subject with many variables, in this page we will focus on a number of factors that are largely universal: number of CPU cores, memory, and both the number and placement of virtual machines.
Not covered here is scaling of databases or scaling of volumes.
For information on costs, see Fly App Pricing.
RAM is a precious commodity - both to those on Hobby plans who want to remain within or near the free allowances, and to apps that want to scale to be able to handle a large number of concurrent connections.
At some point you may find that you need more memory. There are two types: real and virtual. Real is faster, but more expensive. Virtual (swap) is slower and generally free.
Some starting point recommendations:
- 256MB is enough to run small applications with few users
- 512MB is a better place to start if you are doing image processing or have a moderate number of users.
- 1024MB is a minimum if you are running an application that uses puppeteer or otherwise makes use of chrome’s rendering engine.
Once you have settled on a size, some links to get you started:
These options are not mutually exclusive. A good starting point may be 512MB of RAM and 1024MB of swap.
Node.js has a cluster module that can be used to address this. See Run a Node.js HTTP Express.js Server on Multiple CPU Cores for an example on how to use this module.
Once your application is coded to take advantage of multiple cores,
fly machines list to see a list of your machines, and then
fly machine update --vm-cpus to update the number of CPUs a single machine.
For most JS applications the key to scaling will be in creating more virtual machines, each with enough memory and CPU cores to handle a unit of workload. More information on that topic can be found on the Scale the Number of Machines page.