Skip to main content

Handler Selection Strategies

Handler selection controls how container instances are selected from a handler’s pool when processing a task. This is configured per-handler in handlers.toml.

Available Strategies

Round-Robin (Default)

Cycles through container slots sequentially. Each acquisition starts from the next slot in sequence.
handlers.toml
Best for: Even distribution of load across containers, general workloads.

First-Available

Always starts from slot 0 and takes the first available container.
handlers.toml
Best for: Handlers with warm caches, maximizing reuse of “hot” containers, reducing cold starts.

Random

Starts from a random slot each time.
handlers.toml
Best for: Very high concurrency scenarios where lock contention might be a concern.

Configuration

Handler selection is configured in handlers.toml for each handler:
handlers.toml

Performance Notes

Testing showed that round-robin provides the best overall performance for most workloads. The blocking lock creates natural backpressure - workers queue at slots rather than spinning, which improves throughput under load.

Comparison

Mixing Strategies

You can use different strategies for different handlers based on their characteristics:
handlers.toml