I have a server that receives hundreds of asynchronous connections and needs to implement MySQL access to different threads. Actually, as I use the Async Socket Begin / End standard of .Net, there is a thread pool, so it is not 1 thread for each connection and even if it were, it would not create 1 MySQL connection for each thread, this would only be valid if 10 connections, with 1 MySQL connection for each socket connected.
How do I implement this? Could you suggest some links for study? I need to use some "designe pattern" where I have a thread-safe pool of MySQL connections, in which it keeps x active connections and releases as the need of the requests? Something like:
Connection myConnection = GetSomeConnection(); // Returns a shared object
Command cmd;
lock(myConnection)
{
cmd = myConnection.CreateCommand();
}