Use Thruster to expose request queue time

While the package installation alone will allow background job (worker) services to connect to Judoscale, web services require an additional step. In order to correctly determine request queue time for web services, Judoscale reads a unique header on each incoming request: X-Request-Start. Some hosting platforms automatically add this header to every incoming request. Amazon ECS does not. So we’ll need to add it ourselves!

Thruster is a small HTTP proxy from Basecamp that runs in front of your app server, inside your app’s container. Since version 0.1.15, Thruster adds an X-Request-Start header to every request it proxies (unless the request already has one), in the same t=<unix milliseconds> format our NGINX sidecar uses. It’s always on, so there’s nothing to configure. Because Thruster runs in the same container as your app, you don’t need a second container in your task definition.

✅ Tip

Created your app with Rails 8? The Dockerfile that rails new generates in Rails 8 and later already starts your app with ./bin/thrust ./bin/rails server and exposes port 80. If you deploy that Dockerfile to ECS and your load balancer sends traffic to port 80, Judoscale may already be receiving queue time. Check that your Gemfile.lock has a recent enough Thruster (0.1.15 or later) and the right platform (see below), then skip ahead to Verify Incoming Metrics. Apps upgraded from earlier Rails versions usually keep their old Dockerfile and don’t run Thruster unless you’ve added it.

How it works

Thruster wraps your app server’s start command. It listens for HTTP traffic on HTTP_PORT (default 80), starts your app server with PORT set to TARGET_PORT (default 3000), and proxies each request to it:

Load balancer  →  Thruster (HTTP_PORT, 80)  →  your app server (TARGET_PORT, 3000)

Thruster records the time a request arrives, before the request waits for a free app server process, so Judoscale sees the full time each request spends in queue.

Install and run Thruster

Thruster is a standalone Go binary that can run any server command, not just Ruby ones. Ruby apps can install it with the thruster gem; other languages add the binary to their Docker image.

Ruby

Add the gem to your app:

bundle add thruster

The gem ships a pre-built binary for each platform, but it only installs the binary when your Gemfile.lock lists the platform your container runs on. Add the platform for your ECS tasks, or Thruster will fail to start:

# Tasks with cpuArchitecture X86_64 (the default)
bundle lock --add-platform x86_64-linux

# Tasks with cpuArchitecture ARM64 (AWS Graviton)
bundle lock --add-platform aarch64-linux

Then prefix the command that starts your web server with thrust. For example, in your Dockerfile:

EXPOSE 80
CMD ["bundle", "exec", "thrust", "bin/rails", "server"]

Or in a Procfile, keeping your app’s own port settings:

web: HTTP_PORT=${PORT:-3000} TARGET_PORT=$((${PORT:-3000} + 1)) bundle exec thrust puma -e ${RACK_ENV:-development}

Python, Node, and Java

Thruster has no pip, npm, or Maven package, so build the binary in a separate stage of your Dockerfile and copy it into your app’s image. Building with CGO_ENABLED=0 produces a static binary that runs on slim and Debian-based images:

FROM golang:1.27 AS thruster
RUN CGO_ENABLED=0 go install github.com/basecamp/thruster/cmd/[email protected]

Then, in your app’s stage, copy the binary in, set TARGET_PORT to the port your app server listens on, and prefix your start command with thrust. Thruster also sets PORT to the value of TARGET_PORT when it starts your app, so apps that read PORT pick up the right port automatically.

Thruster forwards signals to your app server and exits when it does, so it works as your container’s main process.

Python

FROM python:3.13-slim
COPY --from=thruster /go/bin/thrust /usr/local/bin/thrust
# ... app setup ...
ENV HTTP_PORT=80 TARGET_PORT=8000
EXPOSE 80
CMD ["thrust", "gunicorn", "--bind", "0.0.0.0:8000", "myapp.wsgi"]

Node

FROM node:24-slim
COPY --from=thruster /go/bin/thrust /usr/local/bin/thrust
# ... app setup ...
ENV HTTP_PORT=80 TARGET_PORT=3000
EXPOSE 80
CMD ["thrust", "node", "server.js"]

Java

FROM eclipse-temurin:21-jre
COPY --from=thruster /go/bin/thrust /usr/local/bin/thrust
# ... app setup ...
ENV HTTP_PORT=80 TARGET_PORT=8080
EXPOSE 80
CMD ["thrust", "java", "-jar", "app.jar"]

Spring Boot listens on port 8080 by default, which matches TARGET_PORT above. If you’ve changed server.port, use that port instead.

Point your load balancer at Thruster

Thruster can only add the header to requests that pass through it. In your task definition, map the container port Thruster listens on (HTTP_PORT, 80 by default), and make sure your load balancer’s target group sends traffic to that port, not to your app server’s TARGET_PORT. If the load balancer reaches your app server directly, the header is never added.

If your container can’t listen on port 80 (for example, because it runs as a non-root user), set HTTP_PORT to another port, such as 8080, and use that port in your task definition and target group.

🚨 Warning

Thruster changes more than headers. By default it also compresses responses with gzip, caches public responses, handles X-Sendfile, and closes connections where reading the request or writing the response takes longer than 30 seconds. If your app has long-running requests or already handles any of these, review Thruster’s configuration options, such as HTTP_READ_TIMEOUT, HTTP_WRITE_TIMEOUT, and GZIP_COMPRESSION_ENABLED.

Frequently Asked Questions

Should I use Thruster or the NGINX sidecar?

Both add the same header in the same format, so Judoscale treats them the same way. Thruster is simplest for Ruby apps, especially apps that already run it, such as those created with Rails 8’s generated Dockerfile, and it saves you a second container. For Python, Node, and Java apps, Thruster saves the container but adds a Go build stage to your Dockerfile. The NGINX sidecar needs no changes to your app’s image and doesn’t change anything else about your responses, so it’s still a good choice, especially for apps that don’t use Thruster today.

What if a client sends its own X-Request-Start header?

Thruster keeps an X-Request-Start header that’s already on the request, and Amazon’s load balancers pass client headers through. Our NGINX sidecar always overwrites the header instead. In practice, this means a client could send a fake timestamp and make that request’s queue time look much longer than it was. If that’s a concern for your app, use the NGINX sidecar, or strip the header before it reaches Thruster.

Which version of Thruster do I need?

Thruster added the X-Request-Start header in version 0.1.15. Earlier versions proxy requests without it, so Judoscale won’t see queue time. With the Ruby gem, run bundle update thruster to upgrade. With the Dockerfile approach, the version is the one after @ in the go install line.

Verify Incoming Metrics

Once you’ve installed the package, set up Thruster (for web services), and deployed your application, Judoscale will begin showing your queue metrics in the Scaling page charts.

Screenshot: scaling charts in Judoscale

If your web service isn’t receiving traffic, or if your worker service has no jobs waiting in queue, you won’t see any activity in the charts. Let it collect metrics while your app is under load to see queue time information.