<?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/"
	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>Alexey's Random Notes</title>
	<atom:link href="http://timanovsky.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://timanovsky.wordpress.com</link>
	<description>Random technical comments, hacking</description>
	<lastBuildDate>Mon, 31 Oct 2011 13:24:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='timanovsky.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Alexey's Random Notes</title>
		<link>http://timanovsky.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://timanovsky.wordpress.com/osd.xml" title="Alexey&#039;s Random Notes" />
	<atom:link rel='hub' href='http://timanovsky.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Enabling ARCHIVE storage engine in IUS MySQL 5.1</title>
		<link>http://timanovsky.wordpress.com/2010/10/09/enabling-archive-storage-engine-in-ius-mysql-5-1/</link>
		<comments>http://timanovsky.wordpress.com/2010/10/09/enabling-archive-storage-engine-in-ius-mysql-5-1/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 08:17:50 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[BI]]></category>
		<category><![CDATA[IUS repo]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=215</guid>
		<description><![CDATA[IUS is great repo which allows seamless integration of MySQL 5.1 and Python 2.6 into CentOS systems (which have 5.0 and 2.4 versions). The only issue is that if you run &#8216;SHOW ENGINES&#8217; it will only show you MRG_MYISAM, CSV, FEDERATED, InnoDB, MEMORY, MyISAM engines. I wanted to experiment with ARCHIVE storage engine for storing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=215&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://iuscommunity.org/">IUS</a> is great repo which allows seamless integration of MySQL 5.1 and Python 2.6 into CentOS systems (which have 5.0 and 2.4 versions). The only issue is that if you run &#8216;SHOW ENGINES&#8217; it will only show you MRG_MYISAM, CSV, FEDERATED, InnoDB, MEMORY, MyISAM engines. I wanted to experiment with ARCHIVE storage engine for storing raw input BI events, which is basically JSON. ARCHIVE engine seems to be a good hit for this &#8211; it supports compression (of our highly redundant data) and auto increment, which is necessary to implement queue-like processing, how it goes should be a topic for the separate post. So I was puzzled when I didn&#8217;t see archive storage engine in MySQL by IUS. Initial googling only suggested that ARCHIVE storage engine is enabled at compile time, which was pretty sad and I couldn&#8217;t understand why on the Earth had they omitted it. Later I found<a href="http://www.willis-owen.co.uk/wp/2010/01/ius-mysql-how-to-enable-the-archive-storage-engine/"> this post</a> suggesting that ARCHIVE storage engine can be installed as plugin, and I need to install separate YUM packages. Finding for those packages in the current repo gave no results. So I finally found <a href="https://answers.launchpad.net/ius/+question/127045">this bugreport</a> revealing taht a few plugins are actually installed as a part of mysql51-server package and you only need to enable it! So I went a head and<br />
<code><br />
mysql&gt; INSTALL PLUGIN archive SONAME 'ha_archive.so';<br />
Query OK, 0 rows affected (0.02 sec)<br />
</code><br />
And then<br />
<code><br />
mysql&gt; show engines \G</code></p>
<p><code> </code></p>
<p><code>*************************** 7. row ***************************<br />
Engine: ARCHIVE<br />
Support: YES<br />
Comment: Archive storage engine<br />
Transactions: NO<br />
XA: NO<br />
Savepoints: NO<br />
7 rows in set (0.00 sec)<br />
</code></p>
<p>Voila!</p>
<p>The following plugins are installed into the OS but not into MySQL:</p>
<p><code><br />
ha_archive.so - ARCHIVE<br />
ha_blackhole.so - BLACKHOLE<br />
ha_example.so - EXAMPLE<br />
ha_innodb_plugin.so - InnoDB Plugin<br />
</code></p>
<p>Enjoy!</p>
<p><strong>Update</strong>: Experiment on 24M rows shows 11X compression ratio! From 437 bytes/row in InnoDB (no indexes) down to 38 bytes per row.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/215/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/215/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/215/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/215/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/215/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/215/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/215/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/215/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/215/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/215/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/215/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/215/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/215/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/215/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=215&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2010/10/09/enabling-archive-storage-engine-in-ius-mysql-5-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>SSH: Convert OpenSSH to SSH2 and vise versa (via //burnz.blog)</title>
		<link>http://timanovsky.wordpress.com/2010/08/18/ssh-convert-openssh-to-ssh2-and-vise-versa-via-burnz-blog/</link>
		<comments>http://timanovsky.wordpress.com/2010/08/18/ssh-convert-openssh-to-ssh2-and-vise-versa-via-burnz-blog/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 13:47:02 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/2010/08/18/ssh-convert-openssh-to-ssh2-and-vise-versa-via-burnz-blog/</guid>
		<description><![CDATA[SSH2 format is used by windows PuTTY. If you need to migrate your SSH keys from windows to linux/ mac os, then this article is useful. Connecting two server running different type of SSH can be nightmare if you does not know how to convert the key. In this tutorial, I will try to explain [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=209&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>SSH2 format is used by windows PuTTY. If you need to migrate your SSH keys from windows to linux/ mac os, then this article is useful.</p>
<blockquote cite='http://burnz.wordpress.com/2007/12/14/ssh-convert-openssh-to-ssh2-and-vise-versa/' style='overflow:hidden;'><p><a href='http://burnz.wordpress.com/2007/12/14/ssh-convert-openssh-to-ssh2-and-vise-versa/' title='//burnz.blog'></a> Connecting two server running different type of SSH can be nightmare if you does not know how to convert the key. In this tutorial, I will try to explain on how to convert the public key from OpenSSH to SSH2 and SSH2 to OpenSSH. To convert the key, it must be done in OpenSSH server. Convert OpenSSH key to SSH2 key Run the OpenSSH version of ssh-keygen on your OpenSSH public key to convert it into the format needed by SSH2 on the remote machine. T &#8230; <a href='http://burnz.wordpress.com/2007/12/14/ssh-convert-openssh-to-ssh2-and-vise-versa/' title='//burnz.blog'>Read More</a></p>
</blockquote>
<p>via <a href='http://burnz.wordpress.com/2007/12/14/ssh-convert-openssh-to-ssh2-and-vise-versa/' title='//burnz.blog'>//burnz.blog</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/209/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=209&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2010/08/18/ssh-convert-openssh-to-ssh2-and-vise-versa-via-burnz-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>Some myths about H.264 vs Theora and their use in HTML5 video tag.</title>
		<link>http://timanovsky.wordpress.com/2010/05/02/some-myths-about-h-264-vs-theora/</link>
		<comments>http://timanovsky.wordpress.com/2010/05/02/some-myths-about-h-264-vs-theora/#comments</comments>
		<pubDate>Sun, 02 May 2010 19:26:29 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[h.264]]></category>
		<category><![CDATA[h264]]></category>
		<category><![CDATA[mpeg]]></category>
		<category><![CDATA[mpeg-la]]></category>
		<category><![CDATA[theora]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=191</guid>
		<description><![CDATA[I was planning to write this post some time ago, now I&#8217;ve got the last piece of puzzle [7]. Myth: H.264 &#8211; is proprietary codec, Theora &#8211; is open. Facts: H.264 &#8211; is open international standard ISO/IEC 14496-10 [8], there exist open/free reference code and several open source implementations. Theora &#8211; is nonstandard codec with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=191&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was planning to write this post some time ago, now I&#8217;ve got the last piece of puzzle [7]. </p>
<p><strong>Myth:</strong> H.264 &#8211; is proprietary codec, Theora &#8211; is open.<br />
<strong>Facts:</strong>  H.264 &#8211;  is open international standard ISO/IEC 14496-10 [8], there exist open/free reference code and several open source implementations. Theora &#8211; is nonstandard codec with unpredictable roadmap, distributed as open source [5].</p>
<p><strong>Myth:</strong> One have to pay royalties to use H.264 on web site<br />
<strong>Facts:</strong> No if your video content is free (i.e. you are not selling videos on title-by-title or subscription basis), at least till the end of 2015 [10]. This date has been moved several times, chances are it will be moved yet again. After that date one will have to pay $2500/year if service has less than half a million users; $5K &#8211;  if less than 1M users; $10K &#8211; over 1M users. The bill very reasonable even for startup. Additional protection is that license terms are fixed for five years, and royalties can not be increased by more than 10% at renewal. [4]</p>
<p><strong>Myth</strong>: One have to pay for H.264 encoding and decoding applications.One have to pay if using browser with H.264.<br />
<strong>Facts:</strong> Yes, each developer of H.264 encoding/decoding application or library has to pay  $0.20 for each copy sold. If you are an end user there is no grounds to worry, it is application developer/distributor responsibility to pay the royalties. Paid application have royalties already included. Free applications like IE, Safari, iTunes, Flash will obviously remain free, as corporations will wave those royalties for users. Moreover some of the SW companies are among H.264 licensors, so they probably have special conditions agreements and pay much less if anything. It is not clear, but companies like Mozilla, Firefox maker, may be among losers, as they don&#8217;t have a way to pay royalties if they are found to have to. [4]</p>
<p><strong>Myth</strong>: Theora &#8211; open source codec, therefore it could be no problems with patent infringement.<br />
<strong>Facts</strong>:  Video codecs (and audio too) is a knowledge area with extremely high patent density. Everything one can imagine has already been patented, that&#8217;s what millions bucks research budgets are spent for. So probability of Theora being patent-clear is zero. </p>
<p><strong>Myth:</strong>  On2 donated original (VP3) code which Theora is based on, and warranted no legal actions against anybody using it or its modifications. So no patent worries.<br />
<strong>Facts:</strong> A) There is only protection from On2 legal actions [6] B) Development of Theora went quite a bit from original VP3 code, so it now may infringe some patents unintentionally. C) There is no warranties that original VP3 technology does not violate third party patents including ones in H.264 patent pool.  D) Another fact to keep in mind, even obtaining MPEG-LA license does not warrant one is all covered, there could be other panets out of MPEG-LA pool [3]. E) We&#8217;ve got first confirmation that legal actions against Theora are possible &#8211; by Steve Jobs [7].</p>
<p><strong>Myth</strong>: With broad support for <code>Video</code> tag in browsers Flash Video will die.<br />
<strong>Facts:</strong> Not that soon.  <code>Video</code> tag provides way fewer controls to developer &#8211; e.g. no caching and buffer size control. Live streaming is not supported yet, and is not in roadmaps.</p>
<p><strong>Who is in which camp among SW giants?</strong><br />
<strong>Fact:</strong> Apple, Microsoft are among H.264 licensors pool; Adobe, Google are not. [2] Google seems to be trying to build its own video patent portfolio by acquiring On2 company [9].</p>
<p><strong>Why industry seems to like H.264 codec more than free open source solutions</strong>?<br />
This codec is now supported by Adobe Flash, MS Silverlight, Apple iTunes/QuickTime, it is supported by a lot of mobile phones, camcoders, digital television etc. And its support will become only wider. For all industry players it is very beneficial to have single universal standard codec, it allows for great technology reuse, simplifies and makes development cheaper, it benefits technology convergence. And after all it is just a very good codec delivering very good quality in wide bitrate ranges.</p>
<p><strong>Conclusion:</strong><br />
We will see major perturbations if Theora success starts threaten business of big guys.</p>
<p><strong>Update</strong><br />
1. Changed spelling to Firefox, as was required <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
2. Actually, H.264 use for free internet broadcast will remain royalty-free till the end of 2015 [10], as pointed out in<br />
3. One more good article: <a href="http://www.engadget.com/2010/05/04/know-your-rights-h-264-patent-licensing-and-you/">http://www.engadget.com/2010/05/04/know-your-rights-h-264-patent-licensing-and-you/</a></p>
<p><strong>Update 2</strong><br />
Another very good article on On2-Google VP8 now: <a href="http://x264dev.multimedia.cx/?p=377">http://x264dev.multimedia.cx/?p=377</a> It nicely describes overall quality of VP8 code, and patent issues with VP8 and MS&#8217;s VC-1. The later was also thought patent-free initially. </p>
<p><strong>References</strong><br />
1. H.264 page at MPEG LA site: <a href="http://www.mpegla.com/main/programs/AVC/Pages/Intro.aspx">http://www.mpegla.com/main/programs/AVC/Pages/Intro.aspx</a><br />
2. List of H.264 patent pool licensors &#8211; <a href="http://www.mpegla.com/main/programs/AVC/Pages/Licensors.aspx">http://www.mpegla.com/main/programs/AVC/Pages/Licensors.aspx</a><br />
3. MPEG LA FAQ  <a href="http://www.mpegla.com/main/programs/AVC/Pages/FAQ.aspx">http://www.mpegla.com/main/programs/AVC/Pages/FAQ.aspx</a><br />
4. Summary of H.264 license terms by MPEG LA &#8211; <a href="http://www.mpegla.com/main/programs/AVC/Documents/AVC_TermsSummary.pdf">http://www.mpegla.com/main/programs/AVC/Documents/AVC_TermsSummary.pdf</a><br />
5. Theora codec page: <a href="http://www.theora.org">http://www.theora.org</a><br />
6. On2 statement about VP3 license: <a href="http://svn.xiph.org/trunk/theora/LICENSE">http://svn.xiph.org/trunk/theora/LICENSE</a><br />
7. Apple prepares to go after open source codecs: <a href="http://blogs.fsfe.org/hugo/2010/04/open-letter-to-steve-jobs/">http://blogs.fsfe.org/hugo/2010/04/open-letter-to-steve-jobs/</a><br />
8. Official H.264 standard <a href="http://www.iso.org/iso/catalogue_detail.htm?csnumber=52974">http://www.iso.org/iso/catalogue_detail.htm?csnumber=52974</a><br />
9. Google acquires On2 Technologies &#8211; <a href="http://www.google.com/intl/en/press/pressrel/ir_20090805.html">http://www.google.com/intl/en/press/pressrel/ir_20090805.html</a><br />
10. H.264 will remain free for internet broadcast till end of 2015 <a href="http://www.mpegla.com/Lists/MPEG%20LA%20News%20List/Attachments/226/n-10-02-02.pdf">http://www.mpegla.com/Lists/MPEG%20LA%20News%20List/Attachments/226/n-10-02-02.pdf</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/191/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=191&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2010/05/02/some-myths-about-h-264-vs-theora/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>Fast IP-&gt;location resolution in SQL</title>
		<link>http://timanovsky.wordpress.com/2009/12/25/fast-ip-location-resolution-in-sql/</link>
		<comments>http://timanovsky.wordpress.com/2009/12/25/fast-ip-location-resolution-in-sql/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 11:59:35 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=187</guid>
		<description><![CDATA[Abstract Many web services nowadays rely on users&#8217; geo location information. It can be required purely for statistics purposes, or to add value to provided service itself. In most cases the only possible way to detect user location is to use IP address of originating request. IP addresses are not hierarchical in a geographical sense, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=187&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Abstract</strong><br />
Many web services nowadays rely on users&#8217; geo location information. It can be required purely for statistics purposes, or to add value to provided service itself. In most cases the only possible way to detect user location is to use IP address of originating request. IP addresses are not hierarchical in a geographical sense, large block of IP addresses is reserved to an ISP, and then broken down for smaller companies or individuals. There is no much order in the system. So a quick database is required in order to be able to make millions of lookups.</p>
<p><strong>Geo location data</strong><br />
Surely enough companies exist which provide such IP-based geo location data. <a href="http://www.maxmind.com/app/ip-location">Maxmind</a> is one of them. Fortunately they provide<a href="http://www.maxmind.com/app/geolitecountry"> free version</a> of their database under some legal constraints. There are other providers too, I&#8217;ve recently came across <a href="http://ipinfodb.com/ip_database.php">IpInfoDB</a>. So far so good, now we need a system to make use of the data.</p>
<p><strong>Physical database design</strong><br />
Data consists of (startIp, endIp, country) tuples. If IP address is in the range, it is originated from that country. There blind unassigned ranges, there are private ranges, and as said above multiple (very many) ranges map to a Country. In my table there is &gt; 100K distinct IP ranges.</p>
<p>Physical design in MySQL:<br />
<code>CREATE TABLE LookupIpToCountry (<br />
  startIp int(10) unsigned NOT NULL,<br />
  endIp int(10) unsigned NOT NULL,<br />
  countryId tinyint(3) unsigned NOT NULL,<br />
  PRIMARY KEY  (startIp),<br />
  KEY fk_countryId (countryId),<br />
  CONSTRAINT LookupIpToCountry_ibfk_1 FOREIGN KEY (countryId) REFERENCES Countries (id)<br />
) ENGINE=InnoDB;</code></p>
<p>Other database or engine can be used, provided that <code>startIp</code> is clustering index, i.e. data in the table is physically sorted according to startIp in ascending order.</p>
<p><strong>Fast lookup query</strong><br />
<code>mysql&gt; select * from LookupIpToCountry where startIp&lt;=INET_ATON('74.125.19.99') and endIp&gt;=INET_ATON('74.125.19.99')  order by startIp desc limit 1;<br />
+------------+------------+-----------+<br />
| startIp    | endIp      | countryId |<br />
+------------+------------+-----------+<br />
| 1249693272 | 1249773023 |       230 |<br />
+------------+------------+-----------+<br />
1 row in set (0.00 sec)</code></p>
<p>The idea here is to find the first region into which IP of interest falls. <code>SELECT ... WHERE startIp&lt;= X ... order by startIp desc</code> will navigate through B-tree index  to the last row satisfying <code>startIp</code> criterion and setup scan iterator in descending order. (Because it can only validate second condition  <code>endIp&gt;= X </code>by scanning). But the iteration ends immediately because of <code>LIMIT 1</code> if second condition is satisfied. So effectively whole query is reduced to B-tree lookup of one value. Of course, in case of the miss (IP address does not fall to any of known ranges), there is a performance hit:</p>
<p><code>mysql&gt; select * from LookupIpToCountry where startIp&lt;=INET_ATON('255.255.255.255') and endIp&gt;=INET_ATON('255.255.255.255')  order by startIp desc limit 1;<br />
Empty set (<strong>0.39 sec</strong>)</code></p>
<p>In order to fix it you can simplify the query to <code>select * from LookupIpToCountry where startIp&lt;=INET_ATON('255.255.255.255') order by startIp desc limit 1;</code> and check second condition <code>endIp&gt;=INET_ATON('255.255.255.255')</code> at application level, if you think it is worth.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=187&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2009/12/25/fast-ip-location-resolution-in-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>Solving performance problems in pub-sub erlang server</title>
		<link>http://timanovsky.wordpress.com/2009/08/20/solving-performance-problems-in-pub-sub-erlang-server/</link>
		<comments>http://timanovsky.wordpress.com/2009/08/20/solving-performance-problems-in-pub-sub-erlang-server/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 20:15:22 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[long polling]]></category>
		<category><![CDATA[mochiweb]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[pub-sub]]></category>
		<category><![CDATA[TCP]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=133</guid>
		<description><![CDATA[Intro So I wrote (see some prehistory here) a kind of notification server where clients can subscribe to events and be notified when event of interest happens. Clients use HTTP long poll method to get notifications delivered, and one of the application of the server is chat room. Symptoms In my case there were two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=133&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Intro</strong><br />
So I wrote (see some prehistory <a href="http://timanovsky.wordpress.com/2009/01/09/toward-a-million-user-long-poll-http-application-nginx-erlang-mochiweb/">here</a>) a kind of notification server where clients can subscribe to events and be notified when event of interest happens.  Clients use HTTP long poll method to get notifications delivered, and one of the application of the server is chat room.</p>
<p><strong>Symptoms</strong><br />
In my case there were two problems:</p>
<ol>
<li>general lack of performance (I started optimizing somewhere from 200-300 messages per second)</li>
<li>under high load server would lock up, sometimes for extended period of time &#8211; it does not deliver any messages</li>
<li>even under moderate load performance is not stable and would drop eventually for some period of time (sometimes to complete lock up, sometimes not, sometimes for a couple of seconds, sometimes for longer time).</li>
<li>In-depth investigation with tcpdump has shown that server can not even accept connections.</li>
</ol>
<p><strong>Side note on server not accepting tcp connections</strong><br />
That is interesting how it happens though. I don&#8217;t know if it is specific Linux 2.6 behavior of it is a norm, but the sequence is:</p>
<ol>
<li>client sends SYN</li>
<li>server responds with ACK, but acknowledgment number set to some arbitrary big number</li>
<li>client drops connection by sending RST</li>
</ol>
<p>So should you see similar behavior note that this is just a symptom, not disease. The problem is somewhere dipper. In my case increasing TCP listen backlog from mochiweb&#8217;s default 30 helped a bit, fewer timeouts were observed, but still performance sucked.</p>
<p><strong>Fixing Root Cause</strong><br />
So how pub-sub servers in Erlang are generally built? You get a message being processed in some process, it might have been received from somewhere else or originates from this process . And then you have bunch of waiting processes representing connected subscribed clients waiting for a message be delivered. Each of these processes normally represents TCP connection or in my case HTTP long polling connection. And delivering message to this process releases it from wait state and allows message to be delivered to end user. There is of course some router module or process which determines a subset of processes (PIDs) to which the message should be delivered. How to do efficiently is very interesting topic but not for this post. Then you do something like<br />
<strong><code>lists:foreach(fun(Pid) -&gt; send_message(Pid, Message) end, PidList)</code></strong></p>
<p>The result of this is that each of processes from the target group (selected by router) becomes immediately available for execution. And if the group size is big, chances are that current process broadcasting this notifications will be preempted. And the thing is that this actually causes context switching storm. I&#8217;m not 100% sure how Erlang runtime is implemented, but it seems that if process receives a message it gets some kind of priority and is scheduled for execution, like it happens in some OSes. So the message sending loop may take quite awhile.</p>
<p>Now, if the message broadcast loop is more complex, say it consists of two nested loops, and inside it you do some non trivial operations followed by sending the message for one particular PID, then the things become very bad. Context switching overhead no matter how light it is in Erlang kills your performance.</p>
<p><strong>Recipe</strong></p>
<ol>
<li>If you have complex loops to calculate to which PID send the message, and you do message sending inside that loop &#8211; rewrite the code. First prepare list of PIDs using whatever complex procedures you have, then send messages to those PIDs in one shot.</li>
<li>Then sending messages to bunch of PIDs do temporarily boost performance of your thread so it won&#8217;t be preempted.</li>
</ol>
<p>Example:<br />
<strong><code><br />
PidList = generate_pid_list(WhatEver),<br />
OldPri = process_flag(priority, high),  % Raise priority, save old one<br />
lists:foreach(fun({Pid, Msg}) -&gt; send_message(Pid, Msg) end, PidList),<br />
process_flag(priority, OldPri)<br />
</code><br />
</strong><br />
That&#8217;s basically it. The result is that now I&#8217;m reliably achieving about 1.5k messages/sec with all stuff like HTTP/JSON parsing, ETS operations, logging, etc. I would like to pump this number few times higher, but at the moment that&#8217;s what I can get. I will come back when learn something new <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>PS. You may also find this discussion followed $1000 code challenge useful:<br />
<a href="http://groups.google.com/group/erlang-programming/browse_thread/thread/1931368998000836/b325e869a3eea26a">http://groups.google.com/group/erlang-programming/browse_thread/thread/1931368998000836/b325e869a3eea26a</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=133&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2009/08/20/solving-performance-problems-in-pub-sub-erlang-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>Fix Eclipse Config to Start with Broken Perspective</title>
		<link>http://timanovsky.wordpress.com/2009/08/13/fix-eclipse-config-to-start-with-broken-perspective/</link>
		<comments>http://timanovsky.wordpress.com/2009/08/13/fix-eclipse-config-to-start-with-broken-perspective/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 10:10:16 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=129</guid>
		<description><![CDATA[I happened to switch to Ruby Browsing Perspective in Eclipse eventually, for whatever reason it crashed Eclipse with Out of Memory exception. When I try to restart it won&#8217;t, because it tries to load all the same Perspective. The solution is to edit one of Eclipse config files. The file of interest is "workspace/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml" (in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=129&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I happened to switch to Ruby Browsing Perspective in Eclipse eventually, for whatever reason it crashed Eclipse with Out of Memory exception. When I try to restart it won&#8217;t, because it tries to load all the same Perspective. The solution is to edit one of Eclipse config files. The file of interest is <code>"workspace/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml"</code> (in my case on Mac it is ~Documents/workspace/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml)</p>
<p>The default perspective is configured by the following directive:<br />
<code>&lt;perspectives activePart="org.rubypeople.rdt.ui.EditorRubyFile"<strong> activePerspective="org.rubypeople.rdt.ui.RubyBrowsingPerspective"</strong>&gt;</code></p>
<p>So what I had to do is replace <code>org.rubypeople.rdt.ui.RubyBrowsingPerspective</code> with <code>org.eclipse.jdt.ui.JavaPerspective</code></p>
<p>You can find for exact class names of available perspectives in the same file. Perspective declaration looks like:<br />
<code><br />
&lt;perspective editorAreaTrimState="2" editorAreaVisible="1" fixed="0" version="0.016"&gt;<br />
&lt;descriptor class="org.eclipse.jdt.internal.ui.JavaPerspectiveFactory" <strong>id="org.eclipse.jdt.ui.JavaPerspective" </strong>label="Java"/&gt;<br />
...<br />
</code><br />
First line is opening of perspective declaration, and &lt;descriptor&gt; tag contains id attribute which is what you want. If you search trough <code>workbench.xml</code> you will find all available perspective names.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=129&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2009/08/13/fix-eclipse-config-to-start-with-broken-perspective/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>Tuning Linux firewall connection tracker ip_conntrack</title>
		<link>http://timanovsky.wordpress.com/2009/04/10/tuning-linux-firewall-connection-tracker-ip_conntrack/</link>
		<comments>http://timanovsky.wordpress.com/2009/04/10/tuning-linux-firewall-connection-tracker-ip_conntrack/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 15:16:14 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[conntrack]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=117</guid>
		<description><![CDATA[Overview If your Linux server should handle lots of connections, you can get into the problem with ip_conntrack iptables module. It limits number of simultaneous connections your system can have. Default value (in CentOS and most other distros) is 65536. To check how many entries in the conntrack table are occupied at the moment: cat [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=117&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Overview</strong><br />
If your Linux server should handle lots of connections, you can get into the problem with ip_conntrack iptables module. It limits number of simultaneous connections your system can have. Default value (in CentOS and most other distros) is 65536.</p>
<p>To check how many entries in the conntrack table are occupied at the moment:<br />
<code><br />
cat /proc/sys/net/ipv4/netfilter/ip_conntrack_count<br />
</code><br />
Or you can dump whole table :<br />
<code><br />
cat /proc/net/ip_conntrack<br />
</code></p>
<p>Conntrack table is hash table (hash map) of fixed size (8192 entries by default), which is used for primary lookup. When the slot in the table is found it points to list of conntrack structures, so secondary lookup is done using list traversal. 65536/8192 gives 8 &#8211; the average list length.  You may want to experiment with this value on heavily loaded systems.</p>
<p><strong>Modifying conntrack capacity</strong><br />
To see the current conntrack capacity:<br />
<code><br />
cat /proc/sys/net/ipv4/netfilter/ip_conntrack_max<br />
</code><br />
You can modify it by echoing new value there:<br />
<code><br />
# echo 131072 &gt; /proc/sys/net/ipv4/netfilter/ip_conntrack_max<br />
# cat /proc/sys/net/ipv4/netfilter/ip_conntrack_max<br />
131072<br />
</code><br />
Changes are immediate, but temporary &#8211; will not survive reboot.</p>
<p><strong>Modifying number of buckets in the hash table</strong><br />
As mentioned above just changing this parameter will give you some relief, if your server was at the cap, but it is not ideal setup. For 1M connections average list becomes 1048576 / 8192 = 128, which is a bit too much.</p>
<p>To see current size of hash table:<br />
<code><br />
cat /proc/sys/net/ipv4/netfilter/ip_conntrack_buckets<br />
</code><br />
which is read-only aliase for module parameter:<br />
<code><br />
cat /sys/module/ip_conntrack/parameters/hashsize<br />
</code><br />
You can change it on the fly as well:<br />
<code><br />
#echo 32768 &gt; /sys/module/ip_conntrack/parameters/hashsize<br />
# cat /sys/module/ip_conntrack/parameters/hashsize<br />
32768<br />
</code></p>
<p><strong>Persisting the changes</strong><br />
Making these changes persistent is a bit tricky.<br />
For total number of connection just edit <code>/etc/sysctl.conf</code> (CentOs, Redhat etc) and you are done:<br />
<code><br />
# conntrack limits<br />
net.ipv4.netfilter.ip_conntrack_max = 131072<br />
</code></p>
<p>Not so easy with hashtable size. You need to pass parameters to kerenl module at boot time. Edit add to <code>/etc/modprobe.conf</code>:<br />
<code><br />
options ip_conntrack hashsize=32768<br />
</code> </p>
<p><strong>Memory usage</strong><br />
You can find how much kernel memory each conntrack entry occupies by grepping /var/log/messages :<br />
<code><br />
ip_conntrack version 2.4 (8192 buckets, 65536 max) - 304 bytes per conntrack<br />
</code><br />
1M connections would require 304MB of kernel memory.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=117&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2009/04/10/tuning-linux-firewall-connection-tracker-ip_conntrack/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>Get Unix timestamp in Java, Python, Erlang</title>
		<link>http://timanovsky.wordpress.com/2009/04/09/get-unix-timestamp-in-java-python-erlang/</link>
		<comments>http://timanovsky.wordpress.com/2009/04/09/get-unix-timestamp-in-java-python-erlang/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 07:42:20 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=112</guid>
		<description><![CDATA[Mostly a note for myself. To Get Unix timestamp value in seconds java: long timestamp = System.currentTimeMillis()/1000 Python: import time timestamp = int(time.time()) Erlang: {Mega, Secs, _} = now(), Timestamp = Mega*1000000 + Secs, Working with timestamps in MySQL mysql&#62; SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00'); -&#62; 875996580 mysql&#62; SELECT FROM_UNIXTIME(1111885200); +---------------------------+ &#124; FROM_UNIXTIME(1111885200) &#124; +---------------------------+ &#124; 2005-03-27 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=112&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Mostly a note for myself. To Get Unix timestamp value in seconds</p>
<p><strong>java:</strong><br />
<code><br />
long timestamp = System.currentTimeMillis()/1000<br />
</code></p>
<p><strong>Python:</strong><br />
<code><br />
import time<br />
timestamp = int(time.time())<br />
</code></p>
<p><strong>Erlang:</strong><br />
<code><br />
{Mega, Secs, _} = now(),<br />
Timestamp = Mega*1000000 + Secs,<br />
</code></p>
<p><strong>Working with timestamps in MySQL</strong><br />
<code><br />
mysql&gt; SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00');<br />
-&gt; 875996580<br />
mysql&gt; SELECT FROM_UNIXTIME(1111885200);<br />
+---------------------------+<br />
| FROM_UNIXTIME(1111885200)   |<br />
+---------------------------+<br />
| 2005-03-27 03:00:00                |<br />
+---------------------------+<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=112&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2009/04/09/get-unix-timestamp-in-java-python-erlang/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>Solution for Erlide hangs Eclipse problem</title>
		<link>http://timanovsky.wordpress.com/2009/03/30/solution-for-erlide-hangs-eclipse-prolem/</link>
		<comments>http://timanovsky.wordpress.com/2009/03/30/solution-for-erlide-hangs-eclipse-prolem/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 18:46:20 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=104</guid>
		<description><![CDATA[If you are using Erlide to develop Erlang applications you may sooner or later find yourself in a situation than IDE just hangs completely whenever you try to access any Erlide functions. You can not even go to Erlide section of Eclipse Preferences ! This seems to be a kind of mystery, at least googling [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=104&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are using Erlide to develop Erlang applications you may sooner or later find yourself in a situation than IDE just hangs completely whenever you try to access any Erlide functions. You can not even go to Erlide section of Eclipse Preferences ! This seems to be a kind of mystery, at least googling didn&#8217;t reveal any helpful information except hinting that problem could be due to backend connection issues. As far as I understand, backend is erlang compiler/toolchain used by Erlide. I can imagine it is used when compiling, or when doing syntax check, but why it hangs in editor and preferences dialog?! </p>
<p>I was able to find Erlide logfile (~/Document/workspace_erlide.log under MacOS) And it suggested that Erlide was running in dead loop trying to invoke external Erlang.  In particualr it complained about that the following command were failing with result code 126:<br />
<code>/opt/local/var/macports/software/erlang/R12B-3_2/opt/local/lib/erlang//bin/erl    -name f0a30ba_erlide@alexey-timanovskys-macbook-pro.local -setcookie erlide<br />
</code>.  When I tried to execute it from command line I got errors from erlang. Then I discovered that I have two installations of erlang &#8211; R12B 3.2 and 5.0, obviously I used macports to upgrade to most recent one, but it  kept previous version too. And erlide was configured to use old erlang setup which didn&#8217;t work for whatever reason. So the next step was to find where it is configured, I grepped and found it in<br />
<code>~Documents/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.erlide.core.prefs</code><br />
I replaced line<br />
<code><br />
runtimes/erlang/homeDir=/opt/local/var/macports/software/erlang/R12B-3_2/opt/local/lib/erlang/<br />
</code> with<br />
<code><br />
runtimes/erlang/homeDir=/opt/local/lib/erlang/<br />
</code><br />
and restarted Eclipse. It worked!</p>
<p>So be careful, breaking anything in erlang configuration will not allow you to use Erlide, you can&#8217;t even go to preferences and change erlang home directory to correct one.</p>
<p>I&#8217;m using Eclipse 3.4.1 and tried Erlide versions  0.5.0 and 0.5.1. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=104&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2009/03/30/solution-for-erlide-hangs-eclipse-prolem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
		<item>
		<title>How to produce hex array from binary data</title>
		<link>http://timanovsky.wordpress.com/2009/03/17/how-to-produce-hex-array-from-binary-data/</link>
		<comments>http://timanovsky.wordpress.com/2009/03/17/how-to-produce-hex-array-from-binary-data/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 16:50:55 +0000</pubDate>
		<dc:creator>Alexey Timanovsky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[hexdump]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://timanovsky.wordpress.com/?p=98</guid>
		<description><![CDATA[Suppose you have a binary file you want to include as byte array into C/C++/Java program. Here how you can generate it (just add opening and closing braces and clean some garbage at the end) hexdump -v -e " 16/1 \"0x%02X, \" \"\n\"" Something like the following will be produced: 0x7F, 0xFE, 0xF9, 0xE7, 0x9F, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=98&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Suppose you have a binary file you want to include as byte array into C/C++/Java program. Here how you can generate it (just add opening and closing braces and clean some garbage at the end)</p>
<p><code>hexdump -v -e " 16/1 \"0x%02X, \" \"\n\"" </code></p>
<p>Something like the following will be produced:</p>
<p><code><br />
0x7F, 0xFE, 0xF9, 0xE7, 0x9F, 0x7F, 0xFE, 0xF9, 0xE7, 0x9F, 0x7F, 0xFE, 0xF9, 0xE7, 0x9F, 0x7F,<br />
0xFE, 0xF9, 0xE7, 0x9F, 0x7F, 0xFE, 0x0F, 0xFD, 0x3F, 0x4F, 0xAC, 0x0A, 0xA2, 0x00, 0xB0, 0x94,<br />
0x01, 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  , 0x  ,<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/timanovsky.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/timanovsky.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/timanovsky.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/timanovsky.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/timanovsky.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/timanovsky.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/timanovsky.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/timanovsky.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/timanovsky.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/timanovsky.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/timanovsky.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/timanovsky.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/timanovsky.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/timanovsky.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=timanovsky.wordpress.com&amp;blog=5831516&amp;post=98&amp;subd=timanovsky&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://timanovsky.wordpress.com/2009/03/17/how-to-produce-hex-array-from-binary-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14d4d2c02acf61f5532588e30de4bf23?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timanovsky</media:title>
		</media:content>
	</item>
	</channel>
</rss>
