0
I have a server that receives hundreds of asynchronous connections and I need to implement Mysql access from different threads. In fact, how I use the Async Socket Begin/End standard. Net, there is a thread pool, so it is not 1 thread for each connection and even if it was, would not create 1 Mysql connection for each threads, this would only be valid if there were at most 10 connections, being 1 Mysql connection for each connected socket.
How do I implement this? Could you suggest some study links? Do I need to use a "designe Pattern" where I have a thread-safe Mysql connection pool, where I keep x connections active and release as required? Something like:
Connection myConnection = GetSomeConnection(); // Returns a shared object
Command cmd;
lock(myConnection)
{
cmd = myConnection.CreateCommand();
}
It would not be the case to implement a Singleton in the role of Broker - managing a request queue, for example? This is a commonly used model for controlling requests for unique and shared resources.
– OnoSendai