Kamal proxy: Thruster
This course covers Thruster, the Go binary that wraps Puma inside the application container. It starts with the cost of serving static files from Puma's limited request slots, then reads the Gemfile and Dockerfile lines that make up the whole integration. Lessons explain how X-Sendfile hands file transfers from Rails to the proxy, why digest-named assets make a one-year cache safe, and how compression is decided by content type. The course also covers what Thruster leaves to kamal-proxy and Rails, and how to measure whether it helps.
What you'll learn
- ✓Why static files and slow clients tie up Puma's request slots
- ✓How the Dockerfile CMD wraps Puma with Thruster and keeps the entrypoint check working
- ✓How X-Sendfile lets Rails authorize a file and hand the transfer to the proxy
- ✓Why digest-named assets make a one-year cache safe, and how compression is decided
- ✓How assume_ssl and force_ssl avoid a redirect loop between kamal-proxy and Thruster
- ✓How to measure Ruby threads spent on requests that need no Ruby
The job Puma should not do
Puma is a Ruby web server, and it's very good at running Ruby. Something else usually sits in front of it because serving a static file isn't running Ruby, and doing it in a Ruby thread is expensive in a specific way.
Read the full lesson free →Curriculum
7 lessonsThe job Puma should not do
Shows how serving static files holds Puma's few request slots, and compares nginx with Thruster as the fix.
The line in the Dockerfile
Finds Thruster in the Gemfile and Dockerfile, traces the process tree and explains why the entrypoint check survives.
X-Sendfile and the handoff
Explains how X-Sendfile lets Rails authorize a file while Thruster streams the bytes from the same container.
Caching and compression
Covers why digest-named assets allow a one-year cache, Thruster's memory cache, and compression decided by content type.
What it does not do
Lists what Thruster leaves out, including routing, TLS here, health checks and rate limiting, and when it stops fitting.
Measuring whether it helps
Measures Thruster by Ruby threads held for requests needing no Ruby, and explains why its effect is small here.
Putting it together
Summarizes the course in five points and sets a challenge to compute the thread-seconds Thruster saves.