{"id":95685,"date":"2017-03-08T07:00:00","date_gmt":"2017-03-08T22:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=95685"},"modified":"2019-03-13T01:07:45","modified_gmt":"2019-03-13T08:07:45","slug":"20170308-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20170308-00\/?p=95685","title":{"rendered":"How do we improve the performance of conhost processes when we ping a bunch of servers?"},"content":{"rendered":"<p>A customer had a program that launches many instances of the <code>ping<\/code> program in order to check the availability of a large number of servers. They found that each copy of <code>ping<\/code> comes with a copy of <a HREF=\"https:\/\/blogs.technet.microsoft.com\/askperf\/2009\/10\/05\/windows-7-windows-server-2008-r2-console-host\/\">conhost.exe<\/a>, and all these <code>conhost<\/code> processes degrade system performance by a factor of four. They were looking for guidance on how they could improve the performance of the <code>conhost<\/code> process. <\/p>\n<p>Well, the best way to avoid performance issues with <code>conhost<\/code> is to stop using <code>conhost<\/code>. <\/p>\n<p>It sounds like the customer was launching the <code>ping<\/code> program and then either <a HREF=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/\">parsing the output<\/a> or studying the exit code in order to determine whether the server was up. Instead, they could use <a HREF=\"http:\/\/msdn.microsoft.com\/library\/system.net.networkinformation.ping.aspx\">the <code>System.Net.Network&shy;Information.Ping<\/code> class<\/a> (if programming in C#) or the <a HREF=\"https:\/\/msdn.microsoft.com\/library\/aa366050(VS.85).aspx\">Icmp&shy;Send&shy;Echo<\/code> function<\/a> (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. <\/p>\n<p>(Both functions report the ping time in milliseconds because <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20161115-00\/?p=94715\">the speed of light is unlikely to improve<\/a>.) <\/p>\n","protected":false},"excerpt":{"rendered":"<p>How about avoiding them entirely?<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-95685","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>How about avoiding them entirely?<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/95685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=95685"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/95685\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=95685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=95685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=95685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}