<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: How-To: Rack Middleware for API Throttling</title>
	<atom:link href="http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/</link>
	<description>Multichannel Messaging Explained</description>
	<lastBuildDate>Tue, 29 Dec 2009 23:20:56 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nino</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-73</link>
		<dc:creator>Nino</dc:creator>
		<pubDate>Tue, 29 Dec 2009 23:20:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-73</guid>
		<description>@Brian: have you actually gotten this to work? 

In my experiments and according the documentation, for volatile keys (expired keys), INCR will overwrite the value, treating it as null; your counter will forever be 1 if you use expire.

incr(&#039;foo&#039;,1)
# foo = 1 # good
incr(&#039;foo&#039;,1)
# foo = 2 # good 
expire(&#039;foo&#039;,100)
# foo will expire in 100 seconds
incr(&#039;foo&#039;,1)
# foo = 1 # bad

See this thread:
http://groups.google.com/group/redis-db/browse_thread/thread/9de9fdb23d9b04c2

Using a cron job for cleanup seems to be a reasonable approach to this problem</description>
		<content:encoded><![CDATA[<p>@Brian: have you actually gotten this to work? </p>
<p>In my experiments and according the documentation, for volatile keys (expired keys), INCR will overwrite the value, treating it as null; your counter will forever be 1 if you use expire.</p>
<p>incr(&#8216;foo&#8217;,1)<br />
# foo = 1 # good<br />
incr(&#8216;foo&#8217;,1)<br />
# foo = 2 # good<br />
expire(&#8216;foo&#8217;,100)<br />
# foo will expire in 100 seconds<br />
incr(&#8216;foo&#8217;,1)<br />
# foo = 1 # bad</p>
<p>See this thread:<br />
<a href="http://groups.google.com/group/redis-db/browse_thread/thread/9de9fdb23d9b04c2" rel="nofollow">http://groups.google.com/group/redis-db/browse_thread/thread/9de9fdb23d9b04c2</a></p>
<p>Using a cron job for cleanup seems to be a reasonable approach to this problem</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Hammond</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-70</link>
		<dc:creator>Brian Hammond</dc:creator>
		<pubDate>Sun, 23 Aug 2009 04:30:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-70</guid>
		<description>Nevermind this.  I just looked how Rack::Auth::Basic actually works :)</description>
		<content:encoded><![CDATA[<p>Nevermind this.  I just looked how Rack::Auth::Basic actually works <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Hammond</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-69</link>
		<dc:creator>Brian Hammond</dc:creator>
		<pubDate>Sun, 23 Aug 2009 03:54:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-69</guid>
		<description>You might want to actually authenticate the username given against your datastore.  Otherwise, an attacker could push someone else over *their* rate limit.</description>
		<content:encoded><![CDATA[<p>You might want to actually authenticate the username given against your datastore.  Otherwise, an attacker could push someone else over *their* rate limit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Hammond</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-68</link>
		<dc:creator>Brian Hammond</dc:creator>
		<pubDate>Thu, 13 Aug 2009 18:05:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-68</guid>
		<description>FYI Redis supports key expiration.

http://code.google.com/p/redis/wiki/ExpireCommand

INCR then EXPIRE a key.

The nice part about the EXPIRE command is that you get a running rate limiter, as a pending expiration is removed after you change a value.

INCR key, EXPIRE key 3600.

@Leather - not everyone can control the nginx config (e.g. when hosted on Heroku).</description>
		<content:encoded><![CDATA[<p>FYI Redis supports key expiration.</p>
<p><a href="http://code.google.com/p/redis/wiki/ExpireCommand" rel="nofollow">http://code.google.com/p/redis/wiki/ExpireCommand</a></p>
<p>INCR then EXPIRE a key.</p>
<p>The nice part about the EXPIRE command is that you get a running rate limiter, as a pending expiration is removed after you change a value.</p>
<p>INCR key, EXPIRE key 3600.</p>
<p>@Leather &#8211; not everyone can control the nginx config (e.g. when hosted on Heroku).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stevie</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-47</link>
		<dc:creator>Stevie</dc:creator>
		<pubDate>Tue, 09 Jun 2009 16:04:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-47</guid>
		<description>@Leather,

Limit_req is great, but it doesn&#039;t have flexibility of a higher level tool like ApiThrottling.  Being able to limit on a per-user basis make ApiThrottling a heck of a lot more useful.  It&#039;s pretty common with API services to limit requests based on contractual agreements (pay more for a higher guaranteed throughput, etc).  This could be built into ApiThrottling without much work.

Also, starting off a comment with &quot;this is stupid&quot; is pretty asinine, especially when you obviously haven&#039;t spent the time to understand what ApiThrottling gives you.  Luc has made something really great here, and trolling just makes you look, well, stupid.</description>
		<content:encoded><![CDATA[<p>@Leather,</p>
<p>Limit_req is great, but it doesn&#8217;t have flexibility of a higher level tool like ApiThrottling.  Being able to limit on a per-user basis make ApiThrottling a heck of a lot more useful.  It&#8217;s pretty common with API services to limit requests based on contractual agreements (pay more for a higher guaranteed throughput, etc).  This could be built into ApiThrottling without much work.</p>
<p>Also, starting off a comment with &#8220;this is stupid&#8221; is pretty asinine, especially when you obviously haven&#8217;t spent the time to understand what ApiThrottling gives you.  Luc has made something really great here, and trolling just makes you look, well, stupid.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How-To: Rack Middleware for API Throttling - Daemian Mack</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-35</link>
		<dc:creator>How-To: Rack Middleware for API Throttling - Daemian Mack</dc:creator>
		<pubDate>Fri, 15 May 2009 20:05:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-35</guid>
		<description>[...] Rack Middleware for API Throttling  I will show you a technique to impose a rate limit (aka API Throttling) on a Ruby Web Service. I will be using Rack middleware so you can use this no matter what Ruby Web Framework you are [...]</description>
		<content:encoded><![CDATA[<p>[...] Rack Middleware for API Throttling  I will show you a technique to impose a rate limit (aka API Throttling) on a Ruby Web Service. I will be using Rack middleware so you can use this no matter what Ruby Web Framework you are [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luc Castera</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-34</link>
		<dc:creator>Luc Castera</dc:creator>
		<pubDate>Fri, 15 May 2009 16:39:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-34</guid>
		<description>Leather,

Thanks for your comment. I did look at the limit_req module but the documentation was sparse and it didn&#039;t seem to be able to limit connections per user.

If you have used limit_req before, it would be great if you could write about it and share your knowledge since there is so little documentation on it. I would love to see a solution to this problem using limit_req module.

Rack and redis are not really a overhead. All Ruby frameworks use rack it and if you run any modern Ruby web framework, you are already using it heavily + we are using Redis for other stuff to so it is part of our infrastructure.  If you do not want to use Redis and have Memcached already running, you could easily adapt this code to use memcached instead (see Mike&#039;s comment earlier).</description>
		<content:encoded><![CDATA[<p>Leather,</p>
<p>Thanks for your comment. I did look at the limit_req module but the documentation was sparse and it didn&#8217;t seem to be able to limit connections per user.</p>
<p>If you have used limit_req before, it would be great if you could write about it and share your knowledge since there is so little documentation on it. I would love to see a solution to this problem using limit_req module.</p>
<p>Rack and redis are not really a overhead. All Ruby frameworks use rack it and if you run any modern Ruby web framework, you are already using it heavily + we are using Redis for other stuff to so it is part of our infrastructure.  If you do not want to use Redis and have Memcached already running, you could easily adapt this code to use memcached instead (see Mike&#8217;s comment earlier).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leather Donut</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-33</link>
		<dc:creator>Leather Donut</dc:creator>
		<pubDate>Fri, 15 May 2009 16:01:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-33</guid>
		<description>This is stupid.

Use the right tool for the right problem. There is no need to include all of this at such a high level. 

For example, nginx has the limit_req directive that works perfectly for something like this. There is no need to incur all the additional overhead of rack, redis blah blah blah.</description>
		<content:encoded><![CDATA[<p>This is stupid.</p>
<p>Use the right tool for the right problem. There is no need to include all of this at such a high level. </p>
<p>For example, nginx has the limit_req directive that works perfectly for something like this. There is no need to incur all the additional overhead of rack, redis blah blah blah.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dev Blog AF83 &#187; Blog Archive &#187; Veille technologique : Infrastructure Ruby Rails, HTML, Javascript, Tutoriels, Git, Regexp</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-32</link>
		<dc:creator>Dev Blog AF83 &#187; Blog Archive &#187; Veille technologique : Infrastructure Ruby Rails, HTML, Javascript, Tutoriels, Git, Regexp</dc:creator>
		<pubDate>Mon, 11 May 2009 22:16:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-32</guid>
		<description>[...] http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/ : un tutoriel pour faire de l&#8217;API throttling grâce à Rake (l&#8217;API throttling est une pratique qui consiste à limiter le nombre d&#8217;appels qu&#8217;un client peut faire à une service web) [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/" rel="nofollow">http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/</a> : un tutoriel pour faire de l&#8217;API throttling grâce à Rake (l&#8217;API throttling est une pratique qui consiste à limiter le nombre d&#8217;appels qu&#8217;un client peut faire à une service web) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Reubenstein</title>
		<link>http://blog.messagepub.com/2009/05/05/how-to-rack-middleware-for-api-throttling/#comment-31</link>
		<dc:creator>Ben Reubenstein</dc:creator>
		<pubDate>Sun, 10 May 2009 17:57:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.messagepub.com/?p=107#comment-31</guid>
		<description>Glad to see some great examples of how to use Rack.  Unless I was attending the wrong sessions, I felt RailsConf was very light on solid examples.</description>
		<content:encoded><![CDATA[<p>Glad to see some great examples of how to use Rack.  Unless I was attending the wrong sessions, I felt RailsConf was very light on solid examples.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
