Error not enough volumes named foo (1) to run 2 processes

I’m getting this error on deploy:

==> Creating release
Error not enough volumes named volume_name_redacted (1) to run 2 processes

I have a Flask app with two processes, a web server and a worker - both of them should be able to access the SQLite database that is located on a volume. Do I need to modify my fly.toml file to mount the same storage twice or something?

Here’s my fly.toml:

app = "redacted"

kill_signal = "SIGINT"
kill_timeout = 5

[env]
  PORT = "8000"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[mounts]
  source="volume_name_redacted"
  destination="/db"
  processes = ["web", "worker"]

[processes]
  web = "gunicorn wsgi --log-level 'info'"
  worker = "celery -A worker.celery worker --loglevel=info --concurrency=1 -B -E"

[[services]]
  http_checks = []
  internal_port = 8000
  processes = ["web"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 6
    timeout = "2s"

#[[statics]]
#  guest_path = "/app/public"
#  url_prefix = "/static/"

Volumes can’t be attached to multiple instances.

As per the docs:

Volumes are bound to both apps and regions. A volume is directly associated with only one app and exists in only one region.

And kurt around here:

@mrkishi what is the suggested way to accomplish what I’m looking to do then?

  • SQLite database on a volume
  • Persists between deploys
  • Web server using gunicorn/Flask
  • Worker service using Celery

You’ll want to run both services in the same VM. Check these docs for a few ways to go about that: Running Multiple Processes Inside A Fly.io App

OK, I’ll follow those suggestions in the docs…but doesn’t this kind of defeat the point of being able to specify and run multiple processes in fly.toml and having the benefit of mounted volumes?

I guess if all those services are totally stateless and only rely on network connections to the outside, then it works.

It’s not really possible to mount a single volume across multiple VMs.

But like you said, there are plenty of use cases for mutli-process apps. If you run Postgresql, for example, instead of SQlite, you can do this no problem. That does not mean your app is stateless - it just stores data somewhere that does not require attaching a volume to your application VM. This is the most common way people build full stack apps today.

That said, we think it would be great to have a distributed SQLite solution. It’s definitely something we’re thinking about!

Is it possible to scale volumes like I scale instances?
For example - scale count 2 will also do the same thing with volumes and they will be each other mirrors.

No worries, I figured it out. Creating a new volume from a snapshot is really a breeze :+1: