Advice / best practice - thread connection pools / mutexes

Piotr Honik piotr.honik at
Tue Apr 27 20:14:54 UTC 2010

Why don't you consider implementing a full manager-worker model?
Tracking multiple mutexes and conditional waiting when you hit 100+ 
threads isn't going to give you good performance.
I would be looking at a separate thread doing one thing only - 
performing database queries on behalf of worker threads.

This approach has several advantages:
  - the size of  the 'pool' controlled easily
  - mutexes locked only by one thread
  - worker threads don't care about db connection, they only talk to the 
  - good starting point to develop a complete round-robin solution with 
several db servers


More information about the freebsd-threads mailing list