Synchronous Vs asynchronous server connection
-
Hi all, I need to build a server with threading pool to handling client request. Is it better to have ayschronous server connection rather than synchronous connection, so that the server can have better response or performance ? Is asynchronous server connection hard to program ? Thank you
-
Hi all, I need to build a server with threading pool to handling client request. Is it better to have ayschronous server connection rather than synchronous connection, so that the server can have better response or performance ? Is asynchronous server connection hard to program ? Thank you
Doh, synchronous perfoms better, but asynchronous offers much better scalability. Then, it depends on what you want - if you have only one client, then synchronous will be the choice, if the number of clients is unknowns or more than 2-3, async is the choice. Async is much harder to code, because humans usually don't think async.
-
Doh, synchronous perfoms better, but asynchronous offers much better scalability. Then, it depends on what you want - if you have only one client, then synchronous will be the choice, if the number of clients is unknowns or more than 2-3, async is the choice. Async is much harder to code, because humans usually don't think async.
-
Thanks ! But why 2-3 clients is the boundary ? And are there any reference for programming async server ?
Well, it's not exactly 2-3, it's just the range, where it can be acceptable and because if you have 4 clients, you usually have 5 next day, then 6 and after month you'll find yourself having trouble with 100... Problem with synchronous access, is that it needs generally one thread per client behavior and then they became a resource hog, because a lot of time is spent by creating/destructing these threads and by switching between them. Ideal ratio is one thread per one cpu, although this is of course unrealistic, but more threads means more work in the OS, hence less cpu time for application. look here, at the section internet&networks on codeproject for more details and even tutorials: http://www.codeproject.com/internet/[^]
-
Hi all, I need to build a server with threading pool to handling client request. Is it better to have ayschronous server connection rather than synchronous connection, so that the server can have better response or performance ? Is asynchronous server connection hard to program ? Thank you
Really good question... Geo states right one regarding one client and multiple client request. I would recommend asynchoronous if you have multiple clients.. But Now you have to think about the right choices of choosing a thread option. Option 1: 1. You can handle multiple client request in one thread!!! by using windows socket overlapped, or messaging socket communication technologies. Microsoft provides better support to work with one thread but multiple socket connection. I think you can handle maximum of 64 client connections in one thread.. (I may be wrong). But to be careful, this choice won't always good to any solution.. You have to workout whether this technique is suitable for you or not. 2. If you opt for single thread per connection, this seems to be good, but this will screw your application, system performance. Suppose say, your server handles 1000 request at a time, you have to create 1000 threads to handle this.. :(. But still you have choice.. You can use thread pooling, instead of creating a thread each time, you can use existing thread one the connected client disconnected.. Again this is painful approach, but this would increase performance of the system.. 3. Mix of option one and Two. Having thread pool + one thread will handle multple sockets This is really very good to discuss, I would appreciate if you guys add more points to this topic... " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan