<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Ask Bjørn Hansen</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/" />
    <link rel="self" type="application/atom+xml" href="http://www.askbjoernhansen.com/atom-feedburner-2.xml" />
    <id>tag:www.askbjoernhansen.com,2008-02-24://1</id>
    <updated>2008-05-17T00:22:46Z</updated>
    <subtitle>It can be important to have waited at least a moment to see what was already there.</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Open Source 4.11</generator>

<entry>
    <title>JavaScript: The Good Parts</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/05/16/javascript_the_good_parts.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.2082</id>

    <published>2008-05-17T00:11:37Z</published>
    <updated>2008-05-17T00:22:46Z</updated>

    <summary>Douglas Crockford of JSON fame has written a beautiful book about JavaScript. First of all - at only 170 pages it is short. Even though some of the key points are repeated through the book it&apos;s dense with information. You don&apos;t need any JavaScript experience, but it&apos;s not a &quot;beginning programming&quot; book so if you haven&apos;t been programming before this is not the right book for you. Reading this book a couple of times will give you an appreciation for...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.amazon.com/o/ASIN/0596517742/webchic-20"><img alt="javascript_cover" src="http://www.askbjoernhansen.com/images/2008/05/javascript_cover.jpg" width="240" height="240" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a></span>Douglas Crockford of <a href="http://www.json.org/">JSON</a> fame has written a <a href="http://www.amazon.com/o/ASIN/0596517742/webchic-20">beautiful book about  JavaScript</a>.</p>

<p>First of all - at only 170 pages it is short. Even though some of the key points are repeated through the book it's dense with information. You don't need any JavaScript experience, but it's not a "beginning programming" book so if you haven't been programming before this is not the right book for you. </p>

<p>Reading this book a couple of times will give you an appreciation for the JavaScript language that you almost certainly didn't have before. It'll give you tools to write better programs that you and others will actually be able to maintain over time. </p>

<p>I've learned lots of little things that I maybe knew from experience, but now I <em>know</em> and I know why. </p>

<p>This book will help you battle with JavaScript rather than against it.</p>

<p>(this review was also <a href="http://www.amazon.com/review/R2XPWE2CEP5FAN/ref=cm_cr_rdp_perm">posted on amazon.com</a>)</p>

<p>After reading half the book I went and bought a bunch of extra copies and had them sent to people I work with who are working with JavaScript.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Slides from &quot;Real World Web: Performance &amp; Scalability, MySQL Edition&quot;</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/04/15/real_world_web_performance_scalability_slides.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.2022</id>

    <published>2008-04-15T19:27:13Z</published>
    <updated>2008-04-15T21:05:59Z</updated>

    <summary>The slides from my tutorial yesterday are up at develooper.com. 189 slides this year! A handful of people have told me today (and more yesterday obviously) that they learned a lot and got new ideas for how to build things - yay! I&#8217;m considering putting up a version of the slides with sound. Would anyone want a 3 hour quicktime movie of that? Well, maybe split up into smaller bits, but you get the idea. You wouldn&#8217;t get the hand...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="conferences" label="conferences" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mysql" label="mysql" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="scalability" label="scalability" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="tutorial" label="tutorial" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p><a href="http://www.flickr.com/photos/x180/2415106176/"><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="mysql_audience.jpg" src="http://www.askbjoernhansen.com/images/2008/04/mysql_audience.jpg" width="500" height="332" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></span></a>The slides from my tutorial yesterday are up at <a href="http://develooper.com/talks/">develooper.com</a>.  189 slides this year!   A handful of people have told me today (and more yesterday obviously) that they learned a lot and got new ideas for how to build things - yay!</p>

<p>I&#8217;m considering putting up a version of the slides with sound.  Would anyone want a 3 hour quicktime movie of that?</p>

<p>Well, maybe split up into smaller bits, but you get the idea.  You wouldn&#8217;t get the <a href="http://www.flickr.com/photos/x180/2414281659/">hand</a> <a href="http://www.flickr.com/photos/x180/2414281577/">waving</a>, but you would get a bunch more detail, obviously.</p>

<p>I actually had audio recorded, but I haven&#8217;t checked how it came out, yet, and I&#8217;d have to make a synchronized movie version of the slides (and likely be tempted to just redo the audio anyway).  Thoughts?  Would it be a worthwhile effort?</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Dash Express: Living in the future</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/04/13/dash_express_living_in_the_future.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.2020</id>

    <published>2008-04-13T15:12:34Z</published>
    <updated>2008-04-13T06:22:00Z</updated>

    <summary>Nelson mentioned the marvel of checking traffic on the iPhone. Nelson, I&apos;m sorry - that&apos;s so last months future. Freeway traffic flows? Boring! I&apos;ve only driven about 5000 miles the last year, and almost none of it were on freeways. A couple weeks ago I ordered a Dash Express. Let me tell you: that is the future. The essence of the Dash is that it tracks your speed as your drive and uploads it to the Dash servers (anonymously, supposedly...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="dash" label="dash" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gps" label="GPS" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="navigation" label="navigation" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="Dash Express" src="http://www.askbjoernhansen.com/images/2008/04/de_ondash_3route_270px.jpg" width="270" height="270" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></span>Nelson mentioned the marvel of <a href="http://www.somebits.com/weblog/tech/iphone/maps-and-traffic.html">checking traffic on the iPhone</a>.  Nelson, I'm sorry - that's so last months future.  Freeway traffic flows?  Boring!  I've only driven about 5000 miles the last year, and almost none of it were on freeways.</p>

<p>A couple weeks ago I ordered a <a href="http://dash.net/">Dash Express</a>.  Let me tell you: <em>that</em> is the future.   The essence of the Dash is that it tracks your speed as your drive and uploads it to the Dash servers (anonymously, supposedly - they don't explain what they do to keep it that way) <em>as you drive</em>.  Of course it also downloads traffic data from other drivers and historical data when no Dash owner has driven on a particular street recently.</p>

<p>It is so cool to watch.   Entirely accurate?  Not yet.  Pretty darn good already?  Check.  A glimmer of the future?  Definitely.</p>

<p>The Dash has wifi, but most of the time it uses GPRS for communication via <a href="http://www.jasperwireless.com/">Jasper Wireless</a>.  As a user you don't know that or even care, but as a geek it was fun to find out that there's a wireless carrier that doesn't do anything else than GPRS for mobile gadgets.</p>

<p>Since it's always connected they have built in local search via Yahoo local (not as good as <a href="http://www.yellowbot.com/">YellowBot</a>, of course, but pretty neat all the same ;-) ).  They're working on giving you more "online data".  For example there are gas prices and movie showtimes available, but the UI for that isn't very useful.</p>

<p>Dash are suggesting that the Dash Express will be the first GPS for "daily use" rather than just to be used when you are going somewhere new.  it <a href="http://dash.net/product/traffic-routing.php">suggests multiple routes</a> with distance and time based on current traffic.  Pretty darn neat; but as I mentioned earlier - at least for my short-ish city-only stretches it's still not entirely accurate.  I'm sure they'll improve on it though.  The wonder of automatic software updates and constantly improved traffic data.  I've noticed a big improvement in available traffic information just over the last two weeks since they started selling units to non-beta testers.</p>

<p>So to get better data it is of course in my interest to tell you to go <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FDash-Express-Internet-Connected-Portable-Navigator%2Fdp%2FB0014CIBWC%3Fie%3DUTF8%26s%3Delectronics%26qid%3D1208066139%26sr%3D8-1&amp;tag=webchic-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=932">buy one</a>.   In particular if you live in Los Angeles.  :-)</p>

<p>If you are driving a lot and a lot to new places where you don't know the regular flow of traffic then I'm sure it's worth getting the first generation unit.</p>

<p>However, there's a lot to improve before I'm going to recommend it to "regular drivers" and non-early-adopter types.  The physical form factor is, well, not really sleek.  It's GIGANTIC compared to a modern <a href="http://www.amazon.com/gp/search?ie=UTF8&amp;keywords=Garmin%20Nuvi&amp;tag=develooper&amp;index=blended&amp;linkCode=ur2&amp;camp=1789&amp;creative=9325">Garmin Nuvi</a><img src="http://www.assoc-amazon.com/e/ir?t=develooper&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />.  They say it's to have room for the wifi and GPRS antennas (huh? The iPhone fits both a fraction of the space) and for the battery (which still only lasts a couple of hours; keep that 12v outlet available).  The screen is a well working touch-screen, but the "hardware buttons" on top are crazy annoying when it's not mounted in the window or on the dash board.</p>

<p>Speaking of the screen - My first unit had a slightly defective screen, but Dash were great about getting it fixed and I could see that they had already improved their process on the replacement unit so it won't be an issue again.  My second unit has been flawless so far.</p>

<p>Other than the issues mentioned above, it's mostly software improvements that are missing and those will hopefully be updated over time.  It's done a bad job telling us a quick sequence of directions on freeways.  It doesn't zoom in to show how clearly to navigate intersections or freeway interchanges.  The UI is somewhat inconsistent (for example some buttons disappear when not usable, others stay on the screen and just "don't work").  It seems very slow at updating the screen at times.  As I mentioned above the UI needs some work for some of the features to work better. Etc etc.</p>

<p>All that being said though - if you are in the market for a new GPS, give it a serious look.  It's lots of fun and I trust the software will get better month for month.  It will be interesting to see if or when Garmin catches up with the traffic data system or if one of the big players just goes and buys Dash.   A device built with the Dash traffic data and with Garmins long UI, navigation and hardware expertise: <em>drool</em>.  I guess if the Dash is the future; then that device is the future of the future.</p>

<p>Dash has a great <a href="http://dash.net/help.php">help section</a> that answers lots of questions in addition to their <a href="http://dash.net/product/traffic.php">general feature overview</a>.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Tax season</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/04/12/tax_season.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.2018</id>

    <published>2008-04-13T03:35:18Z</published>
    <updated>2008-04-13T03:25:40Z</updated>

    <summary>I was preparing to do our taxes last week. Every year in late March or early April I realize that there&apos;s an account or two (or three) that I never got around to reconcile or maybe even download activity for, so lots of tedious work ensues. Vani&apos;s been scanning lots and lots of documents into PDF files; I can&apos;t recommend getting a scanner enough. I use QuickBooks for my corporate accounting and like I only sheepishly admit that I really...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
        <category term="Technology" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>I was preparing to do our taxes last week.  Every year in late March or early April I realize that there's an account or two (or three) that I never got around to reconcile or maybe even download activity for, so lots of tedious work ensues.</p>

<ul>
<li><p>Vani's been scanning lots and lots of documents into PDF files; I can't recommend getting a <a href="http://www.amazon.com/o/ASIN/B000WJCX18/webchic-20">scanner</a> enough.</p></li>
<li><p>I use QuickBooks for my <a href="http://develooper.com">corporate</a> accounting and like I only sheepishly admit that I really like the new Radiohead album I'm also reluctant to admit that QuickBooks works pretty darn well for me.</p></li>
<li><p>Personal finance software though.  Geez.  Is <a href="http://moneydance.com/">Moneydance</a> really the leading Quicken alternative?  I tried it briefly and it seemed even more painful to use and I use a ~3 year old Mac version of Quicken!</p></li>
<li><p>Some of the banks are really awesome with letting you download activity from a long time back and having the statements in easily downloaded PDF files.  Bank of America (who I otherwise generally loathe) and American Express are in this category.  Chase (Amazon Visa) are notoriously not.  Oh man, don't get me started on Chase.</p></li>
</ul>
]]>
        

    </content>
</entry>

<entry>
    <title>Reclaim space from a sparse OS X disk image</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/03/25/reclaim_space_from_the_idisk_diskimage.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.1833</id>

    <published>2008-03-26T00:42:43Z</published>
    <updated>2008-03-26T00:43:04Z</updated>

    <summary>In 10.5 and 10.5.1 there was a bug that&#8217;d make my iDisk explode to take all available space, yikes. Fortunately that has been fixed now (not that I use the iDisk much anymore - hello JungleDisk!). It doesn&#8217;t seem like the iDisk disk images get compacted automatically to take less space if you delete files, so what I learned from the bug is generally useful. You can compact a &#8220;sparse&#8221; disk image manually from the Terminal application. The iDisk can&#8217;t...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="osx" label="os x" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>In 10.5 and 10.5.1 there was a bug that&#8217;d make my <a href="http://www.apple.com/dotmac/idisk.html">iDisk</a> explode to take all available space, yikes.  Fortunately that has been fixed now (not that I use the iDisk much anymore - hello <a href="http://www.jungledisk.com/">JungleDisk</a>!).</p>

<p>It doesn&#8217;t seem like the iDisk disk images get compacted automatically to take less space if you delete files, so what I learned from the bug is generally useful.</p>

<p>You can compact a &#8220;sparse&#8221; disk image manually from the Terminal application.</p>

<p>The iDisk can&#8217;t be in use, so close any files opened on it.  Then open a terminal and run:</p>

<pre><code>hdiutil unmount ~/Library/FileSync/*/*.sparsebundle
hdiutil compact ~/Library/FileSync/*/*.sparsebundle
</code></pre>

<p>The <code>hdiutil compact</code> feature also works on old fashioned sparse disk images (all data in one file versus the &#8220;sparsebundles&#8221; that are really directories with lots of smaller files).  I used it to reclaim a few gigabytes from some old disk images, yay.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>MySQL conference tutorial almost sold out</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/03/06/mysql_conference_tutorial_almost_sold_out.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.1956</id>

    <published>2008-03-07T01:25:04Z</published>
    <updated>2008-03-07T01:27:54Z</updated>

    <summary>It looks like my tutorial is almost sold out (and so are several of the others already!) So if you&apos;re planning to go to the MySQL conference, don&apos;t delay - go sign up!...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="conferences" label="conferences" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mysql" label="mysql" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>It looks like <a href="http://www.askbjoernhansen.com/2008/02/14/real_world_web_scalability_mysql.html">my tutorial</a> is <a href="http://www.jpipes.com/index.php?/archives/217-Register-for-MySQL-Conference-and-Expo-Tutorials-Are-Selling-or-Sold-Out.html">almost sold out</a> (and so are several of the others already!)</p>

<p>So if you're planning to go to the <a href="http://en.oreilly.com/mysql2008">MySQL conference</a>, don't delay - go sign up!</p>]]>
        
    </content>
</entry>

<entry>
    <title>Servers are too fast!</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/03/04/servers_are_too_fast.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.1952</id>

    <published>2008-03-04T23:44:29Z</published>
    <updated>2008-03-05T00:31:11Z</updated>

    <summary>We got a couple of new servers at Solfo recently which showed me one of the reasons virtualization is so popular now: Servers are too fast! The &quot;standard issue&quot; CPU is now a quad-2.5GHz CPU, so in each server we have 20 GHZ CPU and 32GB ram (at less than $50 per gigabyte it&apos;s too cheap to not just fill it up and be done upgrading). Just a few years ago the CPUs we were getting were &quot;only&quot; dual 2GHz,...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="intel" label="intel" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="scalability" label="scalability" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="servers" label="servers" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>We got a couple of new servers at <a href="http://www.solfo.com/">Solfo</a> recently which showed me one of the reasons virtualization is so popular now: Servers are too fast!</p>

<p>The "standard issue" CPU is now a quad-2.5GHz CPU, so in each server we have <em>20 GHZ</em> CPU and 32GB ram (at less than $50 per gigabyte it's too cheap to not just fill it up and be done upgrading).  Just a few years ago the CPUs we were getting were "only" dual 2GHz, for ~8GHz CPU per box.  That's a big increase!</p>

<p>In each "tier" of the application (app servers, db servers, search servers) our main reason for having more than one or two servers is redundancy / high availability - never lack of CPU and rarely because we need more memory.</p>

<p>Here's from one of our webservers (virtualized with Xen with 6 of the 8 CPUs on the "real" hardware).</p>

<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="cpu-year.png" src="http://www.askbjoernhansen.com/images/2008/03/cpu-year.png" width="495" height="336" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></span></p>

<p>The big exception is the MySQL servers where we get constrained by I/O so we need a single chassis with lots of disks (the $$ version would be to get external enclosures or SAN boxes with disks) and of course in the MySQL servers we can easily use all 32GB ram.</p>

<p>Anyway, the conclusion: Please give us cheaper, lower power CPUs.   More memory, sure - we'll figure out to use it.  More disk I/O: yes, please!  More more more!  Faster CPUs makes sense at scale, of course, but for a <a href="http://www.yellowbot.com/">smaller website</a> with just a handful of million visitors a month we just can't make a dent in the available CPU.  Maybe if we used Ruby instead of Perl.  ;-)   (just kidding).</p>

<p>(I realize that AMD and Intel makes plenty "slow" CPUs, but they don't come in server boxes with fast I/O and all that).</p>
]]>
        

    </content>
</entry>

<entry>
    <title>When you program open source, ...</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/02/24/when_you_program_open_source.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.1948</id>

    <published>2008-02-24T21:59:23Z</published>
    <updated>2008-02-25T05:56:37Z</updated>

    <summary> Flickr sure has some passionate users!...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="flickr" label="flickr" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="funny" label="funny" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="microsoft" label="microsoft" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="opensource" label="open source" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="yahoo" label="yahoo" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p><span class="mt-enclosure mt-enclosure-image"><a href="http://www.flickr.com/photos/knasclass/2235238048/in/pool-659837@N23"><img alt="microsoft-communism.jpg" src="http://i.askask.com/2008/02/microsoft-communism.jpg" width="373" height="500" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;"/></a></span></p>

<p>Flickr sure has some <a href="http://www.flickr.com/groups/microsoft-keep-your-evil-grubby-hands-off-our-flickr/">passionate users</a>!</p>]]>
        
    </content>
</entry>

<entry>
    <title>10000+ tables in one MySQL database</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/02/14/10000_tables_in_one_mysql_database.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.1938</id>

    <published>2008-02-15T03:57:46Z</published>
    <updated>2008-02-15T04:33:09Z</updated>

    <summary>Once in a while I hear people talking about using thousands or tens of thousands of tables in one MySQL database and often how it &#8220;doesn&#8217;t work&#8221;. There are two things to say to them: Are you nuts?! Sure it works I&#8217;ll elaborate a little on both &#8230; Why&#8217;d you do that? Are you nuts?! In most cases when extraordinarily many tables are brought up the &#8220;correct answer&#8221; is: Fix your schema to not duplicate the same table layout for...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="mysql" label="mysql" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="scalability" label="scalability" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>Once in a while I hear people talking about using thousands or tens of thousands of tables in one MySQL database and often how it &#8220;doesn&#8217;t work&#8221;.  There are two things to say to them:</p>

<ul>
<li>Are you nuts?!</li>
<li>Sure it works</li>
</ul>

<p>I&#8217;ll elaborate a little on both &#8230;</p>

<h2>Why&#8217;d you do that? Are you nuts?!</h2>

<p>In most cases when extraordinarily many tables are brought up the &#8220;correct answer&#8221; is: Fix your schema to not duplicate the same table layout for each customer/user/site/&#8230;!</p>

<p>Once in a while though there are good reasons to have <strike>way too many</strike> lots of tables.  Even &#8220;takes too long to fix the application now&#8221; can be a good enough answer sometimes.</p>

<p>My use case was to use the many tables as an extra &#8220;index&#8221; for a situation that a regular index couldn&#8217;t cover.  Tens of thousands of tables, here we come.</p>

<p><a href="http://www.flickr.com/photos/ask/2265668961/" title="Nova Cimangola Cement Plant by ask, on Flickr"><img src="http://farm3.static.flickr.com/2140/2265668961_b081232230.jpg" width="500" height="333" alt="Nova Cimangola Cement Plant" /></a></p>

<h2>Sure it works, just configure it right!</h2>

<p>&#8230; which is easy!</p>

<ul>
<li><p>In your startup script (/etc/init.d/mysql with the MySQL RPMs), add &#8220;ulimit -n 30000&#8221; somewhere near the top to allow mysqld to have 30000 open files (and sockets).</p></li>
<li><p>In your mysql configuration, add something like the following - adjust the number as appropriate.</p>

<p>set-variable = table_cache=12000</p></li>
</ul>

<p>This will let MySQL keep up to 12000 tables open.  The default limit is much too low and the system will spend all its time closing and opening the files.  The other few thousand handles are free for database connections or whatever.   You surely can tune the numbers more, but I haven&#8217;t needed to be more specific yet.   MySQL uses two filehandles per open table (for MyISAM, it depends on the table type&#8230;) </p>

<h3>Flushing the tables</h3>

<p>One curious thing you&#8217;ll run into is that MySQL can take <em>forever</em> (read: hours!) flushing thousands of tables that have been changed if you do it with a simple &#8220;flush tables&#8221; or when you are shutting down mysql.  That&#8217;s of course not &#8220;hmn, how curious&#8221; but rather <em>insanely frustrating</em> if you were going for a quick restart.  This occasionally seems to happen with InnoDB tables too, but in particular with our large MyISAM system (we use fulltext indexes, hence MyISAM) this is a big issue.</p>

<p>With MyISAM tables, you also have a lot of cleaning up to do if the system crashes one way or another with thousands of tables open.</p>

<p>There’s an easy-ish solution to both these problems, though! Just flush the tables <em>individually</em> before the shutdown command and on a regular basis to mitigate the issue if it crashes.   Remember the system or MySQL can crash for all sorts of reasons.   Recently we had a motherboard with a BIOS or hardware bug that made it unstable after adding more than 16GB memory.  On another box, one of the memory sticks went bad so suddenly it came up with 4GB memory less than previously.   With MySQL carefully tuned to use all the memory (it was an InnoDB-only installation) it&#8217;d try using all 24GB memory and get killed by the kernel when it got above 20!  Yeah, that one took some head scratching before I figured it out.</p>

<p>Below is a small program that&#8217;ll go through the database twice flushing all tables in all databases and then end with a regular &#8220;flush all&#8221;.  We go through the database twice just in case the first flush took so long that a lot of tables got opened again.  Two works for me, depending on your needs you might make it an option.  Or a fancy version would check how many open tables are at the end of the run and go through it again if too many are open (and abort with an error if they open faster than they can get closed!).  The final &#8220;flush tables&#8221; worked for me in getting everything closed just before the script exits (and the shutdown or whatever starts).</p>
]]>
        <![CDATA[<pre><code>#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long qw(GetOptions);
use DBI;

my %args = (
            verbose =&gt; 0,
            user     =&gt; $ENV{USER},
            hostname  =&gt; '127.0.0.1',
            port     =&gt; 3306
           );

GetOptions(\%args,
           'verbose!',
           'user=s',
           'password=s',
           'hostname=s',
           'port=i',
           'database=s@'
          );


my $dbh = DBI-&gt;connect("dbi:mysql:hostname=$args{hostname};port=$args{port}",
                        $args{user}, $args{password})
  or die DBI-&gt;errstr;

my @dbs = $dbh-&gt;func('_ListDBs');

for my $db (@dbs) {
  next if uc($db) eq 'INFORMATION_SCHEMA';
  $dbh-&gt;do("use $db");
  my $tables = $dbh-&gt;selectcol_arrayref("show tables");
  for (1..2) {
    for my $table (@$tables) {
      print "flushing $db.$table\n";
      $dbh-&gt;do("flush table $table");
    }
  }
}

print "flushing all\n";
$dbh-&gt;do("flush tables");
</code></pre>
]]>
    </content>
</entry>

<entry>
    <title>Real World Web: Performance &amp; Scalability, MySQL Edition</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/02/14/real_world_web_scalability_mysql.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.1936</id>

    <published>2008-02-14T16:27:20Z</published>
    <updated>2008-02-14T09:46:20Z</updated>

    <summary>In exactly two months - April 14th - I&apos;m doing a scalability tutorial at the MySQL conference. It&apos;ll, of course, be based on the material I&apos;ve been throwing around since 2001, but once again it&apos;s greatly expanded, extended and improved! It should be lots of fun. I&apos;ve yet to hear anyone tell me that they wasted their time with this particular session and I don&apos;t think people are just being polite because I&apos;m often told that people find it tremendously...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="conferences" label="conferences" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mysql" label="mysql" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="scalability" label="scalability" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>In exactly two months - April 14th - I'm doing a <a href="http://en.oreilly.com/mysql2008/public/schedule/detail/1640">scalability tutorial</a> at the MySQL conference.</p>

<p>It'll, of course, be based on the material I've been throwing around <a href="http://conferences.oreillynet.com/cs/user/view/e_spkr/665">since</a> <a href="http://develooper.com/talks/">2001</a>, but once again it's greatly expanded, extended and improved!  It should be lots of fun.   </p>

<p>I've yet to hear anyone tell me that they wasted their time with this particular session and I don't think people are just being polite because I'm often told that people find it tremendously useful.  So <a href="https://en.oreilly.com/mysql2008/public/register">go sign up already</a>.   And don't pay any attention to <a href="http://krow.net/">Brian Aker</a> and <a href="http://dormando.livejournal.com/">dormando</a>'s shiny memcached tutorial going on at the same time.  I promise I'll cover memcached, too.  :-)   Speaking of Alan Kasindorf (aka Dormando) he had a <a href="http://dormando.livejournal.com/484577.html">most excellent post about how to run your systems</a> recently!</p>

<p>O'Reilly sent me a discount code to hand out to "friends and colleagues".  I'm not sure what they mean by that.  Can I post it here?  If you read my drivel, surely you must be a friend.  If you are interested in the session in the first place, surely you are some kind of colleague.  To be safe however I won't post it here.  If you want 20% off for the <a href="http://en.oreilly.com/mysql2008/public/content/home">MySQL Conference</a> send me <a href="http://develooper.com/contact/">an email</a>.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>What&apos;s the point of blade servers?</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/01/21/whats_the_point_of_blade_servers.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.1916</id>

    <published>2008-01-21T21:44:26Z</published>
    <updated>2008-01-21T21:50:29Z</updated>

    <summary>There&apos;s a news story today about Dell, IBM and HP all working on or having released new blade servers. Huh? What&apos;s the point of those at this point? You can easily (easily) use up all the power and air conditioning available in most facilities with &quot;regular&quot; servers. Why pay more and get a proprietary form factor etc? Are there enough corporate customers who have plenty AC and power available in a small computer room? Or is it something else?...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="bladeservers" label="blade servers" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="dell" label="dell" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="servers" label="servers" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>There's a news story today about Dell, IBM and HP all working on or having released new <a href="http://en.wikipedia.org/wiki/Blade_server">blade servers</a>.   Huh?  What's the point of those at this point?</p>

<p>You can easily (<em>easily</em>) use up all the power and air conditioning available in most facilities with "regular" servers.  Why pay more and get a proprietary form factor etc?   Are there enough corporate customers who have plenty AC and power available in a small computer room?  Or is it something else?</p>
]]>
        

    </content>
</entry>

<entry>
    <title>YellowBot at Twiistup 3</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2008/01/16/yellowbot_at_twiistup_3.html" />
    <id>tag:www.askbjoernhansen.com,2008://1.1914</id>

    <published>2008-01-17T07:59:55Z</published>
    <updated>2008-01-17T09:09:09Z</updated>

    <summary>YellowBot was presenting at Twiistup 3 today. It was a-awesome. We told about two billion people about a site and gave many of them a quick tour - and gave out a lot of t-shirts and a big box of delicious cup-cakes. :-) Now (1am): So Tired....</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p><a href="http://www.yellowbot.com/">YellowBot</a> was presenting at <a href="http://www.twiistup.com/">Twiistup 3</a> today.  It was a-awesome.  We told about two billion people about a site and gave many of them a quick tour - and gave out a lot of t-shirts and a big box of delicious cup-cakes.  :-)</p>

<p>Now (1am): So Tired.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Avoid the &quot;top of the minute problem&quot; - space out your cronjobs </title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2007/11/19/space_out_cronjobs.html" />
    <id>tag:www.askbjoernhansen.com,2007://1.1789</id>

    <published>2007-11-19T17:10:11Z</published>
    <updated>2008-02-25T06:16:41Z</updated>

    <summary>On Unix the universal job scheduler is &quot;cron&quot; (the other universal but less commonly known daemon is the at daemon). On Unix systems everywhere, lots and lots of batch jobs are kicked off all day from the cron daemon. The typical configuration looks something like this: 18 2 * * * ~/bin/some_batch_job This means at 18 minutes past the hour at 2am on every day of the month of every month of every weekday, run the following command (You can...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    <category term="unix" label="unix" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>On Unix the universal job scheduler is "cron" (the other universal but less commonly known daemon is the <a href="http://www.askbjoernhansen.com/2007/09/18/safely_change_firewall_rules_remotely.html">at daemon</a>).  On Unix systems everywhere, lots and lots of batch jobs are kicked off all day from the cron daemon.  The typical configuration looks something like this:</p>

<pre><code>18 2 * * * ~/bin/some_batch_job
</code></pre>

<p>This means at 18 minutes past the hour at 2am on every day of the month of every month of every weekday, run the following command (You can read about the configuration format by typing <code>man 5 crontab</code> on the command line of a nearby unix-y system).</p>

<p>Why 18 minutes past the hour?  For an hourly job you often want to pick a "semi random" time of the hour to run the job. If you run the same batch job on several servers all accessing a shared resource for example.</p>

<p>Sometimes though then the configuration has to be exactly the same everywhere, but you still want to spread out the runs.  Or it's a job that runs every minute or two on many systems.  Or you have a system that just runs a lot of cronjobs and you can't have them all start at exactly the same second.  You have to introduce second granularity to spread them out.  But how?  The cron format works with minutes at the lowest granularity.</p>

<p>You use the magic <code>$RANDOM</code> variable in the shell!</p>

<p>You can get a random number by just accessing <code>$RANDOM</code>, try it:</p>

<pre><code>echo $RANDOM
</code></pre>

<p>If you want a number between 1 and 10 you do a <a href="http://en.wikipedia.org/wiki/Modulo_operation">modulo operation</a> on the random variable.  In shell syntax that'd be</p>

<pre><code>echo $(expr $RANDOM % 10)
</code></pre>

<p>The <code>$( ... )</code> syntax works like backticks, runs the command and returns the result.  The expr command runs the arguments as a shell expression.</p>

<p>Now if you want to run a command (on average) every two minutes, but spread out the executions over 90 seconds, you can do</p>

<pre><code>*/2 * * * * sleep $(expr $RANDOM \% 90); ~/bin/batch_job
</code></pre>

<p>This will run the cronjob every 2 minutes (120 seconds), but wait between 0 and 89 seconds before running the actual script.  Magic!</p>

<p>Whenever you setup something to access a remote resource (RSS feed, NNTP server, ...) it's always polite to do this, otherwise the server operator will get an onslaught of requests exactly on the minute -- or even worse at the top of the hour.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Selectively silence the volume adjustment &quot;click&quot;</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2007/11/17/selectively_silence_the_volume_adjustment_click.html" />
    <id>tag:www.askbjoernhansen.com,2007://1.1838</id>

    <published>2007-11-18T00:09:14Z</published>
    <updated>2007-11-18T00:15:40Z</updated>

    <summary>By default in OS X when you hit the volume keys on the keyboard the OS X gives a little &#8220;click&#8221;. In 10.5 there&#8217;s an option to disable it (Sound Preferences, &#8220;Play feedback when volume is changed&#8221;. Is that option in 10.4 too?). However, if you usually want it on you can still selectively make the adjustment silent. Just hold down the shift key while pressing the volume button. I think this is a new feature in 10.5, but I&#8217;m...</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p><span class="mt-enclosure mt-enclosure-image"><img alt="volume_change.png" src="http://www.askbjoernhansen.com/images/2007/11/volume_change.png" width="218" height="212" class="mt-image-right noborder" style="float: right; margin: 0 0 20px 20px;"/></span>By default in OS X when you hit the volume keys on the keyboard the OS X gives a little &#8220;click&#8221;.  In 10.5 there&#8217;s an option to disable it (Sound Preferences, &#8220;Play feedback when volume is changed&#8221;.  Is that option in 10.4 too?).  However, if you usually want it on you can still selectively make the adjustment silent.</p>

<p>Just hold down the shift key while pressing the volume button.  I think this is a new feature in 10.5, but I&#8217;m not sure - I stumbled over it accidentally (accidentally holding down random keys - amazingly I ever get the computer to do what I want!).  It works on the &#8220;real&#8221; keyboard on my PowerMac, but not on the internal keyboard on the MacBook Pro - I haven&#8217;t tried with an external keyboard on the laptop yet. </p>

<p>Does it work for you?</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Army desertion rate up 80 pct. since &apos;03</title>
    <link rel="alternate" type="text/html" href="http://www.askbjoernhansen.com/2007/11/17/army_desertion_rate_up_80_pct_since_03.html" />
    <id>tag:www.askbjoernhansen.com,2007://1.1836</id>

    <published>2007-11-17T21:14:25Z</published>
    <updated>2007-11-17T21:20:54Z</updated>

    <summary>This must be the craziest spin I&apos;ve seen in a while: &quot;We&apos;re asking a lot of soldiers these days,&quot; said Roy Wallace, director of plans and resources for Army personnel. &quot;They&apos;re humans. They have all sorts of issues back home and other places like that. So, I&apos;m sure it has to do with the stress of being a soldier.&quot; So they&apos;re deserting to go home because of their &quot;issues&quot; there? Uh-huh, sure ......</summary>
    <author>
        <name>Ask Bjørn Hansen</name>
        <uri>http://askask.com/</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.askbjoernhansen.com/">
        <![CDATA[<p>This must be the <a href="http://news.yahoo.com/s/ap/20071117/ap_on_go_ca_st_pe/military_deserters;_ylt=AqsRy2kWFETWEGwGoq5VbYCs0NUE">craziest spin</a> I've seen in a while:</p>

<blockquote><p>"We're asking a lot of soldiers these days," said Roy Wallace, director of plans and resources for Army personnel. "They're humans. They have all sorts of issues back home and other places like that. So, I'm sure it has to do with the stress of being a soldier."</p></blockquote>

<p>So they're deserting to go home because of their "issues" there?  Uh-huh, sure ...</p>]]>
        
    </content>
</entry>

</feed>
