<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ted Graham on .NET : Windows Forms</title><link>http://weblogs.asp.net/tgraham/archive/tags/Windows+Forms/default.aspx</link><description>Tags: Windows Forms</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Web Service performance numbers--plenty fast for UI work</title><link>http://weblogs.asp.net/tgraham/archive/2006/11/15/Web-Service-performance-numbers_2D002D00_plenty-fast-for-UI-work.aspx</link><pubDate>Wed, 15 Nov 2006 23:12:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:934884</guid><dc:creator>Ted_Graham</dc:creator><author>Ted_Graham</author><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/tgraham/rsscomments.aspx?PostID=934884</wfw:commentRss><comments>http://weblogs.asp.net/tgraham/archive/2006/11/15/Web-Service-performance-numbers_2D002D00_plenty-fast-for-UI-work.aspx#comments</comments><description>&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&lt;font face="Courier New"&gt;While designing Web Services, the question of &amp;quot;interface granularity&amp;quot; often comes up.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Conventional wisdom is that Web Service calls are slow, so the interface must be quite coarse to prevent performance problems.&lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&lt;font face="Courier New"&gt;Four years ago, a partner and I built a 2-tier system, a rich client app that talked directly to a database.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Towards the end of the development cycle, the users said, &amp;quot;We know we said this was for internal use, but we want to use this application over the Internet.&amp;quot; &lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&lt;font face="Courier New"&gt;Bam! That is the kind of major requirements change that can kill projects.&lt;span&gt;&amp;nbsp; &lt;/span&gt;After some research, we factored the database calls into an IDataAccess interface that had two implementors: the original database layer and a web service layer that then called the original database layer.&lt;span&gt;&amp;nbsp; &lt;/span&gt;On startup, the app figures out which interface to use.&lt;span&gt;&amp;nbsp; &lt;/span&gt;As our research and prototyping showed, web services are plenty fast for this scenario.&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&lt;font face="Courier New"&gt;My current project is also a rich client backed by web services, and we are discussing how quickly the UI needs to respond to the user.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Microsoft&amp;#39;s &lt;a href="http://msdn2.microsoft.com/en-us/library/ms740089.aspx"&gt;performance guidelines&lt;/a&gt;&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;suggest one threshold, &amp;quot;A good guideline for interactive response is 500 milliseconds.&amp;quot;&lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&lt;font face="Courier New"&gt;Jim Webber&amp;nbsp;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;a href="http://webservices.org/weblog/jim_webber/even_if_you_think_you_can_beat_waldo_you_can_t_beat_einstein"&gt;estimates&lt;/a&gt; that SOAP adds 14 milliseconds round trip.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Network latency is usually less than 50 milliseconds round trip in the US, increasing roughly linearly to a rough maximum of 300 milliseconds worldwide.&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&lt;font face="Courier New"&gt;In my experience, a hit to an optimized database costs roughly 20 ms, plus latency to the database machine of another 5-10 ms.&lt;span&gt;&amp;nbsp; &lt;/span&gt;So we are looking at 14 + 50 + 20 + 10 = 94ms.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Add in another 50 ms for authentication, authorization and business logic on the server, which leaves the UI well under the 500 ms limit.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Anyone have numbers for how much SSL increases latency? &lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&lt;font face="Courier New"&gt;I just did some performance testing that supports these numbers as reasonable.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Using a unit test that connects to the web service and uses it to insert a row in a database (everything on the same machine), I was seeing average call times of 15 ms.&lt;span&gt;&amp;nbsp; &lt;/span&gt;That leaves room for a lot of latency before the application slows down.&lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoPlainText"&gt;&lt;font face="Courier New"&gt;On my project four years ago, we were forced into a finer grained (more talkative) interface by previous decisions.&lt;span&gt;&amp;nbsp; &lt;/span&gt;These days, I&amp;#39;m choosing this architecture with my eyes open, and I like the view.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=934884" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/tgraham/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/tgraham/archive/tags/.NET+best+practices/default.aspx">.NET best practices</category><category domain="http://weblogs.asp.net/tgraham/archive/tags/Advanced+.NET+Techniques/default.aspx">Advanced .NET Techniques</category><category domain="http://weblogs.asp.net/tgraham/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/tgraham/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/tgraham/archive/tags/Software+Process/default.aspx">Software Process</category><category domain="http://weblogs.asp.net/tgraham/archive/tags/Windows+Forms/default.aspx">Windows Forms</category></item></channel></rss>