arbiter-core-0.1.0.0: Core types and logic for PostgreSQL-backed job queue
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.PoolConfig

Description

Connection pool configuration.

Synopsis

Documentation

data PoolConfig Source #

Connection pool configuration.

Constructors

PoolConfig 

Fields

  • poolSize :: Int

    Maximum connections

  • poolIdleTimeout :: Int

    Idle timeout (seconds)

  • poolStripes :: Maybe Int

    Number of stripes (sub-pools). Reduces lock contention on connection checkout.

    • Nothing: Auto-detect based on CPU count
    • Just n: Use n stripes

Instances

Instances details
Show PoolConfig Source # 
Instance details

Defined in Arbiter.Core.PoolConfig

Eq PoolConfig Source # 
Instance details

Defined in Arbiter.Core.PoolConfig

defaultPoolConfig :: PoolConfig Source #

10 connections, 300s idle timeout, 1 stripe. For workers, use poolConfigForWorkers.

poolConfigForWorkers :: Int -> PoolConfig Source #

Pool sized for a worker pool of workerCnt threads.

Returns a single-stripe pool with 2 * workerCnt connections (floor of 2).

A single stripe is intentional. Data.Pool.withResource pins each thread to one stripe based on its capability and does not search other stripes when its own is exhausted. With multiple stripes, threads from the same worker pool can cluster on one stripe and starve it of free connections even when other stripes are idle.