talira

connection_pool

Generic connection pooling for Ruby

open sourceMITfree

connection_pool is a generic connection pool for Ruby that shares objects such as Redis, Dalli or other network clients among an application's threads or fibers. with checks out a connection and blocks, up to a timeout, when all are in use; ConnectionPool::Wrapper wraps a single global connection to ease migration; pools can be shut down or reloaded, and reload themselves after a fork.

Problems it solves

  • share a few Redis connections between my Ruby threads
  • limit how many memcached connections my Ruby app opens
  • stop threads fighting over one global client connection

Features

  • pool any client object with a size and timeout
  • with blocks until a connection is free, or raises TimeoutError
  • ConnectionPool::Wrapper for migrating a global connection
  • shutdown and reload, with automatic reload after fork