Fly Machines: an API for fast-booting VMs

Fly Machines are VMs with a fast REST API that can boot instances in about 300ms. Our proxy can boot Fly Machines for you, and you can shut them down when they’re idle. Which means you can cost-effectively create VMs and keep them standing by to ha

Kurt Mackey
9 min readintermediate
--
View Original

Overview

Fly Machines is an API developed by Fly.io that allows for the rapid booting of virtual machines (VMs) in approximately 300 milliseconds. The article discusses the architecture, performance optimization strategies, and practical applications of Fly Machines, emphasizing their cost-effectiveness and scalability features.

What You'll Learn

1

How to quickly boot VMs using the Fly Machines API

2

Why scaling applications to zero can save costs

3

When to create machines ahead of time for optimal performance

Key Questions Answered

How fast can Fly Machines boot VMs?
Fly Machines can boot virtual machines in about 300 milliseconds, depending on the proximity of the API and the hardware. This speed is achieved by minimizing infrastructure latency and optimizing the process of starting machines.
What is the process for creating a machine in Fly.io?
The process involves a request to an API server, which checks a centralized database for available resources, reserves capacity on a host, and creates a machine record. This entire process is designed to be efficient, although it may take longer if the request is made from a distant location.
What are the cost implications of using Fly Machines?
Running Fly Machines costs the same as normal VM instances, with additional charges for storage when machines are stopped. Currently, users pay approximately $0.15 per month for a 1GB Docker image when the machine is not running.
How does Fly.io handle scaling to zero?
Fly.io allows applications to scale to zero by exiting the process when idle, effectively stopping the machine while keeping it intact for future requests. This method ensures that resources are not wasted when the application is not in use.

Key Statistics & Figures

VM boot time
300ms
This is the average time it takes for Fly Machines to boot a VM, depending on network latency and proximity to the API.
Cost of stopped machines
$0.15/mo for a 1GB Docker image
This is the current charge for storage when a machine is not running.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
To optimize costs, consider creating Fly Machines ahead of time rather than on-demand. This approach allows you to leverage the low storage costs associated with stopped machines while ensuring quick availability when needed.
By pre-creating machines, you can avoid the latency involved in pulling Docker images from remote repositories, which can significantly delay startup times.
2
Utilize the Fly Machines API to build your own functions-as-a-service (FaaS) applications. This can enhance your application's responsiveness and scalability.
Building a FaaS with Fly Machines allows you to efficiently manage resources and respond to user requests without incurring unnecessary costs.
3
Design your application logic to start machines close to your users. This minimizes latency and improves performance during startup.
By ensuring that the start commands are executed from the nearest API server, you can achieve significantly faster response times, enhancing user experience.

Common Pitfalls

1
One common pitfall is relying solely on a single machine for critical applications. If that machine fails or is unavailable, it can lead to downtime.
To avoid this, it's recommended to have redundancy by creating multiple machines across different locations, ensuring that if one fails, another can take over.
2
Another issue is not pre-creating machines when expecting high traffic. This can lead to delays in response times as machines are booted on demand.
Planning ahead and creating machines during low-traffic periods can help mitigate this risk and ensure that resources are available when needed.

Related Concepts

Functions-as-a-service (faas)
Virtual Machine Orchestration
Cost Optimization Strategies In Cloud Computing