Skip to main content

Crate poolsim_core

Crate poolsim_core 

Source
Expand description

§poolsim-core

poolsim-core is the Rust library crate for connection-pool sizing.

It is the simulation and analysis engine behind the poolsim workspace.

§Scope

The current release focuses on sizing calculation, not runtime pool enforcement.

It provides:

  • workload and pool validation
  • latency distribution fitting
  • Erlang-C helpers
  • Monte Carlo queue simulation
  • pool-size optimization
  • sensitivity analysis
  • step-load analysis

§Install

[dependencies]
poolsim-core = "0.1.0"

§Primary APIs

Use the crate-root APIs for the most common workflows:

  • simulate: full recommendation workflow
  • evaluate: score a fixed pool size
  • sweep: generate sensitivity rows with default options
  • sweep_with_options: generate sensitivity rows with explicit options

Important public modules:

  • poolsim_core::types
  • poolsim_core::distribution
  • poolsim_core::erlang
  • poolsim_core::monte_carlo
  • poolsim_core::optimizer
  • poolsim_core::sensitivity
  • poolsim_core::error

§Example

use poolsim_core::{
    simulate,
    types::{PoolConfig, SimulationOptions, WorkloadConfig},
};

let workload = WorkloadConfig {
    requests_per_second: 220.0,
    latency_p50_ms: 8.0,
    latency_p95_ms: 32.0,
    latency_p99_ms: 85.0,
    raw_samples_ms: None,
    step_load_profile: None,
};

let pool = PoolConfig {
    max_server_connections: 120,
    connection_overhead_ms: 2.0,
    idle_timeout_ms: None,
    min_pool_size: 3,
    max_pool_size: 24,
};

let report = simulate(&workload, &pool, &SimulationOptions::default()).unwrap();
assert!(report.optimal_pool_size >= 3);

§Output

The main simulation output includes:

  • recommended pool size
  • confidence interval
  • cold-start minimum pool size
  • utilisation ratio
  • queue-wait metrics
  • sensitivity rows
  • optional step-load analysis
  • warnings

§See Also

§Notes

  • For CLI usage, see the poolsim-cli crate.
  • For HTTP and WebSocket usage, see the poolsim-web crate.

Re-exports§

pub use types::DistributionModel;
pub use types::QueueModel;
pub use types::RiskLevel;

Modules§

distribution
Distribution fitting and sampling utilities. Distribution fitting and sampling for workload latency inputs.
erlang
Erlang-C queueing formulas. Erlang-C queueing helpers used by sizing and sensitivity calculations.
error
Error type and helpers. Error types and helpers for the public poolsim-core API.
monte_carlo
Monte Carlo queue simulation engine. Monte Carlo queue simulation primitives.
optimizer
Pool-size optimization routines. Pool-size optimization routines.
sensitivity
Sensitivity analysis routines. Sensitivity analysis across a configured pool-size range.
types
Public input/output data models. Public data models used by poolsim-core.

Constants§

MIN_FULL_SIMULATION_ITERATIONS
Minimum iteration floor used by full simulation for stable estimates.
PERFORMANCE_CONTRACT_WARNING
Performance warning text emitted by benchmark/helpers when threshold is exceeded.

Functions§

emit_performance_contract_warning
Emits the performance contract warning when elapsed time exceeds threshold.
evaluate
Evaluates a fixed pool size against the workload/options.
simulate
Runs full pool-size optimization and returns a simulation report.
sweep
Generates a sensitivity table using default simulation options.
sweep_with_options
Generates a sensitivity table using explicit simulation options.