// framework · sinatra

Sinatra: small, sharp, shippable.

The 40-line Dockerfile framework. Perfect for internal APIs, webhooks, and 'we just need one endpoint' services.

Sinatra doesn't need a deployment guide as much as it needs a discipline guide — the framework gets out of your way, which means every deployment decision is yours. Here's the boring, correct default.
128 MB
typical image size
220 ms
cold boot
~4k
req/s on 1 vCPU
01 / 03

config.ru is the deploy target

Every cloud that speaks Rack — which is all of them — will boot a Sinatra app given a config.ru and a Gemfile. Keep it that simple.
ruby
# config.ru require "./app" run Sinatra::Application # Gemfile source "https://rubygems.org" ruby "3.3.5" gem "sinatra", "~> 4.1" gem "puma", "~> 6.4" gem "json"
02 / 03

Puma config that scales

Sinatra apps are usually thread-safe and stateless — perfect for a threaded Puma. Set workers to your CPU count on VMs, and to 1 on Fargate / Cloud Run.
ruby
# config/puma.rb threads Integer(ENV.fetch("RAILS_MIN_THREADS", 5)), Integer(ENV.fetch("RAILS_MAX_THREADS", 5)) workers Integer(ENV.fetch("WEB_CONCURRENCY", 1)) preload_app! port ENV.fetch("PORT", 3000) environment ENV.fetch("RACK_ENV", "production")
03 / 03

Health checks

Add a `/healthz` route that returns 200 without touching the database, and a `/readyz` that does. Every load balancer expects both.
ruby
get "/healthz" do content_type :json { status: "ok", pid: Process.pid }.to_json end

Gotchas we learned the hard way

  • !The classic-style Sinatra app is a singleton — don't stash per-request state in constants or class ivars.
  • !Rack 3 changed the response body contract to require `each` returning strings, not arrays. Some old middleware will break.
  • !If you use `Sinatra::Reloader`, gate it behind `configure(:development)` — it's slow and unsafe in production.

Official resources

Docs, repos, and training materials for this framework.

Related guides

Ready?
Deploy a Sinatra service in under 10 minutes

GCP Cloud Run and Heroku both take an unmodified Sinatra app + Gemfile and just work. Start there.