<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Why WSGI?</title>
	<atom:link href="http://www.circulartriangle.com/?feed=rss2&#038;p=26" rel="self" type="application/rss+xml" />
	<link>http://www.circulartriangle.com/blog/?p=26</link>
	<description>Blog</description>
	<lastBuildDate>Mon, 24 May 2010 22:09:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Matthew Wilkes</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-68</link>
		<dc:creator>Matthew Wilkes</dc:creator>
		<pubDate>Wed, 03 Feb 2010 02:54:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-68</guid>
		<description>Thanks for that Benjamin!  Unfortunately I&#039;ve not got much time to put into this site and my front-end knowledge is pretty limited.  The fact that the footer navigation is just &quot;hi&quot; and the inconsistent use of colour on links is another issue.  Not to mention the fact that the front page of the website is just a holding page.

It&#039;s very much a work in progress, it&#039;s just limited by how much work I have on.  Hopefully it&#039;ll be better by the next time you come here.</description>
		<content:encoded><![CDATA[<p>Thanks for that Benjamin!  Unfortunately I&#8217;ve not got much time to put into this site and my front-end knowledge is pretty limited.  The fact that the footer navigation is just &#8220;hi&#8221; and the inconsistent use of colour on links is another issue.  Not to mention the fact that the front page of the website is just a holding page.</p>
<p>It&#8217;s very much a work in progress, it&#8217;s just limited by how much work I have on.  Hopefully it&#8217;ll be better by the next time you come here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benjamin</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-67</link>
		<dc:creator>Benjamin</dc:creator>
		<pubDate>Wed, 03 Feb 2010 00:19:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-67</guid>
		<description>Please don&#039;t take this as trolling, but simply constructive criticism.
The post was great, but the way the fonts render on Chrome for Mac is seriously almost unreadable.</description>
		<content:encoded><![CDATA[<p>Please don&#8217;t take this as trolling, but simply constructive criticism.<br />
The post was great, but the way the fonts render on Chrome for Mac is seriously almost unreadable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Hamilton</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-65</link>
		<dc:creator>Matt Hamilton</dc:creator>
		<pubDate>Tue, 02 Feb 2010 10:48:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-65</guid>
		<description>As Martin pointed out lxml is fast. Its added processing time is negligible addition to the time of actually serving up the request in most case. And if adding 10ms to your app is a big deal, then you probably wouldn&#039;t be doing this approach anyway.

My &#039;Lipstick on a Pig&#039; system that Matt mentioned above is a good example of this. Admittedly, the original .NET system we are proxying is insanely slow, but we then add on a WSGI pipeline of about 8-10 middleware stages. Most of these stages at the moment do an lxml parse/unparse step at each step (no optimisation done yet... this is a prime candidate for repoze.xmliter), yet the added delay is so small it can&#039;t be measured with any statistical certainty.  This combined with the fact we are then sending about a 1/3 of the resultant HTML compared to previously, and it is well formed (original .NET produced HTML was not) means that it *seems* faster to the end user as the download and render speeds for the browser are much quicker.

Also coupled with the fact we were able to break our problem down in to many small steps (quite a few are re-used as we have about 6 different pipelines, each with a variation of which middleware is called in each one) that we could test independently means that overall we have a better system than we would have done had we not had the flexibility of WSGI.

-Matt</description>
		<content:encoded><![CDATA[<p>As Martin pointed out lxml is fast. Its added processing time is negligible addition to the time of actually serving up the request in most case. And if adding 10ms to your app is a big deal, then you probably wouldn&#8217;t be doing this approach anyway.</p>
<p>My &#8216;Lipstick on a Pig&#8217; system that Matt mentioned above is a good example of this. Admittedly, the original .NET system we are proxying is insanely slow, but we then add on a WSGI pipeline of about 8-10 middleware stages. Most of these stages at the moment do an lxml parse/unparse step at each step (no optimisation done yet&#8230; this is a prime candidate for repoze.xmliter), yet the added delay is so small it can&#8217;t be measured with any statistical certainty.  This combined with the fact we are then sending about a 1/3 of the resultant HTML compared to previously, and it is well formed (original .NET produced HTML was not) means that it *seems* faster to the end user as the download and render speeds for the browser are much quicker.</p>
<p>Also coupled with the fact we were able to break our problem down in to many small steps (quite a few are re-used as we have about 6 different pipelines, each with a variation of which middleware is called in each one) that we could test independently means that overall we have a better system than we would have done had we not had the flexibility of WSGI.</p>
<p>-Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris McDonough</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-63</link>
		<dc:creator>Chris McDonough</dc:creator>
		<pubDate>Mon, 01 Feb 2010 19:46:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-63</guid>
		<description>I used to be all about WSGI middleware as componentry.  After much gnashing of teeth, these days, not so much.  TBH, I&#039;d probably instead built this functionality into each application rather than trying to develop a generic captcha middleware thing.</description>
		<content:encoded><![CDATA[<p>I used to be all about WSGI middleware as componentry.  After much gnashing of teeth, these days, not so much.  TBH, I&#8217;d probably instead built this functionality into each application rather than trying to develop a generic captcha middleware thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Wilkes</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-62</link>
		<dc:creator>Matthew Wilkes</dc:creator>
		<pubDate>Mon, 01 Feb 2010 14:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-62</guid>
		<description>Alan: Yeah, that&#039;s what I was thinking when I mentioned making it caching-aware.  With a carefully tuned grace time on your objects no users will even see the (slight) slowdown.</description>
		<content:encoded><![CDATA[<p>Alan: Yeah, that&#8217;s what I was thinking when I mentioned making it caching-aware.  With a carefully tuned grace time on your objects no users will even see the (slight) slowdown.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Hoey</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-61</link>
		<dc:creator>Alan Hoey</dc:creator>
		<pubDate>Mon, 01 Feb 2010 13:20:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-61</guid>
		<description>There&#039;s potentially a very nice extension to this if you&#039;re looking for a performance boost - have the middleware inject an ESI rather than the new form field(s).  Then you can cache the entire form and keep the CAPTCHA generation in the fast part of the pipeline.  Obviously you need to be running something like Varnish that understands ESI to do this but it would probably make a measurable difference where you&#039;re serving a lot of forms.</description>
		<content:encoded><![CDATA[<p>There&#8217;s potentially a very nice extension to this if you&#8217;re looking for a performance boost &#8211; have the middleware inject an ESI rather than the new form field(s).  Then you can cache the entire form and keep the CAPTCHA generation in the fast part of the pipeline.  Obviously you need to be running something like Varnish that understands ESI to do this but it would probably make a measurable difference where you&#8217;re serving a lot of forms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SK</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-60</link>
		<dc:creator>SK</dc:creator>
		<pubDate>Mon, 01 Feb 2010 12:27:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-60</guid>
		<description>Aspelli: not the point really. Processing and monkeypatching whole responses every time they are generated just to insert a CAPTCHA is stupid. Generating an XML tree rather than using a regexp is just a variation on insanity.

Wilkes: yes, premature optimization is bad, but refusing to bother about efficiency at the design phase is even worse.</description>
		<content:encoded><![CDATA[<p>Aspelli: not the point really. Processing and monkeypatching whole responses every time they are generated just to insert a CAPTCHA is stupid. Generating an XML tree rather than using a regexp is just a variation on insanity.</p>
<p>Wilkes: yes, premature optimization is bad, but refusing to bother about efficiency at the design phase is even worse.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Aspeli</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-59</link>
		<dc:creator>Martin Aspeli</dc:creator>
		<pubDate>Mon, 01 Feb 2010 05:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-59</guid>
		<description>@SK - your moronic side-swipe aside, parsing an output document with the lxml HTML parser is relatively effecient. Most web pages consist of only a few kb of HTML at most, and lxml is fast. Working with a well-defined data structure is a lot safer and potentially more efficient than doing a lot of regex matching, for instance. Using something like repoze.xmliter, you&#039;ve also got a way to do that which allows you to only parse once even if you have multiple middleware layers.

As Matt pointed out, there are situations where layering this functionality on top of an application makes a lot of sense. Response post-processing is a very commonly used technique in a lot of frameworks. WSGI makes it nicer than most.

Martin</description>
		<content:encoded><![CDATA[<p>@SK &#8211; your moronic side-swipe aside, parsing an output document with the lxml HTML parser is relatively effecient. Most web pages consist of only a few kb of HTML at most, and lxml is fast. Working with a well-defined data structure is a lot safer and potentially more efficient than doing a lot of regex matching, for instance. Using something like repoze.xmliter, you&#8217;ve also got a way to do that which allows you to only parse once even if you have multiple middleware layers.</p>
<p>As Matt pointed out, there are situations where layering this functionality on top of an application makes a lot of sense. Response post-processing is a very commonly used technique in a lot of frameworks. WSGI makes it nicer than most.</p>
<p>Martin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Wilkes</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-57</link>
		<dc:creator>Matthew Wilkes</dc:creator>
		<pubDate>Sun, 31 Jan 2010 22:52:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-57</guid>
		<description>If only I&#039;d thought to add &quot;illustrative pseudocode&quot; somewhere in that post.  First-off, it&#039;s obvious to anyone that&#039;s written any code professionally that this isn&#039;t a suggested piece of production code.  I mean, just look at it, it&#039;s &lt;em&gt;clearly&lt;/em&gt; a proof of concept that took about 5 minutes to write.  For one thing it would fail on the vast majority of HTTP traffic, it was written in a browser to show one possible way of doing it.  Would you perhaps feel more comfortable if I said &quot;XSLT compilation&quot;, or maybe &quot;regular expression&quot;?  Not that it matters, anyway, the real issue with this example is that it treats the response body as a string, not as an iterable.  You try doing that on your sites, that&#039;s the real killer, not lxml&#039;s C.  Even in this naïve case, I&#039;d estimate it would add maybe 10ms to each request.

If you&#039;re coding for fastest-possible responses right from the start you&#039;re &lt;strong&gt;doing it wrong&lt;/strong&gt;.  The whole point of this is that by using an architecture like this your app and the CAPTCHA system can evolve independently.  Once you&#039;ve made an implementation that is caching-aware you&#039;re down to nothing at all. What you have at the end, however, is far superior to what you&#039;d have if you&#039;d built yet another one-shot CAPTCHA system and you&#039;re still up on time compared to integrating somebody else&#039;s with the FooFormLibrary that you&#039;re using.

So, yes, I&#039;m happy to be of the mindset that it&#039;s better to take the hit of parsing some responses to get a better system overall, otherwise I&#039;d be knowingly producing inferior code because  the superior method makes me feel uncomfortable.</description>
		<content:encoded><![CDATA[<p>If only I&#8217;d thought to add &#8220;illustrative pseudocode&#8221; somewhere in that post.  First-off, it&#8217;s obvious to anyone that&#8217;s written any code professionally that this isn&#8217;t a suggested piece of production code.  I mean, just look at it, it&#8217;s <em>clearly</em> a proof of concept that took about 5 minutes to write.  For one thing it would fail on the vast majority of HTTP traffic, it was written in a browser to show one possible way of doing it.  Would you perhaps feel more comfortable if I said &#8220;XSLT compilation&#8221;, or maybe &#8220;regular expression&#8221;?  Not that it matters, anyway, the real issue with this example is that it treats the response body as a string, not as an iterable.  You try doing that on your sites, that&#8217;s the real killer, not lxml&#8217;s C.  Even in this naïve case, I&#8217;d estimate it would add maybe 10ms to each request.</p>
<p>If you&#8217;re coding for fastest-possible responses right from the start you&#8217;re <strong>doing it wrong</strong>.  The whole point of this is that by using an architecture like this your app and the CAPTCHA system can evolve independently.  Once you&#8217;ve made an implementation that is caching-aware you&#8217;re down to nothing at all. What you have at the end, however, is far superior to what you&#8217;d have if you&#8217;d built yet another one-shot CAPTCHA system and you&#8217;re still up on time compared to integrating somebody else&#8217;s with the FooFormLibrary that you&#8217;re using.</p>
<p>So, yes, I&#8217;m happy to be of the mindset that it&#8217;s better to take the hit of parsing some responses to get a better system overall, otherwise I&#8217;d be knowingly producing inferior code because  the superior method makes me feel uncomfortable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SK</title>
		<link>http://www.circulartriangle.com/blog/?p=26&#038;cpage=1#comment-56</link>
		<dc:creator>SK</dc:creator>
		<pubDate>Sun, 31 Jan 2010 21:09:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.circulartriangle.com/blog/?p=26#comment-56</guid>
		<description>So you&#039;re parsing and building an XML tree of the response for each request in the hope that there&#039;s a captcha to replace there? With such a mindset, no wonder zope/plone has a reputation for very poor performance. And no wonder WSGI is perceived as snake oil if that&#039;s all you can come up with.</description>
		<content:encoded><![CDATA[<p>So you&#8217;re parsing and building an XML tree of the response for each request in the hope that there&#8217;s a captcha to replace there? With such a mindset, no wonder zope/plone has a reputation for very poor performance. And no wonder WSGI is perceived as snake oil if that&#8217;s all you can come up with.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
