Threads
-
Im now starting to think of developing a big chat system which will need to handle up to 1000 clients connected at once. my question is how it would of be the best way to handle all of the 1000 clients?? a thread for each client isnt too much ?
You're right, creating a thread for each client won't scale. The best way to go about this is to use a threadpool. There is the System.Threading.ThreadPool[^] class provided by the .NET Framework. If you don't find it sufficient for your needs, there are also custom implementations of managed threadpools, a simple search in CP for "ThreadPool" should give you plenty of results. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
You're right, creating a thread for each client won't scale. The best way to go about this is to use a threadpool. There is the System.Threading.ThreadPool[^] class provided by the .NET Framework. If you don't find it sufficient for your needs, there are also custom implementations of managed threadpools, a simple search in CP for "ThreadPool" should give you plenty of results. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Isnt thread pool can proccess only 25 threads at a time? (max) and 1000 active socket will create me a bottle neck
That limit is per processor, so if you have a dual processor machine, then it's 50 threads. If you want more threads than that, then it defeats the very purpose of having the threadpool. The basic assumption behind using a threadpool is you can distribute the work among a few precreated threads, so you have never have one thread idle and another doing all the work. You can have a look here[^] if you want a custom implementation of Threadpools. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
That limit is per processor, so if you have a dual processor machine, then it's 50 threads. If you want more threads than that, then it defeats the very purpose of having the threadpool. The basic assumption behind using a threadpool is you can distribute the work among a few precreated threads, so you have never have one thread idle and another doing all the work. You can have a look here[^] if you want a custom implementation of Threadpools. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Im now starting to think of developing a big chat system which will need to handle up to 1000 clients connected at once. my question is how it would of be the best way to handle all of the 1000 clients?? a thread for each client isnt too much ?
I did something like this using remoting, delegates and events. It was pretty easy. I would avoid the mutithread, because it can become complex and it will slow you proformance with that many threads open.
-
If i understand right threadpool are good for threads which dont do much work and alot of time under wait state isnt it the exact opposite of my problem? alot of active sockets ?
Again, what you say is true for the system provided threadpool thread. I'm saying this for the umpteenth time, you can always find custom implementations of it on the web. Regards Senthil _____________________________ My Blog | My Articles | WinMacro