3

I'm building an app (client) in C# which pings a server in my local network using Ping.SendAsync(host, 3000, null) to verify connectivity and send data. The app will be installed in about 200 PCs.

Question is:

Is it safe to ping the server every 5secs from those 200 PCs all day long?

Thanks in advance

Marko
  • 20,385
  • 13
  • 48
  • 64
user1693287
  • 33
  • 1
  • 2
  • 3
    Why would you ping (poll) so often? Are you consistently sending data or are you trying to verify it's okay to send data whenever? – tsells Sep 24 '12 at 03:11
  • @tsells: I don't know why OP is doing it, but when I did it the reason was to know relatively quickly when the server went down. Mine was a monitoring app, though, so it only had a few clients rather than 200. – Gabe Sep 24 '12 at 03:37

2 Answers2

5

You should already know the answer to this one - it depends.

Let's say you are sending 40 requests per second, on average. Can a web server handle 40 requests per second? It likely can, but you don't provide any detail of what the server is doing.

For a server to receive a request and return a simple value then the number of milliseconds could well be in the single digits. If the server needs to read or write to disk, or connect to another server (say, a database) then the number of milliseconds might be two digits. If connecting to a remote or multiple servers then it might even take three digits - over 100ms.

If the server needs to crunch some numbers and calculate something then there's no way of guessing - it could take a day for all I know.

Assuming the server doesn't run any other critical systems that need dedicated resources, you are really interested in two things here

  • how long does an operation take to complete? It obviously needs to complete in well under 5 seconds, because the server will want to make another request at that time and they will simply queue up causing chaos.
  • how many concurrent requests can the server handle? Make sure you aren't running a single threaded server; you want to be able to process multiple requests at the same time. This will again ensure that requests don't queue up.

You need to average 40 per second, which is really not very much - assuming there is not much processing happening. But the way the know whether this is a 'good idea' or not is to simply test it out. You should use a test framework or write a test harness - it's exceedingly simple to do, just write apps that hit the server as fast as they can. You will need to run the test from multiple client machines because otherwise you won't be sure that the single client machine isn't a bottleneck.

This might sound tedious but it is both necesary and educational.

Kirk Broadhurst
  • 27,836
  • 16
  • 104
  • 169
  • Good post Kirk. Note the OP does specify that he's using 'Ping.SendAsync' - not a request that will write to disk. – Adam Sep 24 '12 at 03:26
  • Thankyou for replying my post. – user1693287 Sep 24 '12 at 15:23
  • Thankyou for replying my post. I'll do some testing and see how well it does. The Reason for pinging the server so often is because students often unplug client pcs and reboot them pretty often. (its a school where I work at). I'm also using NetworkAvailability/AvailabilityChanged for that. But I need to verify the link is up and ready for sending info to the server. Not much info though...only a pair of insert queries to a db once every half hour or so from every client (200). – user1693287 Sep 24 '12 at 15:36
0

Thats only about 110MB a day... I wouldn't stress about it.

You do mention sending data though... make sure your packets are of reasonable size (you want to avoid DDOSing yourself).

If it were running over the internet I might be more careful however.

classicjonesynz
  • 4,012
  • 5
  • 38
  • 78
Adam
  • 4,159
  • 4
  • 32
  • 53
  • Thank you. Yes I do send data. Not much though. Only a pair of insert queries every half hour or so. I'm running on local network. I'll do some testing and see how it works. – user1693287 Sep 24 '12 at 15:38