I recently found that WSASend and send takes a lot of CPU power.
These are the conditions what I've tested with my application:
200 concurrent clients connecting to server
one TCP and UDP socket endpoint between a client and server
server app runs on Windows 2000 Server + P-450, 256MB RAM.
clients sends 1 TCP messages and 4 UDP messages to server and receives 10
TCP messages and 40 UDP messages from server as reply.
server app does nothing except for receiving messages from client and sends
it to 5% of connected clients.
The server receives messages in overlapped I/O manner with Completion Port,
and sends messages in traditional blocked send with winsock-internal send
buffer.
The results are:
server consumes about 60% of its CPU work!!
It may seem to be a serious cost, considering I'd expected about 2000
simultaneous clients easily. However, when I let the server app reply the
messages to only one client rather than 5% of everyone, the server app
consumes only 1% of its CPU work.
I also did the source code level profiling and found that 90% of server work
is WSASend() or send().
Thus, WSASend and send() are very heavy methods, I concluded. However, I
should fix the problem. How can I solve it? I am just guessing sending
messages in overlapped I/O manner with completion port as it already works
on receiving will get better performance, but I'm not sure, as it is just a
guess.
Please reply, thanks in advance.
Bae, Hyun-jik
No it doesn't.
> The server receives messages in overlapped I/O manner with Completion
Port,
> and sends messages in traditional blocked send with winsock-internal send
> buffer.
Why don't you just send via completion ports as well?
> The results are:
> server consumes about 60% of its CPU work!!
> It may seem to be a serious cost, considering I'd expected about 2000
> simultaneous clients easily. However, when I let the server app reply the
> messages to only one client rather than 5% of everyone, the server app
> consumes only 1% of its CPU work.
> I also did the source code level profiling and found that 90% of server
work
> is WSASend() or send().
Odd. How large are your buffers? Did yo turn off internal buffering?
> Thus, WSASend and send() are very heavy methods, I concluded. However, I
> should fix the problem. How can I solve it? I am just guessing sending
> messages in overlapped I/O manner with completion port as it already works
> on receiving will get better performance, but I'm not sure, as it is just
a
> guess.
What I do is maintain a send queue per socket. The completion method will
loop sending the current message until it's done, then pull the next one off
the queue and send that. So I have a 2 overlapped structures per socket
(one for send, one for recv). I haven't done the degree of testing that you
have, but my normal cpu load for a chat client I threw together for testing
is essentially zero. I'll have to hammer it and see how it scales.
Sean
"Sean Kelly" <ken...@pacbell.net> wrote in message
news:DNm07.24$aO1....@news.pacbell.net...