Configuration
Configure the PDFSamurai Docker Server using environment variables passed to docker run.
Environment variables
| Variable | Default | Description |
|---|---|---|
PORT | 3000 | Server port |
WORKERS | 1 | Number of worker threads for PDF generation |
MAX_QUEUE_SIZE | 100 | Maximum queued requests before the server returns 503 |
TASK_TIMEOUT | 60000 | PDF generation timeout in milliseconds |
Example
docker run -p 3000:3000 \
-e WORKERS=4 \
-e MAX_QUEUE_SIZE=200 \
-e TASK_TIMEOUT=30000 \
pdfsamurai/server
Scaling workers
By default, the server runs with a single worker. This is the safest option and works on any machine. If you need higher throughput, increase the number of workers based on your setup.
Dedicated server
Use all CPUs minus one (reserves a CPU for the main thread):
docker run -p 3000:3000 \
-e WORKERS=$(( $(nproc) - 1 )) \
pdfsamurai/server
Shared server
Use half the CPUs to leave resources for other services:
docker run -p 3000:3000 \
-e WORKERS=$(( $(nproc) / 2 )) \
pdfsamurai/server
Fixed value
Set a specific number of workers:
docker run -p 3000:3000 \
-e WORKERS=4 \
pdfsamurai/server
Memory considerations
Each worker starts with approximately 64 MB of memory and can grow up to 2 GB depending on template complexity. Make sure you have enough RAM for the number of workers you configure.
More workers than available CPU cores will not improve throughput and may slow down individual PDF generation.