Library tutorials & articles
Business logic processing in a socket server
- Introduction
- A business logic thread pool
- Doing the Work
- Conclusion
Introduction
Overview
In the previous article we designed a reusable socket server class to make writing high performance socket based servers easy. We presented a series of simple examples, from the humble echo server through to some slightly more real-world packet echo server and a fake POP3 server. This article continues to make the example server more usable in the real-world by adding a business logic thread pool to the server so that messages are processed by a thread that isn't part of the IO thread pool. This helps to maintain the scalability and performance of the server by moving potentially blocking work off into its own thread pool.
Why do we need another thread pool
To be able to handle variable load it's often useful to have a thread pool that can be expanded and contracted depending on the current load on the server. As we pointed out in the last article, all of our asynchronous socket IO is handled by the socket server's thread pool. The threads in this pool cannot be terminated whilst they have outstanding IO operations or the operations will be terminated. This means that the socket server's thread pool cannot shrink without us keeping track of the IO operations associated with a particular worker thread and only allowing the thread to terminate when all IO operations have completed. To maintain performance we need to make sure that the threads in the socket server's thread pool do not block, there are a finite number of them and if they all block then no socket IO will occur until they unblock. The easiest way to ensure that the IO threads don't block is to move the business logic processing out of the IO thread pool and into a new thread pool. The IO threads then simply handle the IO, chunk the data stream into messages and pass the messages off to the business logic thread pool.
Related articles
Related discussion
-
job vacancy .Net Programmers - ( C# || C++ ) (5 full-time positions)
by tajulz (0 replies)
-
How to store C++ object pointers in Core foundation's ordered collections like CFMutableArrayRef, CFMutableDictionaryRef.
by elizas (0 replies)
-
Binary Studio | software development outsourcing Ukraine
by Soft Industry (5 replies)
-
searhing numeric data in urdu text file.
by adilsajjad (0 replies)
-
Programming MS Visual C++, David J. Kruglinski - missing files needed
by andwan0 (0 replies)
Related podcasts
-
Listener Feedback 67
This mailbag episode includes FASM, scripts, sockets, SSL/TLS, HTTPS, Windows 7's XP mode, and more. Security Now wiki shownotes For 16kpbs versions, transcripts, and notes (including fixes), visit Steve's site: grc.com, also the home of the best disk maintenance and recovery utility ever written...
This thread is for discussions of Business logic processing in a socket server.