x
Skip to main content

Performance Optimization & Sizing

PDF processing is memory-intensive - a single large PDF can expand to many times its file size in memory during processing. This guide helps you size your deployment correctly.


How Stirling PDF Uses Memory

Stirling PDF loads PDFs into memory using a tiered strategy based on file size:

File SizeStrategyMemory Impact
Up to 10 MBLoaded entirely into memoryFast, but consumes memory proportional to file size
10 MB to 50 MBPartially in memory, remainder stored on diskModerate memory usage with disk spillover
Over 50 MBFully stored on disk during processingMinimal memory usage, but requires adequate disk space

The application also monitors memory pressure. If available memory drops too low, all operations are forced into disk-backed mode regardless of file size.

Memory-Intensive Operations

A 50 MB PDF with complex vector graphics, embedded fonts, and many pages can expand to 200-500 MB in memory during processing. Operations that render pages (such as PDF-to-image conversion) and OCR are particularly memory-intensive. Plan for several times the maximum expected file size per concurrent operation.


Resource Recommendations

Recommended specifications:

  • CPU: 2 cores (4+ recommended)
  • RAM: 4 GB
  • Disk: 10 GB free space

Docker Compose:

services:
stirling-pdf:
image: docker.stirlingpdf.com/stirlingtools/stirling-pdf:latest
deploy:
resources:
limits:
memory: 4G
cpus: '2.0'

Fine Tuning

For most deployments, Stirling PDF's defaults work well and no manual tuning is needed. If you are experiencing performance issues with large files or high concurrency, you can adjust the memory allocated to the application using the JAVA_TOOL_OPTIONS environment variable:

services:
stirling-pdf:
environment:
JAVA_TOOL_OPTIONS: "-Xms512m -Xmx4g"

-Xms sets the initial memory allocation and -Xmx sets the maximum. If running in Docker or Kubernetes with memory limits, set the container limit to at least 1.5x the -Xmx value to leave room for background processes like LibreOffice and Tesseract.


Resource-Intensive Operations

Some operations require significantly more resources than others. If your organization primarily uses specific tools, you should size your deployment based on the most resource-heavy operations your users will perform.

OperationCPU ImpactMemory ImpactNotes
Merge / SplitLowProportional to total file sizesLightweight file operations
OCR (Tesseract)Very HighHighCPU-bound image analysis
File Conversion (LibreOffice)HighHighSingle-threaded per instance
PDF-to-ImageModerateVery HighPage rendering expands memory significantly
PDF/A ConversionModerateHighFont embedding and color profiles
CompressionModerateHighRewriting internal PDF structures

For example, if your team primarily uses OCR and document conversion, you will need significantly more resources than a team that mainly merges and splits PDFs. Adjust your Process Limits and resource allocation accordingly.