A
andrew queisser
I've got the following situation and I'm wondering about scalability of
different solutions:
1) Client sends a request to a fixed port on a UDP server
2) UDP server sends an ACK and launches the request (worker thread)
3) UDP server sends response data back to client
4) Client sends ACK back to server
My question is about how to distribute the work among the main server and
the worker threads. My initial solution is to have the client send
everything to the fixed UDP port and then have the main server thread filter
out duplicate requests and duplicate ACKs. The server thread also sends the
response from step 2). The worker thread would only send the response back
to the client via a socket that each worker thread opens up upon creation.
However, I could also have the worker thread execute steps 2), 3) and
receive the ACK from step 4). That would relieve some load from the main
server thread, especially matching up the ACK with the thread that's
handling the request.
On the other hand, everything has to go through one network interface
anyway, so is there some advantage of structuring the code one way or the
other?
Also, does it make sense to use asynchronous BeginReceiveFrom with UDP in
order to get back to reading the socket or is the buffering on the incoming
UDP socket flexible enough to buffer out reasonable delays in the main
thread?
Thanks,
Andrew
different solutions:
1) Client sends a request to a fixed port on a UDP server
2) UDP server sends an ACK and launches the request (worker thread)
3) UDP server sends response data back to client
4) Client sends ACK back to server
My question is about how to distribute the work among the main server and
the worker threads. My initial solution is to have the client send
everything to the fixed UDP port and then have the main server thread filter
out duplicate requests and duplicate ACKs. The server thread also sends the
response from step 2). The worker thread would only send the response back
to the client via a socket that each worker thread opens up upon creation.
However, I could also have the worker thread execute steps 2), 3) and
receive the ACK from step 4). That would relieve some load from the main
server thread, especially matching up the ACK with the thread that's
handling the request.
On the other hand, everything has to go through one network interface
anyway, so is there some advantage of structuring the code one way or the
other?
Also, does it make sense to use asynchronous BeginReceiveFrom with UDP in
order to get back to reading the socket or is the buffering on the incoming
UDP socket flexible enough to buffer out reasonable delays in the main
thread?
Thanks,
Andrew