API concurrency issue

"I have a FastAPI backend deployed on Fly.io that handles PDF processing for my React frontend. When a user selects a component, two things should happen independently:

  1. Display a PDF file from a direct URL in an iframe
  2. Process this PDF on the server for future Q&A functionality

The issue: When deployed on Fly.io, the PDF doesn’t display until the server finishes processing it, even though these should be independent operations. The PDF viewer is using a direct URL that shouldn’t depend on server processing.

Interestingly, when running the same code locally, everything works as expected - the PDF displays immediately while processing happens in the background.

My fly.toml configuration:

toml

Copy

[http_service]
  internal_port = 8000
  force_https = true
  auto_stop_machines = 'stop'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1

This seems like a concurrency issue where Fly.io might be queuing all requests while processing the PDF, even though the PDF display should be independent. Has anyone encountered similar issues with long-running processes blocking other requests on Fly.io?"

Try adding more CPUs? Is your web server also responsible for the PDF processing? You should create another app to handle those tasks async otherwise you’ll block your web server.

Makes sense. Thanks a lot!