Class PoolOptions
- Namespace
- CobaltPdf
- Assembly
- CobaltPdf.dll
Configuration options for the CobaltPdf browser pool.
public class PoolOptions
- Inheritance
-
PoolOptions
- Inherited Members
Remarks
Pass an instance of this class to Configure(Action<PoolOptions>) at application startup. For common deployment targets, use the presets in CloudEnvironment rather than setting flags manually:
// Docker / Linux container
CobaltEngine.Configure(CloudEnvironment.ConfigureForDocker);
// Azure Functions Premium Plan
CobaltEngine.Configure(CloudEnvironment.ConfigureForAzure);
// Custom override on top of a preset
CobaltEngine.Configure(o =>
{
CloudEnvironment.ConfigureForDocker(o);
o.MaxSize = 4;
});
Properties
BrowserLeaseTimeout
The maximum time a caller will wait for a free browser lease before a TimeoutException is thrown.
public TimeSpan BrowserLeaseTimeout { get; set; }
Property Value
- TimeSpan
Default:
30 seconds
Remarks
This timeout is combined (via a linked CancellationTokenSource) with any CancellationToken passed to the render method, so whichever fires first wins.
ExtraArgs
Raw Chromium command-line flags appended to every browser launch.
public List<string> ExtraArgs { get; set; }
Property Value
Remarks
On Linux the following flags are added automatically as safe defaults:
--no-sandbox, --disable-gpu, and --disable-dev-shm-usage.
You do not need to add them manually. The CloudEnvironment
presets will skip duplicates if you apply one on top of the defaults.
Common flags:
| Flag | When to use |
|---|---|
--no-sandbox | Always required on Linux (added automatically) |
--disable-dev-shm-usage | Docker / limited /dev/shm (added automatically on Linux) |
--disable-gpu | Headless servers without a GPU (added automatically on Linux) |
--single-process | Memory-constrained environments (Azure App Service, AWS Lambda) |
--proxy-server=host:port | Route Chromium traffic through a proxy |
--ignore-certificate-errors | Self-signed certs during development |
MaxSize
The maximum number of concurrent browser instances allowed in the pool.
public int MaxSize { get; set; }
Property Value
- int
Default:
5. Recommended cloud value:Math.Max(1, Environment.ProcessorCount / 2).
Remarks
Render requests that arrive when all leases are taken will wait up to BrowserLeaseTimeout before throwing a TimeoutException. Must be ≥ 1.
MaxUsesPerBrowser
The maximum number of render operations a single browser instance will serve before it is recycled (closed and replaced with a fresh instance).
public int MaxUsesPerBrowser { get; set; }
Property Value
- int
Default:
100
Remarks
Recycling prevents gradual memory growth from long-running browser processes. Lower this value if you observe increasing memory usage over time. Must be ≥ 1.
MinSize
The minimum number of browser instances to keep warm in the pool at all times.
public int MinSize { get; set; }
Property Value
- int
Default:
1
Remarks
Set to 0 for lazy initialisation (browsers started on first request).
Set to 1 or higher to eliminate cold-start latency on the first render.
Must be ≥ 0 and ≤ MaxSize.