<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>swag.dk &#187; Insanity</title>
	<atom:link href="http://swag.dk/blog/category/insanity/feed/" rel="self" type="application/rss+xml" />
	<link>http://swag.dk/blog</link>
	<description></description>
	<lastBuildDate>Wed, 21 Jul 2010 12:34:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>A ongoing discussion about C and libmemcached &#8211; don&#8217;t censor me</title>
		<link>http://swag.dk/blog/2009/03/26/a-ongoing-discussion-about-c-and-libmemcached-dont-censor-me/</link>
		<comments>http://swag.dk/blog/2009/03/26/a-ongoing-discussion-about-c-and-libmemcached-dont-censor-me/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 11:01:50 +0000</pubDate>
		<dc:creator>Mads Sülau Jørgensen</dc:creator>
				<category><![CDATA[Insanity]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://swag.dk/blog/?p=75</guid>
		<description><![CDATA[And there I was, happy as a 4-year old who had just found a whole box of strawberries. Then all of a sudden, along came a post about how Amir Salihefendic had made a little daemon in C, using libevent &#8230; <a href="http://swag.dk/blog/2009/03/26/a-ongoing-discussion-about-c-and-libmemcached-dont-censor-me/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>And there I was, happy as a 4-year old who had just found a whole box of strawberries.</p>

<p>Then all of a sudden, along came a post about how <a href="http://amix.dk/">Amir Salihefendic</a> had made a <a href="http://amix.dk/blog/viewEntry/19414">little daemon in C</a>, using libevent and memcached, that would allow him to cache a http request in memcached. I don&#8217;t quite get why one would like to reinvent a reverse http proxy like that, and stated my arguments on why I thought that this seemed like a really bad idea.</p>

<p>As you can tell from the comments, he did not agree. It ended up with him deleting my last comment. Good thing I kept a copy in my clipboard. So, here are the comments.
<span id="more-75"></span></p>

<p><strong>Mads Sülau Jørgensen 25. Mar</strong></p>

<p>This could just be me, but why would you do this over a proxy setup with Varnish, Squid og Apache with mpm&#95;event and mod&#95;cache? Seems a little like you&#8217;ve reinvented the wheel.</p>

<p>Also, as a previous commenter has suggested, why did you not just use the memcached support in nginx, and if it was because of the lack of multiple memcache servers, why not patch it and send this patch back to the community?</p>

<p><strong>amix 25. Mar</strong></p>

<p>Mads Sülau Jørgensen:</p>

<p>There are two reasons why I didn&#8217;t patch nginx with this support:</p>

<p>Separation of concerns: Running a separate polling server architecture I can monitor it and scale it independently
Patching nginx would not have been that easy
I prefer using memcached than Varnish or other caching options and memcached gives me a lot of options (deletion of multiple keys at once, consistent hashing and easy and proven scaling to terabytes of cache &#8211; - just to name a few).</p>

<p><strong>Mads Sülau Jørgensen 25. Mar</strong></p>

<p>Ah, but you could, easily, monitor a running nginx instance. The same goes for a running varnish instance. I&#8217;m not necessarily talking about running the nginx memcached module in the same process or the same server as your main proxy is running. So you&#8217;d archive the seperation by running another process or running the process on another box. Easy.</p>

<p>And the memcached module of nginx does not seem /that/ difficult to work with. Sure you&#8217;d have to do alot of handling of dead servers, and timeouts that could block the whole server. The current one probably handles this already. I don&#8217;t use it, so I&#8217;m not one to say.</p>

<p>With your keys structured correctly, you can flush (purge) multiple keys easily in varnish. You can provide your own hashing function as well. You could also use nginx&#8217;s hash balancer to send the request to the &#8220;correct&#8221; backend server.</p>

<p>The thing about hacking some server together with libevent in a language, that might not be onces main language is, that you&#8217;ll end up missing a lot of things, and it may end up exploding in your face. From the top of my head, what happens if a memcached server dies, memory leaks, what happens if the process segfaults (see memory leak).</p>

<p>It might be super-duper fast, but is it stable :)</p>

<p><strong>amix 25. Mar</strong></p>

<p>Mads Sülau Jørgensen:</p>

<pre>plurk@web04:~$ ps aux | grep poll_server
plurk     29835  2.3  0.0   2376  1048 ?        
S    Mar24  27:23 /home/plurk/poll_server/poll_server 0.0.0.0 16000</pre>

<p>It&#8217;s pretty stable (has not crashed since I started it), uses very little CPU and very little memory. If I stop the server, the nginx server will just route everything to Python servers. I doubt Varnish or patching Nginx would have been faster or more stable &#8211; - and they would have added a big conceptual complexity.</p>

<p>Personally, I would much rather fix errors in a 100 line program than a thousands line program. It&#8217;s separation of concerns and separation of complexity. So sure, I could have extended nginx+memcached or hacked Varnish &#8211; - but I chose to keep it simple, learn some new things and solve the problem in a very specialized way.</p>

<p><strong>Mads Sülau Jørgensen 25. Mar</strong></p>

<p>There is no hacking in the varnish solution what so ever. Varnish is a http proxy cache, it would be doing what is was designed to do. And my guess is, that it would be doing it well. My guess is also, that you&#8217;d end up using it alot, and to do more that using it with this one goal.</p>

<p>With a specialized solution, you have to handle a new process, you have to handle the errors that process can give, and you have to keep it running.</p>

<p>Using the tools already available makes more sense to me, and that&#8217;s what I&#8217;m doing when I run into a problem. Others, more proficient programmers usually have had the same problem before me.</p>

<p><strong>amix 25. Mar</strong></p>

<p>Mads Sülau Jørgensen:</p>

<p>Varnish is a good HTTP proxy and cache, no doubt about that, but it lacks a lot of things to be used in my setup. For example, how can I invalidate 1000 keys at once and do it in a split of a second? Their purging capabilities seem to be pretty primitive&#8230;</p>

<p>Plus, who said that I won&#8217;t iterate over this and go into a new direction &#8211; for example, benchmark this against a long-polling &#8220;comet&#8221; solution. Going into this direction would mean dropping Varnish &#8211; while I only need to change and add some lines of code to create a long polling solution of this.</p>

<p><strong>Mads Sülau Jørgensen 25. Mar</strong></p>

<p>Well, with a properly designed URL schema, you&#8217;d do something like this:</p>

<p>PURGE /poll/user/(?:mads|john|abc*)+/status</p>

<p>And then you&#8217;d have the VCL to handle that purge via purge_url(). The above will then purge the urls matching the regular expression, (so mads or john or starting with abc).</p>

<p>It actually works both fast, and well. It does not purge the cache when you tell it, but when you request an object. That makes invalidation <em>fast</em>.</p>

<p>See http://varnish.projects.linpro.no/ for more information.</p>

<p>You can more or less configure varnish to do what you want it to do via it&#8217;s configuration file.</p>

<p>As for the comet solution, your post more or less said that. Right about where it said something about push being hard to scale, which strikes me as a very odd comment. With push, you just have to be able to handle a horde of mostly idle connections, for which http://code.google.com/p/erlycomet/ or something like that, would probably be the way to go.</p>

<p><strong>amix 25. Mar</strong></p>

<p>Mads Sülau Jørgensen:</p>

<p>I am pretty tired of keep repeating myself. So this will be the last comment I answer you.</p>

<p>Varnish is a good cache, but it&#8217;s not really suited where I am headed. An example, how would you change the Varnish solution to support long polling? I can explore this option pretty easily with a basic understanding of how to build a custom server that can perform really good and that can be customized for my needs. I personally want to learn how to build things myself (also things that are complex and that require some thinking and engineering). I know I&#8217;ll need this skill longer down the road and practice makes a master &#8211; so the more practice I have, the better I&#8217;ll be at doing this.</p>

<p><strong>this is the reply he deleted</strong></p>

<p>&#62; I am pretty tired of keep repeating myself. So this will be the last comment I answer you.</p>

<p>The consider this answer a bonus for your collection of entropy.</p>

<p>&#62; An example, how would you change the Varnish solution to support long polling?</p>

<p>I&#8217;m quite sure that I never implied, that varnish would be suitable to do long polling (or other non-cachable long lived requests). If you think I did, please, tell me where.</p>

<p>&#62; I can explore this option pretty easily with a basic understanding of how to build a custom server that can perform really good and that can be customized for my needs.</p>

<p>Yes, and that&#8217;s very fine and good, but that&#8217;s not really what your post says. It basiclly says &#8220;Using libmemcached and a C program, I can make a lot of http requests. Fast. And I don&#8217;t expect to use comet. Push is not what I want.&#8221; but from the looks of it, you may have wanted it to say &#8220;Hi, I made this little C program using libmemcached that I&#8217;m planing on developing into a comet server at some point. I need to extend the server with push in the future.&#8221;</p>

<p>&#62; I personally want to learn how to build things myself (also things that are complex and that require some thinking and engineering).</p>

<p>Yes, throwing something together is very fun, throwing something together in C is even more fun. But throwing something together in C for a large website, because, it&#8217;s just fun, well, for a lot of the web developers in the world, that&#8217;s a really bad idea. It may work today, tomorrow but will it work in a week, a month or a year?</p>

<p>&#62; I know I&#8217;ll need this skill longer down the road and practice makes a master &#8211; so the more practice I have, the better I&#8217;ll be at doing this.</p>

<p>Then I&#8217;d really recommend you looking at this:</p>

<p>http://aleccolocco.blogspot.com/2008/10/gazillion-user-comet-server-with.html</p>

<p>A comet server in C, with all the boiler plate completed. Just insert logic.</p>

<p>You might also get a kick out of reading up on memory management, input validation, how to avoid buffer overflows and just plain old K&amp;R C.</p>
]]></content:encoded>
			<wfw:commentRss>http://swag.dk/blog/2009/03/26/a-ongoing-discussion-about-c-and-libmemcached-dont-censor-me/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>DNS management done right (and without the crappy attitude)</title>
		<link>http://swag.dk/blog/2009/03/06/dns-management-done-right-and-without-the-crappy-attitude/</link>
		<comments>http://swag.dk/blog/2009/03/06/dns-management-done-right-and-without-the-crappy-attitude/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 07:24:44 +0000</pubDate>
		<dc:creator>Mads Sülau Jørgensen</dc:creator>
				<category><![CDATA[Insanity]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://swag.dk/blog/?p=67</guid>
		<description><![CDATA[I&#8217;ve been using GratisDNS A free danish dns provider to manage my dns for a long time. Using their management interface is no walk in the park. It also has a bat habit of sending the username and password as &#8230; <a href="http://swag.dk/blog/2009/03/06/dns-management-done-right-and-without-the-crappy-attitude/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://www.gratisdns.dk/">GratisDNS A free danish dns provider</a> to manage my dns for a long time. Using their management interface is no walk in the park. It also has a bat habit of sending the username and password as a hidden form variable for every page request, in cleartext mind you. Nothing like examining the source of a page (for instance, if you wanted to make an <a href="http://code.google.com/p/python-gratisdns/">python api</a>) and seeing your password in cleartext.</p>

<p>As far as their interface goes, I can deal with that. It works, and it seems to do what it&#8217;s supposed to do fairly easy. A thing that has pushed me over the top, is the admins inability to <a href="http://forum.gratisdns.dk/gratisdns-support/forventet-tid-til-axfr-for-hidden-primary/">help diagnostic</a> a technical issue related to using their system as a secondary dns in front of a hidden primary.</p>

<p>Yesterday a <a href="http://www.technobabble.dk/">good friend</a> of mine told me that there was a new player in the dns game, one started by some people that seem to care about usability, exciting features (multiple dns templates per domain) and external api&#8217;s (goodbuy <a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a>). It&#8217;s called <a href="http://www.quickdns.dk/">QuickDNS</a>.</p>

<p>So I rushed to their site, created myself a user and started tinkering around. Let&#8217;s just say, the it was actually a pleasant experience to do, things just worked<sup>tm</sup>. So I setup a few templates and now have transfered a handful of my domains over there. Seems to work very well, just as expected.</p>

<p>So a very big congratulations to the whole QuickDNS team, you&#8217;ve done an excellent job, and made me a happy customer.</p>

<p>I seem to have agreed to give them a case of cola once they start implementing the axfr / hidden primary feature, and another one on completion. Can&#8217;t wait!</p>
]]></content:encoded>
			<wfw:commentRss>http://swag.dk/blog/2009/03/06/dns-management-done-right-and-without-the-crappy-attitude/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What open source and dentists have in common</title>
		<link>http://swag.dk/blog/2008/07/28/what-open-source-and-dentists-have-in-common/</link>
		<comments>http://swag.dk/blog/2008/07/28/what-open-source-and-dentists-have-in-common/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 08:14:16 +0000</pubDate>
		<dc:creator>Mads Sülau Jørgensen</dc:creator>
				<category><![CDATA[Insanity]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[dentist]]></category>
		<category><![CDATA[dont-kill-me]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://swag.dk/blog/?p=22</guid>
		<description><![CDATA[So this morning I went to the dentist. I have the most fair and lovely dentist in the whole world, but today, there were a new dentist in town. Now I really don&#8217;t mind dentists, going to the dentist or &#8230; <a href="http://swag.dk/blog/2008/07/28/what-open-source-and-dentists-have-in-common/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So this morning I went to the dentist. I have the most <a href="http://www.tandnet.dk/">fair and lovely dentist</a> in the whole world, but today, there were a new dentist in town. Now I really don&#8217;t mind dentists, going to the dentist or doctors in general, but what i don&#8217;t like is not being informed about what is going to happen next. The same goes for open source projects.</p>

<p><span id="more-22"></span>
At work we only use open source software to create our solutions, and to run our hosting or these solutions. Amongst others we use <a href="http://httpd.apache.org/">Apache HTTPd</a>,  <a href="http://www.postgresql.org/">PostgreSQL</a> and of course <a href="http://www.debian.org/">Debian GNU/Linux</a> and I really love working with them. Now those I&#8217;ve just listed are quite mature projects and have a really large userbase. Apache in itself ofcouse is the de-facto HTTPd for any unix server, and it does it&#8217;s job incredibly well.</p>

<p>We also use a coule of unmature projects (in the term of lifespan, not stability), and amongst them are <a href="http://varnish.projects.linpro.no/">Varnish</a>. In case you don&#8217;t know, varnish is a really, really high performance reverse proxy. It&#8217;s designed by the lovely <a href="http://people.freebsd.org/~phk/">red bearded</a> man called <a href="http://phk.freebsd.dk/">Poul-Henning Kamp</a> who is also a long time FreeBSD kernel comitter, which should say something about the quality of the code he writes.</p>

<p>To be quite honest, I don&#8217;t like the fact that Varnish has not made a release or a statement about it&#8217;s progress for almost 8 months. It should&#8217;nt be so hard, they have a trac, and some old readmap&#8217;s that are fairly outdated. Looking at the <a href="http://varnish.projects.linpro.no/timeline">timeline</a> of the trac tells us that there indeed is activity, but it does not tell us anything about the current status of the project.</p>

<p>The same almost goes for <a href="http://www.lighttpd.net/">lighttpd</a>, but they have gotten a bit better at communicating their status. It even seems they are planning to do a <a href="http://blog.lighttpd.net/articles/2008/07/23/a-new-beginning">rewrite from the ground up</a> in lighttpd 2.0.</p>

<p>What I&#8217;d really like to have varnish and the various other projects do, is keep an updated trac. I really fail to see how this whould not do both the projects and the community some real good. And for varnish, I&#8217;m inclined to do it myself should I be given permission and knowledge to do so.</p>
]]></content:encoded>
			<wfw:commentRss>http://swag.dk/blog/2008/07/28/what-open-source-and-dentists-have-in-common/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 simple rules for café trips</title>
		<link>http://swag.dk/blog/2008/05/13/5-simple-rules-for-cafe-trips/</link>
		<comments>http://swag.dk/blog/2008/05/13/5-simple-rules-for-cafe-trips/#comments</comments>
		<pubDate>Tue, 13 May 2008 09:12:25 +0000</pubDate>
		<dc:creator>Mads Sülau Jørgensen</dc:creator>
				<category><![CDATA[Insanity]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[cafe]]></category>
		<category><![CDATA[coffee]]></category>
		<category><![CDATA[rules]]></category>

		<guid isPermaLink="false">http://swag.dk/blog/?p=19</guid>
		<description><![CDATA[So yestoday Seph, Rune and me went to work. Apparently i came at the exact right moment, as the first question I was met with was &#8220;Hey, we talked about going to the downstairs café for brunch. You in?&#8221;. Seeing &#8230; <a href="http://swag.dk/blog/2008/05/13/5-simple-rules-for-cafe-trips/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So yestoday <a href="http://www.mijav.dk/">Seph</a>, <a href="http://www.bromer.eu/">Rune</a> and me went to work. Apparently i came at the exact right moment, as the first question I was met with was &#8220;Hey, we talked about going to the downstairs café for brunch. You in?&#8221;.</p>

<p>Seeing as this is the thrid time we went down there in the last 3 weeks, we came up with a little ruleset for when we are allowed to ditch work, and have a relaxing cup of coffee.</p>

<p>Rules for café going for the <a href="http://www.coniuro.dk/">Coniuro</a> denmark office are:</p>

<ul>
<li>If it&#8217;s very hot outside</li>
<li>If it&#8217;s very cold outside</li>
<li>If it&#8217;s very windy outside</li>
<li>If it became a habbit</li>
<li>If it has been a while since the last time we went</li>
</ul>

<p>If any of the rules should become true, we are allowed to go.</p>

<p>Having an office in the center of copenhagen has it&#8217;s <a href="http://www.google.com/search?q=advantages" title="Who would have thought googling for that would yield a hit about sex">advantages</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://swag.dk/blog/2008/05/13/5-simple-rules-for-cafe-trips/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Stress a pigeon &#8211; the game</title>
		<link>http://swag.dk/blog/2008/03/20/stress-a-pigeon-the-game/</link>
		<comments>http://swag.dk/blog/2008/03/20/stress-a-pigeon-the-game/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 11:58:27 +0000</pubDate>
		<dc:creator>Mads Sülau Jørgensen</dc:creator>
				<category><![CDATA[Insanity]]></category>
		<category><![CDATA[Me]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://swag.dk/blog/2008/03/20/stress-a-pigeon-the-game/</guid>
		<description><![CDATA[Seeing as Copenhagen (the city where I live) has a whole lot of fat, lazy pigeons, what better to use them for, than a little game giving them exercise and entertainment for yourself. The pigeon&#8217;s of Copenhagen are quite lazy &#8230; <a href="http://swag.dk/blog/2008/03/20/stress-a-pigeon-the-game/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Seeing as Copenhagen (the city where I live) has a whole lot of fat, lazy pigeons, what better to use them for, than a little game giving them exercise and entertainment for yourself.</p>

<p>The pigeon&#8217;s of Copenhagen are quite lazy and probably won&#8217;t even move unless you are very close to stepping on them. You can easily walk very close to most of them, and you <i>could</i> hand feed them if you thought that was fun. I don&#8217;t. I&#8217;m more into stressing them.</p>

<p><span id="more-13"></span></p>

<h3>How to play</h3>

<p>The goal of the game is to make a pigeon take a long walk, the faster the better and the longer the better.</p>

<p>Rules are simple, 2 or more players can play at a time. It can be played by one self, but most people will just think you are an idiot, and probably give you money.</p>

<h3>Rules</h3>

<ul>
<li>No harming the little guy.</li>
<li>No throwing objects.</li>
<li>No interferring with the other players pigeon&#8217;s.</li>
<li>When the bird starts flying or stops walking, you loose.</li>
</ul>

<p>Now, go annoy some fat, lazy pigeon&#8217;s.</p>
]]></content:encoded>
			<wfw:commentRss>http://swag.dk/blog/2008/03/20/stress-a-pigeon-the-game/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
