# Preview: persistent disks for Fly apps

**URL:** <https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332>\
**Category:** General\
**Tags:** volumes\
**Created:** [October 26, 2020, 9:36pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332 "2020-10-26T21:36:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [October 26, 2020, 9:36pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/1 "2020-10-26T21:36:52Z")

</div>

We’re releasing persistent disks soon, you can try them out now if you’re curious. `flyctl 0.0.145-beta-3` introduces a `volumes` command you can use to provision permanent disks for your applications.

Volumes are persistent, maintain their data between deploys, and even stick around if your app is suspended.

Creating a volume is simple, this creates a 25GB volume in `ewr`: `flyctl volumes create <name> --region ewr --size 25`

To mount this volume at `/data`, add this to your app config:

```toml
[[mounts]]
  source = "data"
  destination = "/data"

```

You can create multiple volumes with the same name, if you want to run an app in 3 regions, run these commands (and keep `[[mounts]]` in your config the same):

```bash
flyctl volumes create data --region ewr --size 25
flyctl volumes create data --region cdg --size 25
flyctl volumes create data --region syd --size 25

```

Some limitations:

- You can only mount one volume in a VM (we’re curious if you need more)
- We don’t have snapshots/backups available yet
- Your app can only scale to as many VMs as you have volumes. If you’ve created 3 volumes named “data”, your app can scale to 3 VMs.

Other things to know:

- The price is $0.15 per GB per month
- Performance will be better than general purpose EBS in most cases

---

<div class="post-metadata">

**Author:** ![austincollinpena](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/austincollinpena/32/1560_2.png) [@austincollinpena](https://community.fly.io/u/austincollinpena)\
**Post date:** [October 27, 2020, 4:58pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/2 "2020-10-27T16:58:23Z")

</div>

So exciting!

If there are multiple VM’s in a region due to auto scaling, do they access the same volume?

> - Your app can only scale to as many VMs as you have volumes. If you’ve created 3 volumes named “data”, your app can scale to 3 VMs.

This means “no” right? You would need to vertically scale an app, right?

---

<div class="post-metadata">

**Author:** ![michael](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/michael/32/16_2.png) [@michael](https://community.fly.io/u/michael)\
**Post date:** [October 27, 2020, 5:48pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/3 "2020-10-27T17:48:41Z")

</div>

You can either scale vertically or add more volumes to scale horizontally.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jared/32/46_2.png) [@jared](https://community.fly.io/u/jared)\
**Post date:** [November 30, 2020, 6:25am UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/4 "2020-11-30T06:25:28Z")

</div>

I’m trying to wrap my head around this…so I’m very interested in hosting MongoDB through Fly, but with the one-volume-per-VM aspect, for a multi-region deployment I would either need to:

1. Set up multiple DB instances to comprise a single replica set (is that the right term?)
2. Create just a single separate DB instance in region-of-choice and point all app VMs from any region to it (slower but simpler)

Also, I tried to use ScaleGrid + DigitalOcean a while back and the SSL story was a pain. MongoDB Atlas fared much better. I wonder how it might work through Fly?

---

<div class="post-metadata">

**Author:** ![Codepope](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/codepope/32/4_2.png) [@Codepope](https://community.fly.io/u/Codepope)\
**Post date:** [November 30, 2020, 9:00am UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/5 "2020-11-30T09:00:23Z")

</div>

The architecture will be more driven by MongoDB than Fly. MongoDB basically demands a single production database is a replica set (three nodes) tightly bound and failing over for each other (It’s not advisable to have replica sets spread out widely). Anyway, each node of the replica set would have its own volume. And that would make a functioning database. Above that, you could create similar configurations in different locations and then cluster them together. But you might want to just consider effective query caching in your application, rather than dealing with the complexity of MongoDB clusters.

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [November 30, 2020, 3:53pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/6 "2020-11-30T15:53:07Z")

</div>

> [@jared](#):
>
> but with the one-volume-per-VM aspect

Just to clarify … you can only mount one volume per VM _instance_. If you add 3 volumes with the same name, you can use `flyctl scale set min=3` and get a cluster of VMs each with their own volume.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jared/32/46_2.png) [@jared](https://community.fly.io/u/jared)\
**Post date:** [November 30, 2020, 4:10pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/7 "2020-11-30T16:10:02Z")

</div>

Yeah, I would probably be well served by caching the data with Redis for fast reads. Writing would be less frequent and less demanding of performance. Thanks @Codepope for the tip!

---

<div class="post-metadata">

**Author:** ![austincollinpena](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/austincollinpena/32/1560_2.png) [@austincollinpena](https://community.fly.io/u/austincollinpena)\
**Post date:** [December 5, 2020, 5:02am UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/8 "2020-12-05T05:02:21Z")

</div>

I’m going to try this out soon for a little disk based cache I’ve been playing around with.

Are the deployments still zero downtime? How does that work?

Can I vertically scale with zero down time?

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [December 5, 2020, 5:23am UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/9 "2020-12-05T05:23:41Z")

</div>

If you add one volume, deployments will cause downtime while the VM is rebuild and reboots.

If you add two volumes, and set `flyctl scale set min=2`, deployments won’t have downtime. We do rolling upgrades on those.

Right now, vertical scaling requires a full deploy. You also can’t (currently) resize volumes.

---

<div class="post-metadata">

**Author:** ![austincollinpena](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/austincollinpena/32/1560_2.png) [@austincollinpena](https://community.fly.io/u/austincollinpena)\
**Post date:** [December 5, 2020, 3:45pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/10 "2020-12-05T15:45:00Z")

</div>

> Right now, vertical scaling requires a full deploy. You also can’t (currently) resize volumes.

That’s a bummer, but I guess it’s about time I built a piece of backup - infra that I can point my cname to during times like those.

Do you have ideas how long it takes to upgrade from a micro-2x to a cpu1mem1? Or should I just test it myself?

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [December 5, 2020, 6:37pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/11 "2020-12-05T18:37:53Z")

</div>

> [@austincollinpena](#):
>
> Do you have ideas how long it takes to upgrade from a micro-2x to a cpu1mem1? Or should I just test it myself?

It should be quick! Like less than 2s.

Our initial volumes release is designed for clusters, primarily. It’s worth it to run 2 VMs in general so we’re trying to build things that work well with 2+ VMs. 😃

---

<div class="post-metadata">

**Author:** ![austincollinpena](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/austincollinpena/32/1560_2.png) [@austincollinpena](https://community.fly.io/u/austincollinpena)\
**Post date:** [December 6, 2020, 2:19am UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/12 "2020-12-06T02:19:12Z")

</div>

> [@kurt](#):
>
> clusters

You mean having multiple VM’s in the same data center? Or just multiple VM’s period?

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [December 6, 2020, 6:24pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/13 "2020-12-06T18:24:31Z")

</div>

Multiple VMs period. Most people run one per region, and just let traffic move to another region during deploys (or if a VM dies).

---

<div class="post-metadata">

**Author:** ![austincollinpena](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/austincollinpena/32/1560_2.png) [@austincollinpena](https://community.fly.io/u/austincollinpena)\
**Post date:** [December 8, 2020, 5:04pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/14 "2020-12-08T17:04:53Z")

</div>

Is there any way to get a look into how much file storage is used through Fly?

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [December 10, 2020, 1:40am UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/15 "2020-12-10T01:40:12Z")

</div>

We don’t have that exposed via metrics yet, although we should by the time they’re launched for real!

---

<div class="post-metadata">

**Author:** ![austincollinpena](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/austincollinpena/32/1560_2.png) [@austincollinpena](https://community.fly.io/u/austincollinpena)\
**Post date:** [December 20, 2020, 3:32am UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/16 "2020-12-20T03:32:34Z")

</div>

How does a failover region work with this? For example I have a fail over region for my Sunnyvale instance for LAX and Seattle. If I only have a volume in LAX, will the failover automatically go to LA?

---

<div class="post-metadata">

**Author:** ![austincollinpena](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/austincollinpena/32/1560_2.png) [@austincollinpena](https://community.fly.io/u/austincollinpena)\
**Post date:** [December 20, 2020, 3:42am UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/17 "2020-12-20T03:42:15Z")

</div>

Also, quick bug when running:

`flyctl volumes show 5bf-----`

```auto
?[31mError?[0m Field 'Volume' doesn't exist on type 'Queries'

```

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [December 21, 2020, 4:06pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/18 "2020-12-21T16:06:52Z")

</div>

> [@austincollinpena](#):
>
> How does a failover region work with this? For example I have a fail over region for my Sunnyvale instance for LAX and Seattle. If I only have a volume in LAX, will the failover automatically go to LA?

Yep! Volumes constrain where VMs can run. Our scaling UX isn’t quite right for this kind of workload, so it’s a little confusing, but VMs will only launch where you’ve created volumes.

---

<div class="post-metadata">

**Author:** ![emiliendevos](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/emiliendevos/32/48319_2.png) [@emiliendevos](https://community.fly.io/u/emiliendevos)\
**Post date:** [December 27, 2020, 2:31pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/19 "2020-12-27T14:31:20Z")

</div>

Why a minimum of 10 GB for the size of the volume? What if I just want to create a volume with just 1 GB for small applications?

---

<div class="post-metadata">

**Author:** ![jveres](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jveres/32/271_2.png) [@jveres](https://community.fly.io/u/jveres)\
**Post date:** [December 27, 2020, 3:23pm UTC](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332/20 "2020-12-27T15:23:42Z")

</div>

Just curious if sharing a volume between apps in the same region would be possible.  
(I checked and it’s not currently.)

[Next page](https://community.fly.io/t/preview-persistent-disks-for-fly-apps/332.md?page=2)
