Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

XmlTextReader and async sockets? How to combine?

Back to Forum: Tech Off
  • User profile image
    Tom Servo

    I'm soon about to continue working on my Jabber client. I always had planned for the Jabber library itself to be able to run a server, too.

    Now recently, out of the blue for no reason, I figured out some performance issues. If I want my server to be scalable and not gobbling up memory and CPU cycles, I'd have to ditch the connection thread model.

    Trying to think up an easy way to implement async sockets in combination with the XML stuff just blows my mind. The current way at hand, soon to be experimented with, is a really huge state machine, that allows me to pause and switch processing to other connections at any point in the XML stream.

    However would it be tons easier if .NET would support its own version fibers, where I'd just switch fiber whenever I please (as in, no data available or message processed).

    I do want to solicit suggestions from others, though, stopping me from some huge stupidity that'll cause endless wasted hours.

  • User profile image
    Sven Groot

    What's wrong with threads and thread pooling?

  • User profile image
    Tom Servo

    I'm not so hot on the idea of having a thread per connection. And having like 300 threads for 300 connections isn't exactly great.

    A state machine or something similar would work, too, but things would get an awful lot of overhead, because I'd need to be able to bail out and switch the processing to another connection at any time if there's no data available.

    Regarding the ThreadPool: The XmlTextReader just blocks when there's no data available, so I'm not sure on how a ThreadPool would help. Especially each thread would be parsing data on a permanent connection, not handling seperate requests like a webserver. What happens if I suspend a thread that's in a ThreadPool? Will it be dropped out of the scheduling queue until I unsuspend it?

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.