A question about connection pooling, and the many ways to connect.

Sebastian Tennant sebyte at smolny.plus.com
Tue Nov 12 10:43:25 UTC 2013


Hello Marijn,

Quoth Marijn Haverbeke <marijnh at gmail.com>:
> You're right, you have to use local connection and specify that you
> want them to be pooled. (This model has much less overhead -- a single
> synchronization point -- than a  model where a single handle can be
> used in a multi-threaded way.)

This touches on something I've wanted to clarify for some time, namely, best
practise for connecting to a database when using Postmodern in web application
code.

 1. Don't use a single, permanent connection, established at web server start
    time.  This may work fine in development but will soon stall in production.
    Rather, wrap database operations in WITH-CONNECTION forms and always use
    pooled connections.

 2. Avoid multiple WITH-CONNECTION forms (nested or otherwise) within the code
    handling a single HTTP request.

 3. Leave *MAX-POOL-SIZE* bound to NIL (unlimited) at least to begin with.  The
    number of pooled connections only grows when a new connection is needed and
    all others are busy.  The size of the pool will therefore reflect the
    latest peak in web server traffic.

Any and all corrections, clarifications or refinements to my thinking very much
appreciated.

Sebastian
-- 
Emacs' AlsaPlayer - Music Without Jolts
Lightweight, full-featured and mindful of your idyllic happiness.
http://home.gna.org/eap




More information about the postmodern-devel mailing list