On Nov 29, 2007, at 06:10, Wilfried Mestdagh wrote: > Hello DZ-Jay, > > So conclusion is that increasing the backlog does: > - decrease the performance for accepting connections > - decrease the overall performance of the application
This seems to be the conclusion of mine and Huby's tests. > Also: > - connecting clients should have a range of retry's when refused, > eventually with a random small delay. Agreed. > For your application: > Seems you have a lot of processing to do. While your code is executing > no incoming socket can be accepting. Then maybe execute a certain block > (the most time consuming one) in a separate thread ? You can exchange > data between threads the most easy is by posting a message where a > pointer to the data is in WParam argument. The pointer can be freed in > the custom message handler. I will consider this. Thank you, Wilfried. However, the queue manager (listening) thread does not have a single large block of long-executing code, but very small blocks that each do a little work, which may be affecting performance: 1. It runs TWSocketServer, so it has to process all incoming connections and client communications. 2. For each client, it parses the incoming requests from the client to determine what needs to be done, and which state they are in. The request is a string in "CMD:VALUE" fomat. 3. If it's message data, it writes to the filesystem. 4. When done successfuly, it logs to the database. 5. When a message posted by the dispatcher thread announces that a message has been dispatched, the manager thread needs to log this to the database. And all throughout it is writing to a log file (at least while debugging), which needs to be synchronized among all threads. I will try to do some analysis to determine which portions are the bottleneck and see if they could be offset to a separate thread. I do not mind too much right now if the server runs a little slow; we can always re-factor it and optimize it in the future. But what I would like to avoid is rejecting connections too often because of a full backlog (which seems to be happening right now). Perhaps I should run the TWSocketServer on its own thread, and post messages from the clients to the queue manager thread to do the work? Although this seems too complex and expensive. It almost looks like each client should run on its own thread... :( dZ. -- DZ-Jay [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be