none
Which of these async IO models is "best"? RRS feed

  • Question

  • I have a server - coded in C# - that relies wholly on async socket IO (e.g. Socket.BeginReceive), the server works well.

    The 'model' used however is such that when it recieves a msg the recv handler is running an IOCP thread and will hold that thread for the duration of the message processing, which can be a heavily CPU intense operation sometimes.

    I have modified the server very slightly however so that when the recv handler runs it does not process the msg itself, but instead queus a work item to the app domains thread pool, it then returns; this too runs fine and the server appears - semantically - the same.

    The 'heavy' msg processing now runs always in a worker thread rather than an IOCP thread.

    My perception was that IOCP threads are best for IO and should ideally not be burdened with a lot of work - worker threads being best.

    However I can find no definitive recommendation about these two approaches.

    Does anyone have comments?

    Thx

    Cap'n

     



    Thursday, January 12, 2012 4:11 PM

Answers

  • It's best to leave the IO threads waiting for incoming I/O.

    • Proposed as answer by Paul Zhou Monday, January 23, 2012 8:24 AM
    • Marked as answer by Paul Zhou Tuesday, February 7, 2012 6:12 AM
    Thursday, January 12, 2012 6:12 PM