March 8th, 2017

How do we improve the performance of conhost processes when we ping a bunch of servers?

A customer had a program that launches many instances of the ping program in order to check the availability of a large number of servers. They found that each copy of ping comes with a copy of conhost.exe, and all these conhost processes degrade system performance by a factor of four. They were looking for guidance on how they could improve the performance of the conhost process.

Well, the best way to avoid performance issues with conhost is to stop using conhost.

It sounds like the customer was launching the ping program and then either parsing the output or studying the exit code in order to determine whether the server was up. Instead, they could use the System.Net.Network­Information.Ping class (if programming in C#) or the Icmp­Send­Echo function (if programming in C/C++). Not only is this more efficient, you get detailed status results which will help you decide which server your program should use.

(Both functions report the ping time in milliseconds because the speed of light is unlikely to improve.)

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.