// framework · cuba

Cuba: micro, fast, boring.

Sinatra without the DSL sugar. A few hundred lines of Ruby, built on Rack. Deploys like a dream because there's nothing to it.

Cuba is a micro-framework by Michel Martens, built on top of Rack. It's aggressively minimal — routing, and that's about it — which makes it a superb foundation for high-throughput APIs where every allocation matters.
~200
framework LOC
~5.2k
req/s on 1 vCPU
102 MB
min container size
01 / 03

Rack, Puma, done

Cuba doesn't invent a new deployment model. It's Rack. Puma runs it. The Dockerfile is 12 lines.
ruby
# config.ru require "cuba" Cuba.define do on get do on "hello" do res.write "world" end end end run Cuba
02 / 03

Compose with plugins, not with a monolith

Cuba's plugin system (Cuba.plugin Rendering) is how you add ERB, JSON responses, sessions, etc. Add only what you need — that's the whole point.
03 / 03

Threaded Puma is the default

Cuba code tends to be short and non-blocking. Set Puma to 5 threads × 2 workers on a 1 vCPU container and you'll saturate the network before the CPU.

Gotchas we learned the hard way

  • !No ActiveRecord, no session store, no CSRF out of the box. Add Ohm or Sequel, add rack-session, add rack-protection — you're picking the stack.
  • !Cuba plugins are loaded at boot with global effect. Don't try to conditionally load them per-request; it won't work the way you think.
  • !The routing DSL is order-sensitive. Put more specific routes before catchalls, or you'll debug a 'route never matches' issue that has a two-line fix.

Official resources

Docs, repos, and training materials for this framework.

Related guides

Ready?
Ship a Cuba service

Cloud Run and Fargate love tiny, fast containers. Cuba is happy on either — pick by whichever cloud you already run.