CPU use when Threads = 1 (wodWebServer / wodWebServer.NET)
Hi,
I'm using the DLL version of the WOD WebServer control as a COM control. It's working well, but my environment (VFP 9) seems to only support threading with the Threads value set to 1, where each client is on its own thread, but still coordinated by the main thread. It was fine, but I am noticing that the more clients that connect, the higher my CPU use is. Some of this is to be expected, but I need to find out a way to minimize this effect. Right now I have about 30 clients attached and my CPU use, on a 3 core 2.2 Ghz machine, is around 6-8%. I'm afraid that want scale as well as I will need it to.
In this application, my clients are connecting in a long polling scenario, where the server keeps the connection open for 45 minutes waiting to see if there are any external events that would require responding to the client. If there are events, it responds, disconnects the client, and the client immediately reconnects. It there aren't any events within 45 minutes, the server disconnects the client and the client immediately reconnects.
I think each thread must have a timed process that checks to see if it needs to respond. If I'm correct in that assumption, I would like to know if there is any way that I could increase the interval of that internal timer and thereby reduce the CPU impact of each thread.
Thanks for your advice,
-Matt
CPU use when Threads = 1
Hi Matt.
We don't have any timers (except for checking timeouts) so there's nothing to tweak in threads. We only respond to windows messages for each thread.
Why do you say you're unable to set Threads = 0? Why that fails?
Jasmine.
CPU use when Threads = 1
Hi Jasmine,
Yes, setting Threads=0 works with VFP, but as I understand it, that turns off threading all together. Wouldn't that block processing (for other clients) if one client connected and was not responded to for a long time? Setting Threads to 2 in this environment definitely does not work. Clients connected but are not responded to.
Thanks,
-Matt
CPU use when Threads = 1
HI Matt.
It will not block, since sockets work in async way. THey do the job when they have some traffic, and then they're idle waiting for new jobs.
You should try it out to see which one behaves better for you.
Jasmine.
CPU use when Threads = 1
Ok, thanks for clearing that up. I have tried it with Threads = 0 and it does seem to work fine. In this particular case, because there is minimal processing being done for each client, this may be a better option. Looking at the CPU impact of changing from using threads to not using them was minimal though, perhaps only a 1% difference over 30 connected clients. With that said, your explanation still helps, as I can rule out the problem being a timer issue in the threads.
Thanks for you help,
-Matt