Performance, Scaling Puppet Server, Compilers and Tuning for Large Fleets

Puppet Training Course 22 min min read Updated: Nov 17, 2026 Advanced
Performance, Scaling Puppet Server, Compilers and Tuning for Large Fleets
Advanced Topic 2 of 3

How Puppet Server Uses Resources

text Agent request (catalog) ─► Puppet Server (JVM) └─ JRuby instance pool (each instance compiles ONE catalog at a time) uses CPU + memory (roughly 512 MB to 1 GB each, depending on your code) ─► PuppetDB (facts, catalog, report storage) ─► PostgreSQL
ResourceWhy it matters
CPU coresOne compile uses one core. More cores allow more parallel compiles
Memory (JVM heap)Each JRuby instance needs memory. Too little causes slow garbage collection or crashes
Disk and I/OReading code, writing reports and PuppetDB data
NetworkFile serving for source => files, many agents polling

Rules of Thumb for Sizing

Measure your own code: Sizing depends strongly on your catalogs (size, Hiera depth, number of resources, custom functions). The numbers below are starting points. Measure the compile time and memory on your system and adjust. Vendor sizing guides give current recommendations.
Fleet sizeTypical starting point
Up to ~500 nodesOne server: 4 to 8 cores, 8 to 16 GB RAM (PuppetDB and PostgreSQL on the same host or separate)
~500 to 2,500 nodesLarger single server, or server plus PuppetDB on a separate host, tuned JRuby pool
2,500 to 10,000+ nodesPrimary server plus several compilers behind a load balancer, separate PuppetDB and PostgreSQL

A quick estimate of how many agents one JRuby instance can serve:

text agents per instance β‰ˆ run interval (seconds) / average compile time (seconds) Example: run interval 30 min = 1800 s, average compile = 6 s one JRuby instance serves β‰ˆ 1800 / 6 = 300 agents with 4 instances β‰ˆ 1200 agents (add headroom: assume 50% of this in practice)

Tune Puppet Server

bash # /etc/default/puppetserver (Debian) or /etc/sysconfig/puppetserver (RHEL) JAVA_ARGS="-Xms4g -Xmx4g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger" # Set Xms equal to Xmx. Leave memory for the OS and PuppetDB if on the same host.
text # /etc/puppetlabs/puppetserver/conf.d/puppetserver.conf jruby-puppet: { max-active-instances: 4 # normally number of cores - 1, but limited by memory max-requests-per-instance: 100000 # recycle JRuby to limit memory growth (0 = never) environment-class-cache-enabled: true }
SettingMeaning
-XmxMaximum heap. Roughly (max-active-instances x 512 MB to 1 GB) + 1 GB extra
max-active-instancesNumber of compile workers. Too high: memory pressure. Too low: queue
max-requests-per-instanceRecycle workers after N requests, to prevent leaks from old gems
environment-class-cache-enabledFaster class lookups, useful with Code Manager and PE

Spread the Load: Run Interval and Splay

ini # puppet.conf on agents (managed by Puppet or your base profile) [agent] runinterval = 30m splay = true splaylimit = 30m

Without splay, thousands of nodes (for example, after a mass reboot) request catalogs at the same minute, creating a spike. With splay, every agent adds a random delay once and then keeps its own schedule. For long-running fleets, you can also use cron or a systemd timer with a random delay instead of a long-lived daemon.

Compilers and Load Balancer

text β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” agents ───────►│ Load balancer β”‚ (TCP 8140, round robin, health check /status/v1/simple) β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”‚Compiler1β”‚ β”‚Compiler2β”‚ β”‚Compiler3β”‚ (Puppet Server, compile only) β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Primary │───────►│ PuppetDB │──► PostgreSQL β”‚ (CA, code) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • The primary server holds the CA and is the source of code. Compilers only compile catalogs and serve files
  • Code is deployed to all compilers (Code Manager does this, or r10k on each)
  • Agents talk to the load balancer name. Certificates must include that name in dns_alt_names on the compilers
  • Use health checks against /status/v1/simple
  • Certificate signing goes to the primary. Many setups send CA traffic by a separate rule or by ca_server
ini # Agent [main] server = puppet-lb.example.com # load balancer ca_server = puppet-ca.example.com # the primary does certificates # Compiler certificate must contain: puppet-lb.example.com

Make Catalogs Cheaper

Cause of slow or heavy catalogsWhat to do
Huge file trees with recurse => truePackage the files, or use an archive, or recurse => remote carefully
Many tiny resources made in loopsMove bulk data into a template or one file
Big facts (large hashes)Block unused facts, trim custom facts
Very deep Hiera with many files and deep mergesShorten hierarchy, avoid huge merges
Custom Ruby functions that call the networkCache, or run on the agent (Deferred)
Complex inline_template and generate()Replace with EPP and data
Source files via Puppet ServerUse a package repository, or a file mirror, instead of source => puppet:///

Environment Caching

Compile speed improves a lot when code is cached. Use environment_timeout = unlimited and refresh the cache when you deploy code (r10k or Code Manager do it). Frequent changes with environment_timeout = 0 read files on every request and are slow.

PuppetDB and PostgreSQL

  • Give PuppetDB its own memory (-Xmx in /etc/default/puppetdb), a starting point is 1 GB per ~1,000 nodes, adjusted by measuring
  • Run PostgreSQL on SSD storage, tune shared_buffers (25% of RAM) and work_mem
  • Set node-ttl and report-ttl so old data is removed (report-ttl = 14d is common)
  • Watch the command queue: a growing queue means PuppetDB cannot keep up
  • Vacuum and monitor database size. Archive old reports if you need long retention
  • Consider a PostgreSQL replica or managed service for production
ini # /etc/puppetlabs/puppetdb/conf.d/database.ini [database] node-ttl = 7d node-purge-ttl = 14d report-ttl = 14d gc-interval = 60

Measure Before Tuning

bash # Catalog compile time per node (from the report) curl -s -G http://localhost:8080/pdb/query/v4/reports --data-urlencode \ 'query=reports[certname, metrics] { latest_report? = true }' | jq '.[0]' # Server metrics (status API) curl -sk https://localhost:8140/status/v1/services/pe-jruby-metrics?level=debug | jq . # PE and some builds curl -sk https://localhost:8140/status/v1/services?level=info | jq 'keys' # Check the JRuby pool and heap in the log for "free-jrubies" and GC pauses sudo grep -i 'jruby\|OutOfMemory' /var/log/puppetlabs/puppetserver/puppetserver.log | tail

The module puppetlabs-puppet_metrics_dashboard installs Grafana dashboards for Puppet Server and PuppetDB. Look at JRuby borrow time, queue length, average compile time and heap usage. If JRuby instances are all busy and requests wait, add instances (if you have memory) or compilers.

Troubleshooting Symptoms

SymptomLikely causeAction
Agents time out or get HTTP 503No free JRuby instancesMore instances/compilers, more splay, tune code
java.lang.OutOfMemoryErrorHeap too small for pool sizeIncrease -Xmx or reduce instances
Spikes every 30 minutes at the same timeNo splay, or time sync cronEnable splay, spread schedules
Slow only on first run after deployEnvironment cache emptyWarm up or accept, avoid frequent flushes
PuppetDB queue growsDatabase too slow or PuppetDB heap smallMore memory/IO, reduce report size, tune PostgreSQL
Disk fills upReports and logsSet TTLs, rotate logs, remove old environments

Practice Tasks

  1. Measure compile time for five nodes with puppet catalog compile and compute agents per instance
  2. Set splay on lab agents and plot request times from the server log
  3. Change max-active-instances and observe memory use
  4. Draw a diagram with a load balancer and two compilers for 3,000 nodes
  5. Set PuppetDB TTLs and verify old reports are removed

Conclusion

Puppet Server performance is mostly CPU and memory per compile. Measure compile time, set JRuby instances and heap together, use splay, cache environments, simplify heavy catalogs and add compilers behind a load balancer as the fleet grows.

Quick Summary: agents per JRuby β‰ˆ interval / compile time; heap vs instances; splay; compilers + LB; PuppetDB TTLs and PostgreSQL tuning.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators