<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description></description><title>Ecstortive</title><generator>Tumblr (3.0; @maxpert)</generator><link>http://blog.creapptives.com/</link><item><title>The browser script tags</title><description>&lt;p&gt;I recently saw the announcement of &lt;a href="https://lists.webkit.org/pipermail/webkit-dev/2011-December/018775.html" target="_blank"&gt;Google Dart being part of Webkit as patch&lt;/a&gt;. Lots of people really started yelling. This post is just an opinion and a wish-list.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I would love to see dart as plug-in to &lt;strong&gt;browsers&lt;/strong&gt; rather than a patch to Webkit!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If Google is really looking forward to have Dart as next language for webpages; I think its time to open the &lt;strong&gt;Pandora box&lt;/strong&gt; and again start using the long forgotten language=&amp;#8221;Dart&amp;#8221; in script tags (other options may include language=&amp;#8221;Lua&amp;#8221;, language=&amp;#8221;Coffescript&amp;#8221;, language=&amp;#8221;Brainfuck!&amp;#8221; and who knows what). Remember when two giants were fighting we used to have &amp;#8220;VBScript&amp;#8221; in the language property? It&amp;#8217;s long gone, but here is a chance for Microsoft again! Here is my wish list:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Scripting languages that ship as extension to browsers, just like Flash today! This is will open up true competition between developers (Google vs. Microsoft vs. Mozilla vs. Opera?) truly promoting the nature of open platform, where you get choice of choosing your language. Just think about it; if Javascript also becomes an extension to browsers, you would be able to plug v8 to Firefox (Ya I sound crazy)!&lt;/li&gt;
&lt;li&gt;Script tags remain there with no changes, execution however depending upon the availability of language (plugin) mentioned in attribute:&lt;br/&gt;&lt;blockquote&gt;&amp;lt;script type=&amp;#8221;text/dart&amp;#8221; language=&amp;#8221;Dart&amp;#8221;&amp;gt;/* My Dart Code */&amp;lt;/script&amp;gt;&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;BAL, yes a Browser Abstraction Layer. Since all of the extensions would need a interface to interact with DOM, and various components in browser we would definitely need one!&lt;/li&gt;
&lt;li&gt;Since we can switch between languages, we can also get options for compiled scripts! Which will take out the overhead of compression, minification and at times obfuscation crap. We would be able to ship byte-codes over the wire which means lesser size (compiled .pyc files ennnh) and more efficient VMs!&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;I have not yet calculated the Pros and Cons completely but as a web developer this is my wish list. What do you think?&lt;/p&gt;
&lt;ul&gt;&lt;/ul&gt;</description><link>http://blog.creapptives.com/post/14168703011</link><guid>http://blog.creapptives.com/post/14168703011</guid><pubDate>Tue, 13 Dec 2011 20:58:03 +0500</pubDate></item><item><title>The key value store everyone ignored (Postgresql)</title><description>&lt;p&gt;Yes I know you are really happy with your &amp;#8220;persistent&amp;#8221; Key Value store. But did anybody notice &lt;strong&gt;hstore&lt;/strong&gt; that comes along Postgresql. I find Postgresql to be a really great RDBMS that has been ignored all the time. It even has some great publisher/subscriber system as well (or &lt;a href="http://www.postgresql.org/docs/8.1/static/sql-notify.html" target="_blank"&gt;LISTEN/NOTIFY&lt;/a&gt; in terms of Postgresql) that a lot of people may have implement using Redis, RabbitMQ etc. For people who have not lived anything other than MySQL. I would simply ask them to try out Postgres.&lt;/p&gt;
&lt;p&gt;Instead of looking at benchmarks, I will be focusing on a key value store that is &lt;strong&gt;ACID&lt;/strong&gt; compliant for real! Postgres takes advantage of its storage engine and has an extension on top for key value storage. So plan is to have a table can have a column that has a datatype of hstore; which in turn has a structure free storage. Thinking of this model multiple analogies throw themselves in. It can be a Column Family Store just like Cassandra where row key can be PK of the table, and each column of hstore type in table can be imagined like a super column, and each key in the hstore entry can be a column name. Similarly you can imagine it some what like Hash structures in Redis (HSET, HDEL), or 2 or 3 level MongoDB store (few modifications required). Despite being similar (when little tricks are applied) to your NoSQL store structures, this gives me an opportunity to demonstrate you some really trivial examples.&lt;/p&gt;
&lt;p&gt;Lets setup our system first. For my experiment I will be using Postgres 9.1 and I will compile it from source. Once in source directory you can: &lt;strong&gt;./configure &amp;amp;&amp;amp; make install&lt;/strong&gt; to install your Postgres. Don&amp;#8217;t forget to install the extensions in the &lt;strong&gt;contrib&lt;/strong&gt; directory: &lt;strong&gt;cd ./contrib &amp;amp;&amp;amp; make install&lt;/strong&gt;. Once you have setup the database you can create your own database and start the server (Hints: use &lt;strong&gt;initdb&lt;/strong&gt; and &lt;strong&gt;pg_ctl&lt;/strong&gt;). Then launch your psql and make sure you install your hstore extension:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre class="PROGRAMLISTING"&gt;CREATE EXTENSION hstore;&lt;br/&gt;SELECT 'foo=&amp;gt;bar'::hstore;
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;If everything goes well you should be able to see table output. Now we are ready to do some DDL. I created a table my_store as schema definition below:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre class="PROGRAMLISTING"&gt;CREATE TABLE my_store&lt;br/&gt;(&lt;br/&gt;  id character varying(1024) NOT NULL,&lt;br/&gt;  doc hstore,&lt;br/&gt;  CONSTRAINT my_store_pkey PRIMARY KEY (id)&lt;br/&gt;)&lt;br/&gt;WITH (&lt;br/&gt;  OIDS=FALSE&lt;br/&gt;);&lt;br/&gt;&lt;br/&gt;CREATE INDEX my_store_doc_idx_gist&lt;br/&gt;  ON my_store&lt;br/&gt;  USING gist&lt;br/&gt;  (doc);&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;As you can see I&amp;#8217;ve created a table with hstore column type and one GiST index (for operators&amp;#160;?&amp;#160;?&amp;amp;&amp;#160;?| etc.). You can checkout of &lt;a href="http://www.postgresql.org/docs/current/static/hstore.html" target="_blank"&gt;documentation&lt;/a&gt; to have a look on different type of operators you have.&lt;/p&gt;
&lt;p&gt;Now that we have database and tables setup I wrote a simple script to populate it with about 115K rows from twitter stream. Now keep in mind that its a real life data and I was interested in querying few basic things from collected data. For example, how many people are putting hash tags, or doing mentions, or were posting links in the tweets? For doing this I wrote a &lt;a href="http://pastie.org/2999422" target="_blank"&gt;simple python script&lt;/a&gt; using tweepy and psycopg2 and ran it for about few hours. For each tweet in my store I added a key value pair of &amp;#8216;&lt;strong&gt;has_hashtags=&amp;gt;:t&lt;/strong&gt;&amp;#8217; if there were any hash tags in the tweet, similarly I introduced &lt;strong&gt;has_urls&lt;/strong&gt; and &lt;strong&gt;has_mentions&lt;/strong&gt; if they were present in tweet, I will be using these keys along with my GiST index to query my table later on.&lt;/p&gt;
&lt;p&gt;So after populating my data with 115,142 tweets the database grew to a size of 239691780 bytes (Just 228MB). Now comes the fun part. I was totally blown away by what I can achieve by combining the power of relational and key value style under 1 store. So for example I want to  query all the tweets tweeted at unix timestamp of 1323446095 (since I stored the timestamps as a string here is what my query looks like):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT doc -&amp;gt; &amp;#8216;text&amp;#8217; as tweet, doc -&amp;gt; &amp;#8216;created_at&amp;#8217; as created_at&lt;br/&gt;FROM my_store &lt;br/&gt;WHERE doc @&amp;gt; &amp;#8216;created_at=&amp;gt;00001323446095&amp;#8217;;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I can add simple count or any other SQL famous aggregate function without going into any complications of my data store specific map reduce or new language to learn hustle. Do note that I padded my timestamp value with zeros since I am only storing strings as values. Also I am utilizing @&amp;gt; operator, thats gonna use the GiST to really do a quick bitmap index scan instead of sequential scan. That was pretty good for starter. Lets try to fetch out all the tweets that had hash tags in them:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT doc -&amp;gt; &amp;#8216;text&amp;#8217; as tweet, doc -&amp;gt; &amp;#8216;created_at&amp;#8217; as created_at&lt;br/&gt;FROM my_store &lt;br/&gt;WHERE doc @&amp;gt; &amp;#8216;has_hashtags=&amp;gt;:t&amp;#8217;;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Yes querying complete database pulling out complete data (That you won&amp;#8217;t probably do because you page the data :) ) gives me 14689 rows just under 360ms on average. Since we have SQL at hand lets make a condition little more complicated, and use a different operator for same stuff and also sort the data by created_at:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT doc -&amp;gt; &amp;#8216;text&amp;#8217; as tweet, doc -&amp;gt; &amp;#8216;created_at&amp;#8217; as created_at&lt;br/&gt; FROM my_store &lt;br/&gt; WHERE doc @&amp;gt; &amp;#8216;has_hashtags=&amp;gt;:t&amp;#8217; AND doc&amp;#160;? &amp;#8216;has_urls&amp;#8217; &lt;br/&gt;ORDER BY doc -&amp;gt; &amp;#8216;created_at&amp;#8217; DESC;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It already sounds tasty! This is not it Postgres has more operators, so pulling out hash tagged tweets with urls or mentions is also possible,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SELECT doc -&amp;gt; &amp;#8216;text&amp;#8217; as tweet, doc -&amp;gt; &amp;#8216;created_at&amp;#8217; as created_at&lt;br/&gt; FROM my_store &lt;br/&gt; WHERE doc @&amp;gt; &amp;#8216;has_hashtags=&amp;gt;:t&amp;#8217; AND doc&amp;#160;?| ARRAY[&amp;#8216;has_urls&amp;#8217;, &amp;#8216;has_mentions&amp;#8217;]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is not it! hstore comes with all sort of operators and index systems that you can ask for hash store. Check them out &lt;a href="http://www.postgresql.org/docs/current/static/hstore.html" target="_blank"&gt;here&lt;/a&gt;. Now, despite the NoSQL boom I think we have some great examples and reasons of why RDBMS still remains core part of many market giants (Facebook being something everyone knows). Postgres just gives me one more reason to not ignore RDBMS systems, So If you have been moving around on some document stores just because the reason that RDBMS don&amp;#8217;t provide them; think again! You can get the same rock solid durability with structure free systems.&lt;/p&gt;
&lt;p&gt;I will be pretty soon revisiting the &lt;a href="http://bret.appspot.com/entry/how-friendfeed-uses-mysql" target="_blank"&gt;FriendFeed use case with MySQL to store structure free data&lt;/a&gt; with Postgresql approach. Stay tuned, leave your comments and thoughts.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/14062057061</link><guid>http://blog.creapptives.com/post/14062057061</guid><pubDate>Sun, 11 Dec 2011 17:43:00 +0500</pubDate><category>postgresql</category><category>keyvalue</category><category>store</category><category>nosql</category><category>ignore</category><category>hstore</category><category>friendfeed</category><category>facebook</category></item><item><title>Oracle NoSQL simplicity and benchmarks</title><description>&lt;p&gt;Today I will be doing the long awaited initial benchmarks of Oracle&amp;#8217;s NoSQL. Before I jump in I would like to mention that I had a &lt;a target="_blank" href="http://maxpert.tumblr.com/post/12289939108/oracle-nosql-first-impression"&gt;previous post&lt;/a&gt; on Oracle&amp;#8217;s NoSQL that examines the philosophy and design of Oracle NoSQL store. It&amp;#8217;s been few days I&amp;#8217;ve been playing around with system. I found it pretty simple due to its major and minor key system; some great multi-get, iterator constructs for read, basic delete, and put system with versions. I did find some short comings, and we will see them in details at the end of this post. So lets get started.&lt;/p&gt;
&lt;p&gt;For sake of benchmarking I am going to make things really simple. I will be benchmarking the insert and read speeds of a single node (1 machine no replication, no distribution) and look how a single node performs, based on that we can make rough estimates of performance gains by adding more machines.&lt;br/&gt;&lt;br/&gt;Machine used for benchmarks is a pretty normal laptop machine with &lt;a target="_blank" href="http://pastie.org/1571529"&gt;Dual Core 2.1GHz processor&lt;/a&gt;, 3&amp;#160;GB RAM, and &lt;a target="_blank" href="http://pastie.org/1571548"&gt;commodity HDD&lt;/a&gt;. As an example I implemented a twitter like user stream of 100,000 tweets for 100 users randomly (that make approx 1000 tweets per user) each tweet with &lt;strong&gt;size of a little more than 100 bytes&lt;/strong&gt;. So what we will be benchmarking is a speed test for inserting 100,000 tweets (approx 100+bytes) for inserting and reading them all. They should be pretty good experiments (close to a real world scenario) to give us an idea of what Oracle NoSQL can do.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://pastie.org/2862027"&gt;Here&lt;/a&gt; is the piece of code that inserts and reads the 100,000 million entries and benchmarks the total time consumed. Compiling and running this I get output as following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write Time consumed 143156&lt;br/&gt;Iteration Total time taken 223&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Please note the time consumed in above benchmark &lt;strong&gt;is number of milliseconds&lt;/strong&gt;. It turns out that inserting 100,000 entries in random order (since user ids generated are random) take 143156&amp;#160;ms and iterating over each entry of each user take 223&amp;#160;ms. I am pretty satisfied with read speed, and for write speed I found and average time of 1.4&amp;#160;ms (which is slower than reads but almost 700 inserts per second). Its &lt;strong&gt;important&lt;/strong&gt; to note that each insert here is disk synchronized (with durability of Durability.SyncPolicy.SYNC on master, and since we have only 1 node means we are doing the most disk write with no buffering). If I lower the durability value (Durability.COMMIT_WRITE_NO_SYNC write with buffering), the average time drops to 0.5&amp;#160;ms; which is almost double the performance of previous version (or Durability.COMMIT_SYNC). It&amp;#8217;s worth noting that you can also customize durability per transaction, which is great for letting a programmer choose what he wants.&lt;/p&gt;
&lt;p&gt;I didn&amp;#8217;t stop here and continued to implement a example &lt;a target="_blank" href="http://pastie.org/2862063"&gt;twitter class&lt;/a&gt;, which proves the simplicity of what such this simple structure can do. I think the core power lies in not being a monolithic (JSON like) tree like object, and allowing us to pull data on partial paths as well as from full major key path. The class is used in this &lt;a target="_blank" href="http://pastie.org/2862068"&gt;example code&lt;/a&gt; to create a user, authenticate, tweet, and query time-line of user.&lt;/p&gt;
&lt;p&gt;Somebody may wonder how it compares with other data stores (document free, column based, key value). I can definitely achieve same effect by other key value stores (some what close as well), but I must say this style was much breeze and easy to imagine (just look at the code for &lt;a target="_blank" href="#"&gt;reading tweets&lt;/a&gt; and you will know what I am saying), Oracle must rename store type from Key Value store to a new title. Because it&amp;#8217;s pretty clear that its not a key value store; it overlaps between the document and key value style (Again I achieve this same effect in key sorted KV stores like LevelDB or TokyoCabinet).&lt;/p&gt;
&lt;p&gt;In closing I must also give out some negatives I found, plus the some extras. Currently the number of partitions on Oracle NoSQL are fixed! What does this mean? It implies that at storage can&amp;#8217;t be scaled horizontally yet since they can&amp;#8217;t rebalance; once partitions have been made they remain fixed. Although Oracle in it&amp;#8217;s documentation mentions about the next version having the re-balancing feature. Second (may be most for people) hurting part is dependence on Java platform. Now this will hurt lot of Ruby, and Python etc. people but again, as I said in my previous post, with help of a Java programmer you can write a REST API for yourself (I am planning a Protobuff server to eat this plague). Third, I found administration of system to be a little tricky (could not be understood without reading complete administration docs), but this is no hurdle for a programmers since it provides launch and go script to run the server. Right now I am planning to write a Scala wrapper (syntactic awesomeness) for Oracle NoSQL, so once I am done I will put it on GitHub. You folks in the mean while have few more calories of this NoSQL deliciousness.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/12791030969</link><guid>http://blog.creapptives.com/post/12791030969</guid><pubDate>Mon, 14 Nov 2011 20:25:27 +0500</pubDate><category>oracle</category><category>nosql</category><category>benchmarks</category><category>simplicity</category></item><item><title>Oracle NoSQL First Impression</title><description>&lt;p&gt;Today I finally downloaded a community version copy of Oracle NoSQL, I am pretty happy to see a market giant like Oracle in the NoSQL era (Now waiting for DB2 guys to come in too).  I&amp;#8217;ve used Oracle 9i way back in my history and have been  using MySQL for like decades (almost daily basis) and I  know how feature rich these platforms are. Now since Oracle has landed with their NoSQL machinery, I just went through documentation from &lt;strong&gt;developers perspective&lt;/strong&gt; to have a glimpse of feature sets. Lets go through highlights really quickly:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;It&amp;#8217;s a Key Value store that&amp;#8217;s scalable, HA, predictable, and really simple.&lt;/li&gt;
&lt;li&gt;Keys can behave like a composed structure of major, and minor keys. Major keys can be imagined just like path in your storage files (Hassan/Zohaib where there are two major keys Hassan and Zohaib) and minor keys can just be imagined like files in the (given major key) path holding your data in bytes (Hassan/Zohaib.birthdate, Hassan/Zohaib.phonenumber, Hassan/Zohaib.image, Hassan/Zohaib.userID holding different type of data). There can be multiple major and minor keys. I find this depth-limitation free structure to be extremely powerful, and really close to JSON structures (Yes it can act as document oriented database when crafted carefully).&lt;/li&gt;
&lt;li&gt;Supports typical CRUD operations with high definition over consistency and durability, which lets you choose the amount of chocolate sauce you can afford on your taste buds.&lt;/li&gt;
&lt;li&gt;A powerful Multi-Get, Get-Iterators,  Set-Iterators, and depth controls that can set your retrieval on steroids.&lt;/li&gt;
&lt;li&gt;One word that says it all. Transactions!&lt;/li&gt;
&lt;li&gt;Last but not least. &lt;strong&gt;Well documented&lt;/strong&gt;! Some of NoSQL projects have been suffering with this problem, so right from version 1.1 you are getting a really good documentation which is a big plus.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Despite the good features, I feel it has some set backs or I may say a wish list that can actually be fulfilled:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;You need to talk Java, this will benefit the JVM dialects like Coljure, JRuby, Scala etc. But we can always write some REST API like HBase did in shape of Stargate. I won&amp;#8217;t recommend that and I think Oracle should quickly figure out a good protocol (something like Memcache protocol will work) to do so.&lt;/li&gt;
&lt;li&gt;Intelligent client library makes client end thick by maintaining state tables, calculating bounded network hops efficiency, and using major-minor keys to exploit the shards for efficient storage. I find it something like libmemcached or mongos (workings of mongos as library). I can&amp;#8217;t call it a set back because some people prefer this way of sharding and distribution. But my favorite is Riak or Cassandra styled model of peers.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;I can pretty much see how basic and really powerful this tool can turn out to be. I&amp;#8217;ve only considered the Pros and Cons from programming point of view (API) completely ignoring administration and other parts (Will be doing a detailed benchmarks next). I must say I am pretty satisfied until now, and my first impressions are pretty good. Stay tuned for a detailed benchmarks, and stress test.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/12289939108</link><guid>http://blog.creapptives.com/post/12289939108</guid><pubDate>Thu, 03 Nov 2011 23:23:01 +0500</pubDate><category>nosql</category><category>oracle</category><category>first</category><category>impression</category></item><item><title>RVM+Ruby 1.9.2+Thrift 0.7.0 = RRT = Really Really Trashed!</title><description>&lt;p&gt;OK, so I am writing this post after a whole day spent in effort to get Thrift working on Ruby 1.9.2, so that I can run the Cassandra gem. Now what I always expected out of Gem system is breezy a experience. But today it was really rough. Now &lt;a target="_blank" href="https://issues.apache.org/jira/browse/THRIFT-1382"&gt;some people &lt;/a&gt;and Google results suggest that its due to my Ubuntu 11.10 distribution, but if its due to Ubuntu guys why ain&amp;#8217;t anybody reported on Ubuntu bug tracking! Some people say &lt;a target="_blank" href="https://issues.apache.org/jira/browse/THRIFT-1382"&gt;its due to Ruby&lt;/a&gt;, and there are lots of endless discussions with no conclusions.&lt;/p&gt;
&lt;p&gt;Anyways I don&amp;#8217;t want any of you to waste your time on the same exercise that I did today and waste a Sunday! Hopefully this post will help you fix issue. So here we go if you right now do gem install thrift on your system and you get error like&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;#8230;(Some compile commands)&lt;br/&gt;ruby/missing.h:157:20: note: previous declaration of ‘strlcpy’ was here &lt;br/&gt;make: *** [struct.o] Error 1&amp;#8221;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You are victim of RRT (Really Really Trash)! Here is how to fix it. First download the original Thrift 0.7.0 source code distribution from apache&amp;#8217;s site. Extract, configure, and install it with your Ruby 1.9.2 activated (in case you use RVM). Here are commands to do so:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;rvm 1.9.2&lt;br/&gt;tar vxzf [your thrift archive].tar.gz&lt;br/&gt;cd thrift-0.7.0&lt;br/&gt;./configure&lt;br/&gt;make &amp;amp;&amp;amp; make install&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Be sure you have ruby development library installed, and things will go fine. Next just to make sure you get the native thrift client for your activated Ruby, inside thrift source directory go to lib/rb (&lt;strong&gt;cd lib/rb&lt;/strong&gt;) and run &lt;strong&gt;rvm 1.9.2 &amp;amp;&amp;amp; ruby setup.rb&lt;/strong&gt;. In case of Ruby 1.9.3, (Running ruby setup.rb) I encountered same as before error saying &amp;#8220;&lt;strong&gt;struct.c:28:1: error: static declaration of ‘strlcpy’ follows non-static declaration&lt;/strong&gt;&amp;#8221;, to fix this error just open up the ext/struct.c (inside the same lib/rb directory) and remove the &lt;strong&gt;static&lt;/strong&gt; keyword from &lt;strong&gt;line 26&lt;/strong&gt;. Once you have done that you can now install native client of thrift. Lets install the gem now!&lt;/p&gt;
&lt;p&gt;First download the thrift gem from &lt;a target="_blank" href="http://rubygems.org/gems/thrift"&gt;here&lt;/a&gt;. Make sure its version is 0.7.0 (matches thrift protocol you compiled). Once done do &lt;strong&gt;gem unpack thrift-0.7.0&lt;/strong&gt; to unpack the gem contents into thrift-0.7.0 directory. Go to thrift-0.7.0 director and you will find similar structure as lib/rb in thrift source code (not exactly similar but I am mentioning &lt;strong&gt;ext&lt;/strong&gt; directory specifically). Again open up the same file (struct.c) and remove the &lt;strong&gt;static&lt;/strong&gt; keyword from &lt;strong&gt;line 26&lt;/strong&gt;. Running ruby setup.rb inside gem directory should be error free now. Since I am using bundle to do package management a one liner in &lt;strong&gt;Gemfile&lt;/strong&gt; should do the job for me.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;gem &amp;#8220;thrift&amp;#8221;, :path =&amp;gt; &amp;#8216;thrift-0.7.0&amp;#8217; #path to modified gem directory&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And thats about it. Launch your IRB an things should load up. Hope it saves you a day!&lt;/p&gt;</description><link>http://blog.creapptives.com/post/12121356870</link><guid>http://blog.creapptives.com/post/12121356870</guid><pubDate>Sun, 30 Oct 2011 22:15:25 +0500</pubDate></item><item><title>"I know you never wanted to die; neither did I want you to die. But I feel left alone with two..."</title><description>“I know you never wanted to die; neither did I want you to die. But I feel left alone with two realities; one I won’t be able to see you, and second I won’t be able to find a someone like you. You were right! It (Death) is Life’s change agent.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;p&gt;For Steve Jobs from Zohaib Sibt-e-Hassan&lt;/p&gt;
&lt;p&gt;&lt;img src="http://s2.postimage.org/a37lxk5ez/t_hero.png"/&gt;&lt;/p&gt;&lt;/em&gt;</description><link>http://blog.creapptives.com/post/11093277939</link><guid>http://blog.creapptives.com/post/11093277939</guid><pubDate>Thu, 06 Oct 2011 11:03:00 +0500</pubDate></item><item><title>A journey to center of Redis </title><description>&lt;p&gt;I&amp;#8217;ve been using Redis lately and I really love the work they have done. In one of my recent projects I had a typical scenario of having users on different channels, and since the old front-end (Javascript) was doing a JSONP through jQuery, I had to take in account for people who were not able to get back to channel due to some disconnection. Yes, its a typical scenario of &amp;#8220;timeout&amp;#8221; operation. Within a particular time limit (30 seconds in my case) if a user is not coming back or responding back, you have to mark him as offline user (or may be different in your cases).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Timeout&lt;/strong&gt; is a very typical operation that you usually come across all the time, In my case there were few options I had to get around this issue (I was using tornado for handling requests, and Redis for storage):&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;On every request before returning use add_timeout, keeping a Dictionary of &amp;#8216;user_id&amp;#8217; -&amp;gt; add_timeout_returned_id; each time user comes back we remove the timeout event by looking up the user id in dictionary. If user doesn&amp;#8217;t come back within time limit the callback fired will clean the things up.&lt;/li&gt;
&lt;li&gt;Keep time stamps against user id in Redis, run a background process cleaning those who didn&amp;#8217;t updated their time stamp and have their entry left in redis. The background worker will be a separate configurable instance running after intervals and cleaning up the dead users.&lt;/li&gt;
&lt;li&gt;Use the lovely EXPIRE feature of Redis to remove the entries from DB and the worker process which looks for missing (expired) entries in channel and notifies other users with PUBLISH.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Now first entry, won&amp;#8217;t be scalable since we are making the single python instance responsible for maintaining timers for same user, plus it complicates the code (yes I hate complicated code). You can although use cookies with NGINX to load-balance and assign same server again to same user, but this is what I am looking forward to avoid. Second approach is not real-time since we are using worker with update intervals to clean the mess I simply don&amp;#8217;t like it. Third approach sounds fine from DB point of view, but again its not real-time. Exploring and digging deeper I found there was not way to have PUBLISH foo bar DELAY 30 (Publish after delay of 30 seconds). *GOSH* that would have killed the ugly duckling! Unfortunately for meeting deadline I took the 3rd approach since it was memory effective on DB side and keeping my code cleaner when compared to other approaches.&lt;/p&gt;
&lt;p&gt;Last night I sat with this idea in my mind to have a PUBLISH event on a configured channel when a key expires (Cure for the itch). Walking around Redis community I found some really complicated discussions going on; with ideas of meta publish channels and some really brainy ideas stuff. I wanted to keep it simple, clean, configurable and that&amp;#8217;s where opensource really helps; you have a different opinion go create your own flavor. I created my &lt;a target="_blank" href="https://github.com/maxpert/redis/tree/2.2"&gt;own fork&lt;/a&gt; and implemented what was really simple (and yummy chocolate flavored :P). So with new fork, Redis configuration can now contain an additional parameter named keys-expire-notify (so keys-expire-notify&amp;#160;!KEYS will make Redis do a &amp;#8220;PUBLISH&amp;#160;!KEYS &amp;lt;expired_key&amp;gt;&amp;#8221;  every-time a key expires).&lt;/p&gt;
&lt;p&gt;This feature will open up a whole new world of possibilities for the Redis users, including DB updates on cache invalidation, cascaded updates in Redis, time out events from Redis (Yes you can use keys to make it happen), Imagination is your limit! I&amp;#8217;ve been playing around with the thing for a bit longer now and I am pretty much satisfied. It should be pretty much &lt;strong&gt;stable&lt;/strong&gt;, since its built on top of existing infrastructure. You can grab your copy &lt;strong&gt;&lt;a target="_blank" href="https://github.com/maxpert/redis/tree/2.2"&gt;here&lt;/a&gt;&lt;/strong&gt; and enjoy the new feature! I am really looking forward to see this idea as official part of Redis.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/10319226886</link><guid>http://blog.creapptives.com/post/10319226886</guid><pubDate>Sat, 17 Sep 2011 21:27:02 +0500</pubDate><category>redis</category><category>expire</category><category>notification</category><category>publish</category><category>event</category><category>trigger</category><category>notification</category></item><item><title>The Node Redumption!</title><description>&lt;p&gt;In my previous post I did some benchmarks for NodeJS vs Java&amp;#8217;s NIO. For benchmarking I wrote my custom event driven loop handling, and parsing HTTP connections; and what else you can expect! &lt;strong&gt;Hell broke loose&lt;/strong&gt; when the NodeJS fans read that. They had sort of weird comments and objections. From those all the weirdness I learned a few things. Things that were pretty simple and straight forward. This post will be my last post on all I have to say about NodeJS, and Java (Yes, I won&amp;#8217;t be comparing them again!), and other than just theory (as usual) I will present the experiments. While reading this post please bear in mind, I am not a technology maker or an Omega of any big platform; I am one of the developers among the race of curious ones, who when encounters a new technology readily accepts it, experiments with it and then places it in the right shelve (just like a weapon) for the right use case. The reasons behind my last blog post include clarifications (to my self and people around) about pros and cons, a solid idea of what&amp;#8217;s going on inside, and what if I never had NodeJS on hand (more precisely how Facebook and Twitter guys handle so much load). I totally believe in greedy approach to problems, where I say &amp;#8220;To optimize the bigger problem, you have to optimize the subpart of the problem&amp;#8221;.&lt;/p&gt;
&lt;p&gt;I know I annoyed alot of people just by comparing Apples and Bananas (Java and NodeJS). Both languages have a ridiculously different paradigm (OO vs Prototypal) and totally different maturity level (15 years of engineering on Java). So this post is to put both tools in &amp;#8220;same situation&amp;#8221; and experiment what are the results. Some people thought JIT, and JVM has nothing to do with IO based system, well I won&amp;#8217;t say anything in reply to it yet. Let&amp;#8217;s proceed with first benchmark.&lt;/p&gt;
&lt;p&gt;This time I am taking the same NodeJS with &lt;a target="_blank" href="http://learnboost.github.com/cluster/"&gt;Cluster&lt;/a&gt; (Thanks to suggestion in previous post), to add multi-core CPU utilization support (Like always you can suggest if there is a better option). Also I changed the &lt;a target="_blank" href="http://www.pastie.org/2497954"&gt;code&lt;/a&gt; to do some really basic and simple processing, using a counter with timestamp system that just prints a simple message with number of hit counts, and timestamp. For Java I have a special arrangement this time; every body last time objected that my code was pretty unfair to the amount of processing NodeJS  (http module) has to do, so I am making it fair this time. &lt;strong&gt;Netty NIO&lt;/strong&gt; is the new contender in the ring for Java this time; with its fully implemented HTTP support, NodeJS people now cannot object on anything regarding the event loop and parsing system. The code gets divided into four classes now &lt;a target="_blank" href="http://www.pastie.org/2497985"&gt;main launcher&lt;/a&gt;, &lt;a target="_blank" href="http://www.pastie.org/2497988"&gt;pipeline factory&lt;/a&gt;, &lt;a target="_blank" href="http://www.pastie.org/2497995"&gt;handler&lt;/a&gt; (NodeJS guys would be interested in this one), and a &lt;a target="_blank" href="http://www.pastie.org/2497999"&gt;singleton&lt;/a&gt;. Pretty fair pieces of codes for both sides, both utilizing 1 worker per CPU core (I have a dual core), and having full fledged HTTP protocol support. Lets have look at benchmarks again! I used concurrency level 1000 and NodeJS managed to get only 5.2K req/sec [&lt;a target="_blank" href="http://www.pastie.org/2498063"&gt;Raw Dump&lt;/a&gt;], a increase of 200 over last time (That&amp;#8217;s pretty sweet you wasted my time again!). Java Netty NIO on other hand manages to handle 7.3K req/sec [&lt;a target="_blank" href="http://www.pastie.org/2498139"&gt;Raw Dump&lt;/a&gt;], a decrease of 700 over the last time (now you know  why I have decided not to write on both of these again); thats still over 1.7 times faster.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A basic application&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Somebody suggested me to put them in a real scenario (do something with some storage and serve JSON and all typical stuff) and then do the benchmarks. Well taken, I picked Redis (Good enough for speed) for both of them and made an application where hit &amp;#8216;counter&amp;#8217; now lies in Redis along with the hash &amp;#8216;channel&amp;#8217; that contains a mapping of &amp;#8216;timestamp&amp;#8217; =&amp;gt; &amp;#8216;counter value&amp;#8217;. On each request I will check if the &amp;#8216;counter&amp;#8217; exists; if no then I initialize it to 1 by set operation and set the hash value by hmset, if yes I increment the existing value and save that incremented value to map with hmset. Pretty basic and simple to understand (Like assigning a unique id to a user and making him join a chat channel). It can&amp;#8217;t get any simpler and practical. So I am putting NodeJS redis (used npm install hiredis redis; its all steroids!) client&amp;#8217;s &amp;#8220;asynchronous coolness&amp;#8221; with Java&amp;#8217;s uncool asynchronous Jedis and Jackson for JSON serialization. Later on I discovered &lt;a target="_blank" href="https://github.com/wg/lettuce"&gt;lettuce&lt;/a&gt; for Netty NIO as well, but I was too lazy to re-do benchmarks. Using lettuce will definitely improve the performance (or will it?). Let NodeJS have that advantage this time and see what results are we looking at. Here is the updated NodeJS &lt;a target="_blank" href="http://www.pastie.org/2498237"&gt;code&lt;/a&gt;, and updated &lt;a target="_blank" href="http://www.pastie.org/2498249"&gt;handler class&lt;/a&gt; and &lt;a target="_blank" href="http://www.pastie.org/2498255"&gt;singleton class&lt;/a&gt; of Java.&lt;/p&gt;
&lt;p&gt;Now back to benchmarks; running benchmarks with concurrency 1000 on NodeJS had a knockout, I started receiving connection reset by peer, super long delays (even with total 10000 requests it seemed like taking hours) and Redis running out of file numbers (Yes I&amp;#8217;ve opened my limits and done everything possible but it was not working). So we have to lower the concurrency a little bit (since all this is running on same machine); with concurrency level 100 I was able to run benchmarks so I took it as standard point for Java too. With concurrency 100 NodeJS was able to make 1.1K req/sec [&lt;a target="_blank" href="http://www.pastie.org/2498293"&gt;Raw Dump&lt;/a&gt;], and Java Netty NIO still managed 1.7K req/sec [&lt;a target="_blank" href="http://www.pastie.org/2498339"&gt;Raw Dump&lt;/a&gt;]; after concurrency level 100 I tried shots on concurrency level 500 and results were pretty much same [&lt;a target="_blank" href="http://www.pastie.org/2498320"&gt;NodeJS&lt;/a&gt; ~0.9K max][&lt;a target="_blank" href="http://www.pastie.org/2498329"&gt;Java&lt;/a&gt; ~1.4 max]!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;After some fiddling around I was able to make Node work! Pretty much same results (Infact they went down ~0.7K [&lt;a target="_blank" href="http://www.pastie.org/2498888"&gt;Raw Dump&lt;/a&gt;]), Netty keeps itself solid state [~1.3K &lt;a target="_blank" href="http://www.pastie.org/2498925"&gt;Raw Dump&lt;/a&gt;].&lt;/p&gt;
&lt;p&gt;So in conclusion:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;NodeJS is good for long open connections (I&amp;#8217;ve experienced that), but after this experiment I am pretty confident to roll something out on Netty NIO as well, the same design choice was made by plurk people (using NodeJS) but they reverted back to &lt;a target="_blank" href="http://amix.dk/blog/post/19577"&gt;Java Netty NIO&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Speed of execution has alot to do with what you can push out, Ruby is suffering today due to its bad garbage collector and speed (That&amp;#8217;s why Twitter abandoned it, that&amp;#8217;s why Linked in is using JRuby with Jetty stuff to make things happen). Reason I always praise Java is when it provides you with so many options to tune your application according to your requirement (Yes its not easy but its fruitful).&lt;/li&gt;
&lt;li&gt;Buzz words are dangerous! Stop looking at top trends and then adapting the technology.&lt;/li&gt;
&lt;li&gt;If you are good at X you can achieve almost the same scale in X as that of Y (Not always true) but only if you are really good at X (Facebook took PHP to next level, MySQL still lives in their core, Heroku guys have been scaling alot of apps on notorious Ruby, there are many examples out there, just dig!).&lt;/li&gt;
&lt;li&gt;If NodeJS was the best tool for scaling your requests it should have killed us all (even cockroaches).&lt;/li&gt;
&lt;li&gt;Node will mature over the time; I have a strong believe over that, and I will be a happy coder using Javascript as server side too.&lt;/li&gt;
&lt;li&gt;I am not asking you to leave NodeJS (who will help it grow then), things evolve out of experiments and we have to do it, but before holding the sword in your hand you should know the pros and cons.&lt;/li&gt;
&lt;li&gt;Stop yelling and bragging about NodeJS being fast!&lt;/li&gt;
&lt;li&gt;Thanks to everyone, I was pushed to do this experiment and make picture even clear! Lets move web forward.&lt;/li&gt;
&lt;/ul&gt;</description><link>http://blog.creapptives.com/post/9924551244</link><guid>http://blog.creapptives.com/post/9924551244</guid><pubDate>Wed, 07 Sep 2011 23:40:00 +0500</pubDate></item><item><title>Node on nails!</title><description>&lt;p&gt;Before I start this post let me be very clear and precise “I am not advising you to leave NodeJS or shift to Java [PERIOD!!!]”.&lt;/p&gt;
&lt;p&gt;I’ve been in this debate and there is a misunderstanding among my  geek friends that NodeJS is the future and blah blah blah… I totally  love Javascript (No bragging I have a history of being Javascript expert  and I’ve been writing some love for JS too); there is no doubt about  the beauty of closures, and the prototype styled programming. But when  it comes to have Javascript as back-end, its  totally a different story.&lt;/p&gt;
&lt;p&gt;I find it pretty amusing when people are doing benchmarks of some solid technology stack to NodeJS, and &lt;strong&gt;declaring&lt;/strong&gt; NodeJS to be the &lt;strong&gt;fastest&lt;/strong&gt; thing on earth (just Google NodeJS vs *anything that comes to your mind* and you’ll find results like &lt;a target="_blank" href="http://redmonk.com/sogrady/2010/05/13/node-js/"&gt;this&lt;/a&gt;, &lt;a target="_blank" href="http://tjholowaychuk.com/post/543953703/express-vs-sinatra-benchmarks"&gt;this&lt;/a&gt;, and &lt;a target="_blank" href="http://www.google.com/search?client=ubuntu&amp;amp;channel=fs&amp;amp;q=nodejs+vs+php&amp;amp;ie=utf-8&amp;amp;oe=utf-8#sclient=psy&amp;amp;hl=en&amp;amp;client=ubuntu&amp;amp;hs=LDX&amp;amp;channel=fs&amp;amp;source=hp&amp;amp;q=nodejs+vs+php&amp;amp;pbx=1&amp;amp;oq=nodejs+vs+php&amp;amp;aq=f&amp;amp;aqi=p-p1g-s1&amp;amp;aql=&amp;amp;gs_sm=e&amp;amp;gs_upl=34998l35597l1l36170l3l3l0l0l0l0l439l1121l2-1.0.2l3l0&amp;amp;bav=on.2,or.r_gc.r_pw.r_cp.&amp;amp;fp=7f38cb74ed69968b&amp;amp;biw=1366&amp;amp;bih=658"&gt;what not&lt;/a&gt;).  Beyond any doubt NodeJS model is worth attention, but will I use it in  my production environment? I doubt that. I’ve worked on NodeJS on real  serious basis; and experience was pretty bad. I had to write a complete  HTTP client library with Multipart support (Today known as &lt;a target="_blank" href="https://github.com/maxpert/Reston"&gt;Reston&lt;/a&gt;)  so that I can send files to Amazon S3 and few other REST services (at  that time there was no existing library with HTTP Multipart support,  HTTPS had issues and it was all really frustrating for me), to summarize  it I have to say following things to my audience:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Not every web application is &lt;strong&gt;many connections application&lt;/strong&gt;,  you don’t code a chat system or a comet system  everyday. NodeJS is  good at few things and should be used for them. If you ask me to code a  websocket based chat system using a IRC server, I would vote for NodeJS;  but if you ask me to pull emails from all your email accounts and store  them in some RDBMS or NOSQL store I would rather think twice.&lt;/li&gt;
&lt;li&gt;Technology stack is important! Accept it! Live with it! I’ve seen  people making wrong choices on technology stack (then bragging about it  just because they used NodeJS) and then abandoning it, because later  they discovered a better tool for doing the job.&lt;/li&gt;
&lt;li&gt;If its about event based code and its readability I am pretty sure  everybody agrees on the point that callback code is more spaghetti code  than normal flowing code.&lt;/li&gt;
&lt;li&gt;Static typed languages have a clear advantage over dynamic typed  languages. You won’t have any trouble absorbing this fact if you know  compiler internals.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Enough of my experience lets proceed to benchmarks. I have a  typical commodity machine (3GB RAM, Dual Core processor) and as ground  rules I will be doing straight forward benchmarks of Java NIO receiving a  HTTP request, and responding hello world to it; same applies for  NodeJS.&lt;/p&gt;
&lt;p&gt;NodeJS code is pretty straight &lt;a target="_blank" href="http://www.pastie.org/2467041"&gt;forward&lt;/a&gt;.  I’ve used Node version 0.4.9. Notice that it relies on the typical  ‘http’ module, which in turn relies on ‘net’, ‘stream’ etc. all of them  are NodeJS libraries (nothing special from me) and they rely on JIT of  V8 (accept the C parts) for speedy execution.&lt;/p&gt;
&lt;p&gt;Now for Java I took NIO of Java and selector channels to achieve the  same effect as NodeJS (single thread event dispatch). Code as expected  is a little longer since I had to write the looping part too, but  results are worth the experience. I’ve tried to put everything into a  single file as much as I can, so code is not modular/production-ready at  all! Here are the two files &lt;a target="_blank" href="http://www.pastie.org/2467119"&gt;Runner.java&lt;/a&gt; and &lt;a target="_blank" href="http://www.pastie.org/2467124"&gt;core.SocketSelectorCore.java&lt;/a&gt;.  I’ve used HashMaps, String split, indexOf etc. and done basic HTTP  header parsing of the request to simulate a normal request flow (read,  parse, respond cycle). I’ve used pretty inefficient methods, but they  are only there to make things worst for Java.&lt;/p&gt;
&lt;p&gt;So launching NodeJS with “&lt;em&gt;node test.js&lt;/em&gt;” and running Apache Benchmark (&lt;em&gt;ab -c 1000 -n 100000&lt;/em&gt;) 3 times with concurrency level of 1000 yields [&lt;a target="_blank" href="http://www.pastie.org/2467154"&gt;detailed dump&lt;/a&gt;] an average of almost 4 to 5 K requests per second.&lt;/p&gt;
&lt;p&gt;Now before putting the custom written Java NIO event based system on  trial; I would like to mention few things. Java is a beast, you get so  many options on how to tune the JVM ranging from garbage collection to  heap sizes (Checkout Java documentation in-case you are interested). So  for my scenario, I used following flags to run my JVM “&lt;em&gt;java -server -XX:+PrintCompilation -XX:+UseConcMarkSweepGC Runner&lt;/em&gt;”.  Notice I’ve used verbose mode for JIT compilation, so that I can know  when JVM is warmed up and I can take my benchmark samples; plus I  changed the GC method (I tried different methods, but I liked this one  the most). After the &lt;strong&gt;JVM warmed up &lt;/strong&gt;(Google it n00bs) and running same Apache Benchmarks [&lt;a target="_blank" href="http://www.pastie.org/2467243"&gt;detailed dump&lt;/a&gt;], Java was able to manage 8 to 8.5 K requests per second.&lt;/p&gt;
&lt;p&gt;I tried different Heap Sizes and played around with other parameters;  results were interesting. I was always above 6K requests per second on  my machine. Lowering the concurrency (-c 100) takes figures as high as  11K. If you notice closely I was shipping more bytes per request (as  compared to NodeJS), but that didn’t hurt Java and even with my really  stupid approach for storing headers I was able to make it this far.  Having these results at hand I also played around with JRuby for  syntactic awesomeness and wrote a throw away &lt;a target="_blank" href="http://www.pastie.org/2467302"&gt;code&lt;/a&gt; (Complete replica of Java code). And with a pretty rough code and a  minor different flags passed to JRuby, I was again able to manage 4 -  4.5 K requests per second.&lt;/p&gt;
&lt;p&gt;So question now remains is why did I do this, and whats the take  away? I think answers are pretty clear. I personally love Javascript and  NodeJS but I won’t take the argument NodeJS can do &lt;em&gt;X&lt;/em&gt; that language &lt;em&gt;Y&lt;/em&gt; can’t do. I believe comparing Java or PHP or some X to NodeJS is a  stupid buzz that appeared recently. JIT of Java is pretty much state of  art, and Google guys are putting in a great effort to bring V8 up-to  mark. Frameworks like Netty NIO and Mina have been sitting out there for  long time, but have been ignored due to Java’s weird syntax, memory  hunger or steep learning curve reasons (I am just saying). Having said  all that I’ve just busted the myth, “NodeJS can handle more connections  due to its async style, and it enforces you to write code in  callback(async) style; thus you write better code”. My answer is pretty  simple “Write the core part in Java, wrap it in the JRuby or Scala  beauty; and you have a much better way of expressing event driven  system”.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT: September 2nd 2011&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well I&amp;#8217;ve been busy with work lately and seems like I had a nuclear   melt down; and before I knew it the whole reactor exploded! In my &lt;a target="_blank" href="http://maxpert.tumblr.com/post/9677133069/node-on-nails"&gt;previous post Node on Nails&lt;/a&gt; (I just realized I am good in making titles like these), just to purse   the curiosity I tried to create a basic Java based NIO HTTP system and   see the numbers with Node. Here is what I think reactions concluded for   me (Will be helpful to you and me when writing a blog post):&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Never ever use the word &lt;strong&gt;n00bs&lt;/strong&gt; (although I tried  to point the people who hear about node and switch to  it instantly) it  makes me sound like attacking you personally.&lt;/li&gt;
&lt;li&gt;Avoid &lt;strong&gt;scandalish&lt;/strong&gt; titles which I think is right; but I can&amp;#8217;t avoid it (I will try to I promise).&lt;/li&gt;
&lt;li&gt;Never &lt;strong&gt;criticize&lt;/strong&gt; the technology or any tool I have a  crush on (NodeJS in this case);  initial roll was pretty encouraging  towards Java but later comments  really show the people about to bang  their head in the walls and not  being able to convince me with anything  concrete.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starting an article with such disclaimer never matters&lt;/strong&gt;;   you have to show the other site no matter if it is openly available.&lt;/li&gt;
&lt;li&gt;Languages and tools evolve over time; one of the good factors for evolution is criticizing mistakes! &lt;strong&gt;Fanboys don&amp;#8217;t take criticism constructively so there must be another way around&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;People in today&amp;#8217;s world believe that &lt;strong&gt;static typed can be beaten with dynamic typed&lt;/strong&gt; languages.&lt;/li&gt;
&lt;li&gt;I  always used this blog as personal space for letting out such   benchmarks, ideas, discussions. But since people take it too seriously I   have to be more careful &lt;strong&gt;making it more formal&lt;/strong&gt; (People commented on English spell mistakes at times as if it was an English exam).&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Although  I was busy at work, but the exploding hatred called me  to address the  issue; don&amp;#8217;t worry I will still be doing more work on  it as I get more  time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit: 6-Sep 2011&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve done some more benchmarks with a full fledged framework. If you have objections on this benchmark &lt;a target="_blank" href="http://maxpert.tumblr.com/post/9924551244/the-node-redumption"&gt;try new ones out&lt;/a&gt;.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/9677133069</link><guid>http://blog.creapptives.com/post/9677133069</guid><pubDate>Fri, 02 Sep 2011 01:43:00 +0500</pubDate><category>javascript</category><category>java</category><category>nio</category></item><item><title>LevelDB vs Kyoto Cabinet my findings</title><description>&lt;p&gt;I&amp;#8217;ve been pretty excited about Google&amp;#8217;s LevelDB, not to mention there are some really old tanks already in the battle field like BDB, Tokyo Cabinet (Kyoto Cabinet as new one), HamsterDB etc. Fortunately I&amp;#8217;ve already worked with Kyoto Cabinet and when I looked at the &lt;a target="_blank" href="http://leveldb.googlecode.com/svn/trunk/doc/benchmark.html"&gt;benchmarks&lt;/a&gt; I was totally blown away. I have a strong prejudice to name Google, but the benchmark results were way too good to believe. I also had an objection; LevelDB benchmarks compared itself only to TreeDB of Kyoto and not the HashDB (If ignoring key ordering and treating LevelDB to be true key value only). Some of you may start yelling right away that comparing Hash structure to an SSTable is not fair or something. Well by end of this post I will be comparing TreeDB with LevelDB as well and my results were different from officially posted benchmarks.&lt;/p&gt;
&lt;p&gt;So to start off I decided to do a simple insertion, and iteration comparison (ignoring order) of simple HashDB and LevelDB without any compression or any sugar both stores come with, it will be a simple (no forced writes) benchmark of both comparing how much time each takes. I have a pretty normal machine (aka a commodity machine) with a &lt;a target="_blank" href="http://pastie.org/1571548"&gt;normal HDD&lt;/a&gt;, and &lt;a target="_blank" href="http://pastie.org/1571529"&gt;Intel Dual Core&lt;/a&gt; 3GB RAM. So without wasting anymore time; lets dive into code. Here is code for &lt;a target="_blank" href="http://www.pastie.org/2293687"&gt;HashDB Kyoto&lt;/a&gt; and &lt;a target="_blank" href="http://www.pastie.org/2293694"&gt;LevelDB&lt;/a&gt;. Pretty straight forward; I&amp;#8217;ve carefully placed benchmarks point to only measure the &amp;#8220;real time&amp;#8221; consumed by both excluding additional key preparation and value preparation parts. The idea is to insert and iterate 100,000 key/value pairs. Running the benchmarks yield (Please note the first line indicates the time to insert 100,000 KV pairs, and second line indicates the time it took to iterate all those KV pairs, every time db was created from scratch i.e. previous copy was deleted. I took total 3 runs of each):&lt;/p&gt;
&lt;p&gt;Kyoto Cabinet 100,000 entries:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Time consumed was 0.328945&lt;br/&gt;Time consumed was 0.207315&lt;/li&gt;
&lt;li&gt;Time consumed was 0.286653&lt;br/&gt;Time consumed was 0.210296&lt;/li&gt;
&lt;li&gt;Time consumed was 0.284954&lt;br/&gt;Time consumed was 0.208595&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;LevelDB 100,000 entries:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Time consumed was 0.44742&lt;br/&gt;Time consumed was 0.171842&lt;/li&gt;
&lt;li&gt;Time consumed was 0.449287&lt;br/&gt;Time consumed was 0.169108&lt;/li&gt;
&lt;li&gt;Time consumed was 0.444432&lt;br/&gt;Time consumed was 0.169381&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Iterated reads are pretty fast in LevelDB, but writes are almost twice as slow as Kyoto Cabinet. I didn&amp;#8217;t stop here because I&amp;#8217;ve not hit the weak spot of LevelDB yet (yes larger values). So in my next test I fixed the length of value buffer to 512 bytes instead of the small string length, results took the expected form:&lt;/p&gt;
&lt;p&gt;Kyoto Cabinet HashDB 512 bytes 100,000 entries:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Time consumed was 0.549354&lt;br/&gt;Time consumed was 0.249182&lt;/li&gt;
&lt;li&gt;Time consumed was 0.451567&lt;br/&gt;Time consumed was 0.236295&lt;/li&gt;
&lt;li&gt;Time consumed was 0.568072&lt;br/&gt;Time consumed was 0.240299&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;LevelDB 512 bytes 100,000 entries:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Time consumed was 5.09164&lt;br/&gt;Time consumed was 0.302542&lt;/li&gt;
&lt;li&gt;Time consumed was 5.16017&lt;br/&gt;Time consumed was 0.301258&lt;/li&gt;
&lt;li&gt;Time consumed was 5.32948&lt;br/&gt;Time consumed was 0.300175&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;At this point I became suspicious about the &lt;strong&gt;TreeDB&lt;/strong&gt; benchmarks by &lt;strong&gt;LevelDB&lt;/strong&gt; being true on my machine; and guess what, I was right! Here are benchmarks of TreeDB of Kyoto Cabinet:&lt;/p&gt;
&lt;p&gt;TreeDB with Fixed 512 byte value length:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Time consumed was 0.393798&lt;br/&gt;Time consumed was 0.445125&lt;/li&gt;
&lt;li&gt;Time consumed was 0.389259&lt;br/&gt;Time consumed was 0.439923&lt;/li&gt;
&lt;li&gt;Time consumed was 0.392562&lt;br/&gt;Time consumed was 0.438211&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;TreeDB with small length values (same as 1st HashDB benchmarks above):&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Time consumed was 0.39401&lt;br/&gt;Time consumed was 0.322735&lt;/li&gt;
&lt;li&gt;Time consumed was 0.445422&lt;br/&gt;Time consumed was 0.349465&lt;/li&gt;
&lt;li&gt;Time consumed was 0.287259&lt;br/&gt;Time consumed was 0.258459&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Finally I took the total entries to 1,000,000 and ran a benchmark again with &lt;a target="_blank" href="http://www.pastie.org/2295228"&gt;TreeDB&lt;/a&gt;, and &lt;a target="_blank" href="http://www.pastie.org/2295237"&gt;LevelDB&lt;/a&gt;; results are as following:&lt;/p&gt;
&lt;p&gt;LevelDB 1,000,000 entries (small values to give it an advantage):&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Time consumed was 5.9836&lt;br/&gt;Time consumed was 1.91519&lt;/li&gt;
&lt;li&gt;Time consumed was 6.03402&lt;br/&gt;Time consumed was 1.90402&lt;/li&gt;
&lt;li&gt;Time consumed was 6.01079&lt;br/&gt;Time consumed was 1.88251&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;TreeDB 1,000,000 entries (small values):&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Time consumed was 3.9333&lt;br/&gt;Time consumed was 2.56793&lt;/li&gt;
&lt;li&gt;Time consumed was 3.87633&lt;br/&gt;Time consumed was 2.56836&lt;/li&gt;
&lt;li&gt;Time consumed was 3.93033&lt;br/&gt;Time consumed was 2.57917&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Surprised? Same here! Now the question is am I missing something? I am planning to put up some more benchmarks with some real life scenarios and values (may be a tweet sized stuff). Until then I would love to have feedback, and know if I&amp;#8217;ve done any mistake while benchmarking.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/8330476086</link><guid>http://blog.creapptives.com/post/8330476086</guid><pubDate>Mon, 01 Aug 2011 10:56:48 +0500</pubDate><category>leveldb</category><category>kyoto cabinet</category><category>kyoto</category><category>cabinet</category><category>benchmarks</category></item><item><title>JRuby vs Ruby the 2011 shodown</title><description>&lt;p&gt;Well its been long time and I&amp;#8217;ve been sitting quite in a corner waiting for this loud fight between the two Rubies to end. I once had a &lt;strong&gt;debate&lt;/strong&gt; with one of ruby pro (when 1.9.1 was newly out) that JRuby can always stay ahead in speed (There are a-lot details available on how it does that for example &lt;a target="_blank" href="http://blog.headius.com/2009/04/how-jruby-makes-ruby-fast.html"&gt;this one&lt;/a&gt;). I had to start a project recently and choose a platform; ruby was obvious choice, after doing first few iterations when it came to select a database I realised Java has much better support for NoSQL stores than ruby (I can see people getting offended here; but accept it and live with it!) which lead me to the same old discussion in my mind which one is &lt;strong&gt;faster&lt;/strong&gt;? I poked around on Google and found some mixed results. So I made up my mind and decided to do benchmarks myself! Here are the rules of game:&lt;/p&gt;
&lt;p&gt;I will give each ruby complete isolation (ruby 1.9.2 and jruby 1.6.3 both latest stables) and 3 runs on same code just before starting off I will take the system time in milliseconds and at the end print out the total time elapsed. Since I don&amp;#8217;t care about the start up time consumed I am pretty carelessly selecting jruby optimising &amp;#8220;server&amp;#8221; mode (perfect for web application scenario). My machine is a normal laptop with &lt;a target="_blank" href="http://pastie.org/1571529"&gt;Intel Dual Core &lt;/a&gt;, 3GB RAM, and &lt;a href="http://pastie.org/1571548" target="_blank"&gt;a pretty normal HDD&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Time to bust the bubble!&lt;/p&gt;
&lt;p&gt;Run 1 focuses on calculation intensive thing; for that I took one of codes from Internet of generating random numbers you can view &lt;a target="_blank" href="http://www.pastie.org/2184361"&gt;source code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Ruby Runtime:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;2.3871424198150635&lt;/li&gt;
&lt;li&gt;2.309985637664795&lt;/li&gt;
&lt;li&gt;2.3948707580566406&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;JRuby Runtime:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;2.22599983215332&lt;/li&gt;
&lt;li&gt;2.19400000572205&lt;/li&gt;
&lt;li&gt;2.21500015258789&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Ok fine (it was close) may be Java&amp;#8217;s JIT or something else made.&lt;br/&gt;So, Run 2 focuses on class instantiation and dynamic module extension, you can view source code &lt;a target="_blank" href="http://www.pastie.org/2184409"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Ruby Runtime:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;10.353898525238037&lt;/li&gt;
&lt;li&gt;10.456978797912598&lt;/li&gt;
&lt;li&gt;10.417702436447144&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;JRuby Runtime:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;7.58999991416931&lt;/li&gt;
&lt;li&gt;7.75600004196167&lt;/li&gt;
&lt;li&gt;7.68299984931946&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;I am stopping right here for now; I mean why can&amp;#8217;t a native language code beat a same code on top of JVM? It&amp;#8217;s pretty obvious, I have to make some more benchmarks before I make a decision and put the nail in the coffin; So until I do that you people to enjoy this, give me your feedback and may be start thinking about porting your code to &lt;strong&gt;JRuby&lt;/strong&gt; if its worth it!&lt;/p&gt;
&lt;p&gt;To be continued&amp;#8230;&lt;/p&gt;</description><link>http://blog.creapptives.com/post/7390601334</link><guid>http://blog.creapptives.com/post/7390601334</guid><pubDate>Sat, 09 Jul 2011 00:28:00 +0500</pubDate></item><item><title>Yet NOSQL dogma</title><description>&lt;p&gt;Recently &lt;a target="_self" href="http://maxpert.tumblr.com/post/3329352663/the-nosql-dogma"&gt;I posted&lt;/a&gt; some benchmarks on how can you tame MySQL to get the Key-Value behavior, (You can do almost same to get that column family behavior its all about your imagination *grinnn*) lets bullet down exactly what I meant when I used MySQL with HandlerSocket:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;First and foremost whatever you write or read is on &lt;strong&gt;disk (persistent)&lt;/strong&gt;! Its not living in volatile memory (until you really make your table in-memory).&lt;/li&gt;
&lt;li&gt;Concurrency; MySQL speaks for itself and I don&amp;#8217;t think we need any discussion on this.&lt;/li&gt;
&lt;li&gt;MySQL was used because it is free, plus I found Handler-Socket which saved me time.&lt;/li&gt;
&lt;li&gt;Not being antiquated I use NOSQL technologies (I&amp;#8217;ve used Cassandra, Redis, MongoDB, TokyoTyrant, CouchDB, Redis and HBase nothing to brag about; but for proof of fact that am not technology allergic or afraid of something).&lt;/li&gt;
&lt;li&gt;A relational database won&amp;#8217;t be relational until you really define relationships yourself (and enforce them)! So don&amp;#8217;t blame them for slowing down an &lt;strong&gt;insert&lt;/strong&gt; just because you enforced a refrential integrity constraint, or unintentionally did a &lt;strong&gt;join&lt;/strong&gt;. I totally hate this part, because people usually take so much pain in de-normalizing data for NOSQL databases, but when it comes to a SQL database they feel offended by denormalized structure.&lt;/li&gt;
&lt;li&gt;We get a &lt;strong&gt;stable storage engine&lt;/strong&gt;! I am mentioning it again because I don&amp;#8217;t believe in stability of NOSQL storage systems, they are pretty young when compared to these RDBMS reptiles.&lt;/li&gt;
&lt;li&gt;There is no deterministic way for guaranteeing the number of disk seeks or reads until you go for really raw disk level, and believe it or not some databases support that (&lt;a target="_blank" href="http://dev.mysql.com/doc/refman/5.0/en/innodb-raw-devices.html"&gt;MySQL&lt;/a&gt; in my case).&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Given all this I did some benchmarks and as expected the NOSQL community was &lt;strong&gt;hurt&lt;/strong&gt; and this is what one of &lt;a title="MyNOSQL response" target="_blank" href="http://nosql.mypopescu.com/post/3332197551/the-nosql-dogma"&gt;them&lt;/a&gt; thinks:&lt;/p&gt;
&lt;blockquote&gt;&lt;ol&gt;&lt;li&gt;with a similar setup, a NoSQL solution like&lt;strong&gt; Redis&lt;/strong&gt; might give you even more operations per second&lt;/li&gt;
&lt;li&gt;key-value only access might not be enough. Many NoSQL solutions are offering at least &lt;strong&gt;MapReduce&lt;/strong&gt; support.&lt;/li&gt;
&lt;/ol&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;em&gt;&amp;#8212; Quoted from &lt;a target="_blank" href="http://nosql.mypopescu.com/post/3332197551/the-nosql-dogma"&gt;mynosql blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;And I think answers to what they say are pretty simple. &lt;strong&gt;Redis&lt;/strong&gt; is not something to be compared to MySQL; why? Because, its not &lt;strong&gt;truly persistent&lt;/strong&gt;. You have &lt;a target="_blank" href="http://redis.io/topics/persistence"&gt;options&lt;/a&gt; to either do&lt;strong&gt; Append Only File fsync&lt;/strong&gt; which can be &lt;em&gt;timer based &lt;/em&gt;(not reliable) or on every write (try this option and your system will be dead doing writes all the time!), or &lt;strong&gt;save &lt;/strong&gt;based on time interval in seconds (not reliable as quoted by Redis themselves), or the manual &lt;strong&gt;save&lt;/strong&gt; command (a bomb in your head if you use save button frequently). In short &lt;strong&gt;Redis&lt;/strong&gt; is truly &lt;strong&gt;memcached&lt;/strong&gt; on steroids. Comparing &lt;strong&gt;MySQL &lt;/strong&gt;to &lt;strong&gt;Redis &lt;/strong&gt;is like comparing two different genres; where choosing one is matter of your requirements.&lt;/p&gt;
&lt;p&gt;To answer &lt;strong&gt;MapReduce&lt;/strong&gt; part; let me be very clear &lt;strong&gt;MapReduce&lt;/strong&gt; was made by Google to meet its own needs, which is no where near the general business needs. Plus MapReduce is used as substitute to SQL; and thats how powerful SQL is ( Yep they have articles on it ); its like a runtime compiler + storage engine. So its not fair to compare a stripped down version of a (at times pre-compiled) routine to such a flexible thing (SQL).&lt;/p&gt;
&lt;p&gt;Keeping things simple, here is what I want to say: &amp;#8220;Keep NOSQL as Not &lt;strong&gt;Only&lt;/strong&gt; SQL, rather than &lt;strong&gt;No&lt;/strong&gt;SQL due to some buzz word or marketing cliche&amp;#8221;. I&amp;#8217;ve not been paid by SUN to market MySQL, but I completely hate it when people make useless assumptions about the speeds, and put so much effort designing so much denormalized NOSQL structures which could have been achieved in an SQL database (without scattering data, avoiding additional headache different API, updates, bugs and maintainability issues).&lt;/p&gt;</description><link>http://blog.creapptives.com/post/4530634931</link><guid>http://blog.creapptives.com/post/4530634931</guid><pubDate>Mon, 11 Apr 2011 23:42:42 +0500</pubDate><category>nosql</category><category>mysql</category><category>bechmark</category><category>speed</category><category>comparison</category></item><item><title>Compiling TokyoCabinet with Java API under Ubuntu</title><description>&lt;p&gt;Duhh&amp;#8230; It may waste a little time (Java part only) so I thought better make it a blog post; so that everybody can save some time.&lt;/p&gt;
&lt;p&gt;Get your copy of &lt;a title="TokyoCabinet" target="_blank" href="http://fallabs.com/tokyocabinet/"&gt;TokyoCabinet&lt;/a&gt; and Java API ( both are available on same page ) and extract them; First you will have to compile TokyoCabinet and that I think is pretty simple; I compiled my copy disabling bzip and enabling 64 bit offset like this&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;./configure &amp;#8212;disable-bzip &amp;#8212;enable-off64&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt;make&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt;sudo make install&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt;sudo ldconfig&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Make sure you don&amp;#8217;t get any errors; if you do google will help you out here.&lt;/p&gt;
&lt;p&gt;Time for Java API where things got messy for me to figure out; for this you have to make sure you have openjdk-6-jdk installed (I also had openjdk-6-source on my system).&lt;/p&gt;
&lt;p&gt;Once done go to tokyocabinet Java API source directory and now if you do a ./configure you will get an error saying:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;configure: error: jni.h is required&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;After doing some &lt;strong&gt;find &lt;/strong&gt;commands on my /usr/lib/jvm I figured out the problem and here is how you can solve the niche&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CPPFLAGS=&amp;#8221;-I/usr/lib/jvm/java-6-openjdk/include/&amp;#8221; ./configure&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Note the path /usr/lib/jvm/java-6-openjdk/include/ is the path were your &lt;strong&gt;jni.h&lt;/strong&gt; is present; this will vary distro to distro and you can easily google for it. Once done under ubuntu doing a simple &lt;strong&gt;make&lt;/strong&gt; will once again give you a huge list of errors (yep you guessed it). Here is how you will fix that under &lt;strong&gt;ubuntu&lt;/strong&gt; (solution will vary from distro to distro):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;INCLUDEDIR=/usr/lib/jvm/java-6-openjdk/include make&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Bummers I got some errors again; but this time I modified the Makefile (Again will vary from distro to distro)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt; JAVAC = /usr/bin/javac&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt; JAVACFLAGS = -source 1.4 -d .&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt; JAR = /usr/bin/jar&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt; JAVAH = /usr/bin/javah&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt; JAVADOC = /usr/bin/javadoc&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt; JAVARUN = /usr/bin/java&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;this time&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;INCLUDEDIR=/usr/lib/jvm/java-6-openjdk/include make&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt;sudo make install&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt;sudo ldconfig&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;works fine. Once compiled don&amp;#8217;t forget to copy the libjtokyocabinet.so to your jre lib binaries (&lt;strong&gt;sudo cp /usr/local/lib/libjtokyocabinet.so /usr/lib/jvm/java-6-openjdk/jre/lib/i386/.&lt;/strong&gt;). You can go ahead enjoy the treat of adding the .jar files as dependencies and have fun with the cabinet!&lt;/p&gt;</description><link>http://blog.creapptives.com/post/3467391298</link><guid>http://blog.creapptives.com/post/3467391298</guid><pubDate>Thu, 24 Feb 2011 00:07:00 +0500</pubDate></item><item><title>The NoSQL Dogma</title><description>&lt;blockquote&gt;
&lt;p&gt;&lt;span class="body"&gt;Every dogma has its day &amp;#8212; &lt;strong&gt;Anthony Burgess&lt;/strong&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span&gt;And yes I&amp;#8217;ve been living the  NoSQL dogma! The technologies like &lt;strong&gt;HBase&lt;/strong&gt;, &lt;strong&gt;Voldermort&lt;/strong&gt;, &lt;strong&gt;CouchDB&lt;/strong&gt;, and a  huge list of others (each designed for a particular scenario) made  me believe; that my favorite RDBMS MySQL has grown old and it can&amp;#8217;t handle my data anymore. When ever I encountered the API&amp;#8217;s of these noSQL  tools, I realized they are super trivial ( there are exceptions like  MongoDB ), they are in no way as &amp;#8220;rich&amp;#8221; as SQL itself is. Secondly the  rich &amp;#8220;structure&amp;#8221; and the &amp;#8220;value&amp;#8221; is gone (document stores are not always usable in real world scenarios, most of the time we are doing the key value look up).&lt;/span&gt;&lt;br/&gt;&lt;span&gt;Long story cut short; everybody just ignores the effort these beautiful&lt;/span&gt;&lt;span&gt; cre&lt;/span&gt;&lt;span&gt;atures (RDBMSs) put into your daily problems; take care of issues like &lt;/span&gt;&lt;span&gt;parsing&lt;/span&gt;&lt;span&gt;, queuing and all the dirty st&lt;/span&gt;&lt;span&gt;uff &lt;/span&gt;&lt;span&gt;they are doing for you. So next question should be; if I get rid of SQL from My&lt;/span&gt;&lt;span&gt;SQL &lt;/span&gt;&lt;span&gt;(Just a specific case I am pretty sure we can do it on other engines as well)&lt;/span&gt;&lt;span&gt; wou&lt;/span&gt;&lt;span&gt;ld it be ( only My ) any faster? Seems like &lt;strong&gt;yes&lt;/strong&gt;. I would be demonstrating the &lt;em&gt;benchmar&lt;/em&gt;&lt;/span&gt;&lt;em&gt;&lt;span&gt;ks &lt;/span&gt;&lt;/em&gt;&lt;span&gt;i&lt;/span&gt;&lt;span&gt;n a while. But before proceeding I would like to mention clearly that these &lt;/span&gt;&lt;span&gt;benchmark&lt;/span&gt;&lt;span&gt; values have pretty clearly proved me that &lt;/span&gt;&lt;span&gt;a&lt;/span&gt;&lt;span&gt; RD&lt;/span&gt;&lt;span&gt;B&lt;/span&gt;&lt;span&gt;MS when stripped o&lt;/span&gt;&lt;span&gt;ff f&lt;/span&gt;&lt;span&gt;ro&lt;/span&gt;&lt;span&gt;m th&lt;/span&gt;&lt;span&gt;e additional over-heads performs as good as any &lt;/span&gt;&lt;span&gt;persistent&lt;/span&gt;&lt;span&gt; key-value s&lt;/span&gt;&lt;span&gt;tore&lt;/span&gt;&lt;span&gt; (Yep its my personal opinion and I know &lt;/span&gt;&lt;span&gt;noSQL&lt;/span&gt;&lt;span&gt; co&lt;/span&gt;&lt;span&gt;mmunity is hurt by this statement). In my demo I will be replicating a presistent &lt;/span&gt;&lt;span&gt;Key&lt;/span&gt;&lt;span&gt;/Va&lt;/span&gt;&lt;span&gt;lue &lt;/span&gt;&lt;span&gt;store&lt;/span&gt;&lt;span&gt; us&lt;/span&gt;&lt;span&gt;ing MySQL and &lt;/span&gt;&lt;span&gt;HandlerSocket&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span&gt;To&lt;/span&gt;&lt;span&gt;ols of &lt;/span&gt;&lt;span&gt;trade&lt;/span&gt;&lt;br/&gt;&lt;span&gt;I spent a whole day compiling these tools on my machine but by the end of the day it was a satisfaction (You should try as well)! You will require:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;span&gt;A MySQL 5.5.9 ( Latest Stable till date ) &lt;/span&gt;&lt;a target="_blank" href="http://www.google.com/url?sa=D&amp;amp;q=http%3A%2F%2Fdev.mysql.com%2Fget%2FDownloads%2FMySQL-5.5%2Fmysql-5.5.9.tar.gz%2Ffrom%2Fhttp%3A%2F%2Fwww.mirrorservice.org%2Fsites%2Fftp.mysql.com%2F"&gt;Source Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;A Ha&lt;/span&gt;&lt;span&gt;ndlerSocket&lt;/span&gt;&lt;span&gt; ( Latest pull from Github ) &lt;/span&gt;&lt;a target="_blank" href="http://www.google.com/url?sa=D&amp;amp;q=https%3A%2F%2Fgithub.com%2Fahiguti%2FHandlerSocket-Plugin-for-MySQL%2Fcommit%2F159ea6d2678256fef7ddad74cd86cb12af2fd2aa"&gt;Latest Commit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Lovely Python 2.6.5 ( Comes on my debian )&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Newborn Python Socket Handler ( Latest ) &lt;/span&gt;&lt;a target="_blank" href="http://www.google.com/url?sa=D&amp;amp;q=http%3A%2F%2Fpypi.python.org%2Fpypi%2Fpython-handler-socket"&gt;Homepage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;And lots of &lt;/span&gt;&lt;span&gt;patience&lt;/span&gt;&lt;span&gt; for compiling MySQL+HandlerSocket&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;br/&gt;&lt;span&gt;Se&lt;/span&gt;&lt;span&gt;tting the stage&lt;/span&gt;&lt;br/&gt;&lt;span&gt;Once compiled and system is ready next thing would be cr&lt;/span&gt;&lt;span&gt;eati&lt;/span&gt;&lt;span&gt;ng a &lt;/span&gt;&lt;span&gt;basic schema and table for storing &lt;/span&gt;&lt;span&gt;t&lt;/span&gt;&lt;span&gt;he &lt;/span&gt;&lt;span&gt;values; here is my basic schema named &lt;em&gt;&amp;#8216;foo&amp;#8217;&lt;/em&gt; and table named &lt;em&gt;&amp;#8216;kv&amp;#8217;&lt;/em&gt;:&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;CR&lt;/span&gt;&lt;span&gt;EATE TABLE `foo`.`kv` (&lt;/span&gt;&lt;br/&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt; `key` CHAR(255)  NOT NULL,&lt;/span&gt;&lt;br/&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt; `val` TEXT  NOT NULL,&lt;/span&gt;&lt;br/&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt; PRIMARY KEY (`key`)&lt;/span&gt;&lt;br/&gt;&lt;span&gt; )&lt;/span&gt;&lt;span&gt; E&lt;/span&gt;&lt;span&gt;NGINE = MyISAM;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;br/&gt;&lt;span&gt;Darn simple (I&amp;#8217;ve  used key as CHAR for now, INT will be definitely faster);  realistically 255 is more than enough for a key to store its value (until you prove  your self a Jimmy).&lt;/span&gt;&lt;br/&gt;&lt;span&gt;For my Python code &lt;/span&gt;&lt;a target="_blank" href="http://www.google.com/url?sa=D&amp;amp;q=http%3A%2F%2Fpastie.org%2F1571414"&gt;here is the complete code&lt;/a&gt;&lt;span&gt; that I used to benchmark my results.&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span&gt;Machine specs&lt;/span&gt;&lt;br/&gt;&lt;span&gt;My machine is just a normal laptop with following specs:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;span&gt;CPU - &lt;/span&gt;&lt;a target="_blank" href="http://www.google.com/url?sa=D&amp;amp;q=http%3A%2F%2Fpastie.org%2F1571529"&gt;&lt;a href="http://pastie.org/1571529" target="_blank"&gt;http://pastie.org/1571529&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;3GB RAM&lt;/li&gt;
&lt;li&gt;Disk - &lt;a target="_blank" href="http://www.google.com/url?sa=D&amp;amp;q=http%3A%2F%2Fpastie.org%2F1571548"&gt;&lt;a href="http://pastie.org/1571548" target="_blank"&gt;http://pastie.org/1571548&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;span&gt;Results&lt;/span&gt;&lt;br/&gt;&lt;span&gt;Yep time for moment of truth, I inserted a hundered &lt;/span&gt;&lt;span&gt;thousand&lt;/span&gt;&lt;span&gt; (100,000) entries with a varying key &lt;/span&gt;&lt;span&gt;sizes&lt;/span&gt;&lt;span&gt; (see the code you will get what I am saying its pattern is like key0 - key99999 ),&lt;/span&gt;&lt;span&gt; bu&lt;/span&gt;&lt;span&gt;t a value of constant string with a size of 1K ( If I was a twitter it would have been much less&lt;/span&gt;&lt;span&gt; ). Here are the statistics (&lt;/span&gt;&lt;a target="_blank" href="http://www.google.com/url?sa=D&amp;amp;q=http%3A%2F%2Fpastie.org%2F1571421"&gt;Full console dump&lt;/a&gt;&lt;span&gt;):&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;span&gt;100,000 writes took 29.6542 seconds ( ~ &lt;strong&gt;3372 writes / second&lt;/strong&gt; ) &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;100,000 reads in order took 18.4197 seconds ( ~ &lt;strong&gt;5429 reads / second&lt;/strong&gt; )&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;100,000&amp;#160;&lt;/span&gt;&lt;span&gt;reads&lt;/span&gt;&lt;span&gt; in&lt;/span&gt;&lt;span&gt; random order 17.0343 seconds ( ~ &lt;strong&gt;5870 reads / second&lt;/strong&gt; ) (Socking!)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;br/&gt;&lt;span&gt;I would like to add I have used the &lt;/span&gt;&lt;span&gt;default settings of MyISAM&lt;/span&gt;&lt;span&gt; ( default ones with make install ), plus I repeated the experiment without &lt;/span&gt;&lt;span&gt;truncating &lt;/span&gt;&lt;span&gt;the tables (Nothing just happened it remain almost same every-time).&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span&gt;Whats the point?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;MySQL is a proven technology, its engines are &lt;/span&gt;&lt;span&gt;stable and well known, and scalable ( Yep &lt;/span&gt;&lt;span&gt;modern&lt;/span&gt;&lt;span&gt; fo&lt;/span&gt;&lt;span&gt;rks &lt;/span&gt;&lt;span&gt;fo&lt;/span&gt;&lt;span&gt;r&lt;/span&gt;&lt;span&gt; clouds are already rolling one example is &lt;/span&gt;&lt;a target="_blank" href="http://www.google.com/url?sa=D&amp;amp;q=http%3A%2F%2Fdrizzle.org%2F"&gt;drizzle&lt;/a&gt;&lt;span&gt;); so I can&amp;#8217;t find any point in shifting to a technology thats a &lt;em&gt;new born&lt;/em&gt;, adds more calories to my code, and then &lt;/span&gt;&lt;span&gt;brag&lt;/span&gt;&lt;span&gt; about it just because its a buzz word! Untill&lt;/span&gt;&lt;span&gt; th&lt;/span&gt;&lt;span&gt;ere is no &lt;/span&gt;&lt;span&gt;genuine&lt;/span&gt;&lt;span&gt; re&lt;/span&gt;&lt;span&gt;ason to have a &lt;/span&gt;&lt;span&gt;noSQL&lt;/span&gt;&lt;span&gt; it&lt;/span&gt;&lt;span&gt;s just a trendy statement! I am pretty sure by &lt;/span&gt;&lt;span&gt;tuning&lt;/span&gt;&lt;span&gt; so&lt;/span&gt;&lt;span&gt;me more parameters, I can take these reads and writes to a higher number. Taking the same code on a server machine will off-course make these numbers even better. Despite all factors missing on a normal machine it was an impressive performance. For comparisons sake I would be making no &lt;/span&gt;&lt;span&gt;excu&lt;/span&gt;&lt;span&gt;ses and posting benchmarks for other &lt;/span&gt;&lt;span&gt;noSQL&lt;/span&gt;&lt;span&gt; sy&lt;/span&gt;&lt;span&gt;stems from my machine.&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So it was my last day of &lt;/span&gt;&lt;strong&gt;&lt;span&gt;noSQL&lt;/span&gt;&lt;span&gt; d&lt;/span&gt;&lt;span&gt;o&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;&lt;strong&gt;gma&lt;/strong&gt; what about you?&lt;span class="__wave_paste" data-wave-annotations="0,1889,style%2FfontFamily,sans-serif:1367,1381,style%2FfontWeight,bold:1547,1558,link%2Fmanual,http%3A%2F%2Fdev.mysql.com%2Fget%2FDownloads%2FMySQL-5.5%2Fmysql-5.5.9.tar.gz%2Ffrom%2Fhttp%3A%2F%2Fwww.mirrorservice.org%2Fsites%2Fftp.mysql.com%2F:1602,1617,link%2Fmanual,https%3A%2F%2Fgithub.com%2Fahiguti%2FHandlerSocket-Plugin-for-MySQL%2Fcommit%2F159ea6d2678256fef7ddad74cd86cb12af2fd2aa:1687,1697,link%2Fmanual,http%3A%2F%2Fpypi.python.org%2Fpypi%2Fpython-handler-socket:1751,1770,style%2FfontWeight,bold:1893,2020,style%2FfontFamily,monospace:2024,2363,style%2FfontFamily,sans-serif:2218,2243,link%2Fmanual,http%3A%2F%2Fpastie.org%2F1571414:2284,2299,style%2FfontWeight,bold:2434,3720,style%2FfontFamily,sans-serif:2438,2445,style%2FfontWeight,bold:2668,2680,link%2Fmanual,http%3A%2F%2Fpastie.org%2F1571421:2944,2970,style%2FfontWeight,bold:3046,3057,style%2FfontWeight,bold:3072,3087,style%2FfontWeight,bold:3232,3239,link%2Fmanual,http%3A%2F%2Fdrizzle.org%2F:3350,3354,style%2FfontWeight,bold:3413,3420,style%2FfontWeight,bold:" data-wave-xml="And yes I've been living the NoSQL dogma! The technologies like HBase, Voldermort, CouchDB, and a huge list of such weapons (each designed for a particular scenario) made me believe that my favorite RDBMS MySQL has grown old and it can't handle my data anymore. Going through the API's of these no SQL tools, I realized they are super trivial ( there are exceptions like MongoDB ), they are in no way as &amp;quot;rich&amp;quot; as SQL itself is. Secondly the rich &amp;quot;structure&amp;quot; and the &amp;quot;value&amp;quot; is gone (yes the document stores are not frequently used, most of the time we are doing the key value look up).&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Long story cut short; everybody just ignores the effort these beautiful creatures put in to take care of issues like parsing, queuing and all the dirty stuff they are doing for you. So next question should be if I get rid of SQL from MySQL (Just a specific case I am pretty sure we can do it on other engines as well) would it be any faster? Seems like yes. I would be demonstrating the benchmarks in a while. But before proceeding I would like to mention clearly that these benchmark values have pretty clearly proved me that an RDBMS when stripped off from the additional over-heads performs as good as any persistent key-value store (Yep I know noSQL community is hurt). I will be replicating a presistent Key/Value store using MySQL+HandlerSocket at a blazing fast speed.&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Tools of trade&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;I spent a whole day compiling these tools on my machine but by the end of the day it was a satisfaction! You will require:&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;MySQL 5.5.9 ( Latest Stable till date ) Source Code&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;HandlerSocket ( Latest pull from Github ) Latest Commit&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;Python 2.6.5 ( Comes on my debian )&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;Python Socket Handler ( Latest ) Homepage&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;Lots of patience for compiling MySQL+HandlerSocket&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Setting the stage&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Once compiled and system is up and running next thing would be creating a basic schema and table for storing the values&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;CREATE TABLE `foo`.`kv` (&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;   `key` CHAR(255)  NOT NULL,&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;   `val` TEXT  NOT NULL,&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;   PRIMARY KEY (`key`)&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt; ) ENGINE = MyISAM;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Darn simple (I've used key as CHAR for a bad case INT will be definitely faster); realistically 255 is far more than enough for a key (until you prove your self a Jimmy).&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Time for Python code! Here is the complete code that I used to benchmark my results.&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Machine specs&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;My machine is just a normal laptop with following specs.&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;CPU - http://pastie.org/1571529&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;3GB RAM&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;Disk - http://pastie.org/1571548&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt; &amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Results&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Yep time for moment of truth, I inserted a hundered thousand entries with a varying key sizes, but a value of constant string with a size of 1K (If it was a twitter it would have been much less). Here are the statistics (Console dump):&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;100,000 writes took 29.6542 seconds ( ~ 3372 writes / second ) &amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;100,000 reads in order took 18.4197 seconds ( ~ 5429 reads / second )&amp;lt;line t=&amp;quot;li&amp;quot;&amp;gt;&amp;lt;/line&amp;gt;100,000 reads in random order 17.0343 seconds ( ~ 5870 reads / second ) (Socking!)&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;I would like to add I have used the default settings of MyISAM ( default ones with make install ), plus I repeated the experiment without truncating the tables.&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;Whats the point&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;MySQL is a proven technology, its engines are stable and well known, scalable ( Yep modern forks for clouds are already rolling one example is drizzle); so I can't find any point in shifting to a technology thats a new born gives my code more calories and then brag about it just because its a buzz word! Untill there is no genuine reason to have a noSQL its just an overkill! I am pretty sure by tuning some more parameters, I can take these reads and writes to a higher number, plus I would be making no excuses and posting benchmarks for other noSQL systems on my machine.&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;&amp;lt;line&amp;gt;&amp;lt;/line&amp;gt;So it was my last day of noSQL dogma what about you?"&gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="body"&gt;&lt;/span&gt;&lt;/p&gt;</description><link>http://blog.creapptives.com/post/3329352663</link><guid>http://blog.creapptives.com/post/3329352663</guid><pubDate>Wed, 16 Feb 2011 23:25:29 +0500</pubDate></item><item><title>Puny standalone JavaScript custom PubSub events library</title><description>&lt;p&gt;I&amp;#8217;ve been always fascinated by the power of JavaScript. Recently I had a tour to &lt;a target="_blank" href="http://ruby-lang.org/"&gt;Ruby&lt;/a&gt; and the &lt;a target="_blank" href="http://rubyeventmachine.com/"&gt;event machine&lt;/a&gt;. I&amp;#8217;ve got to say Ruby stands no where near the power and flexibility of JS (Gosh I am in love again). There is a list of custom event system available including ones from famous giants like jQuery, Mootools, YUI. The whole idea of having an event published, and subscribers responding to them reminds me of the &lt;strong&gt;small-talk&lt;/strong&gt; (again Ruby has a good attempt but not as good as JS). Just in curiosity of custom events, I went drilling down how to do it, and the fantastic &lt;a target="_blank" href="http://dean.edwards.name/weblog/2009/03/callbacks-vs-events/"&gt;Dean Edward&amp;#8217;s article&lt;/a&gt; derived me nuts! In my hunt for DOM styled event equalizer in JS I derived a trick, but later came across a &lt;a target="_blank" href="https://github.com/mroderick/PubSubJS"&gt;PubSubJS library&lt;/a&gt; already doing that. But nevertheless I still beat it on size at cost of readability, and few features. So if you are curious or doing plain JS on mobile devices this is supposed to be helpful and fully customizable.&lt;/p&gt;
&lt;p&gt;You can checkout a demo &lt;a target="_blank" href="http://jsbin.com/igako3/14/edit"&gt; here&lt;/a&gt; (open debug console to see the magic)&lt;/p&gt;
&lt;p&gt;Code is pretty minimal and fits under 404 bytes when compressed, have a taste:&lt;/p&gt;
&lt;pre&gt;PubSub = (function(){
  
  var lst = {};
  
  return {
    // Subscribe for msg with function "fun" scoped with "obj" and additional parameters "ar"
    sub: function(msg, fun, obj, ar){
      lst[msg] = lst[msg] || [];
      ar = ar || [];
      obj = obj || window;
      lst[msg].push({args: ar, me: obj, f: fun});
    },
  
    // Publish an event "msg" with event event.data = dat and que makes the call itself async (call to pub)
    pub: function(msg, dat, que){
      var me = arguments.callee;
      if(que){
        setTimeout(function(){
          me.apply(me, arguments);
        }, 0);
      }
      var curr = lst[msg] || [];
      
      curr.filter(function(el){
        try{
          el.f.apply(el.me, [].concat({data: dat}, el.args));
        }catch(e){
          setTimeout(function(){throw e;}, 0);
        }
        return true;
      });                   
    },
    
    // Un-subscribe "fun" from event "msg"
    unsub: function(msg, fun){
      var cur = lst[msg] || [];
      lst[msg] = cur.filter(function(el){
        return el.f !== fun;
      });
    }
    
  }
  
})();
&lt;/pre&gt;</description><link>http://blog.creapptives.com/post/2658433646</link><guid>http://blog.creapptives.com/post/2658433646</guid><pubDate>Sun, 09 Jan 2011 04:23:00 +0500</pubDate></item><item><title>FITBJS template engine - Ultra thin</title><description>&lt;p&gt;&lt;strong&gt;Theory:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Last few days I&amp;#8217;ve been looking a template engines and came across some really fine and sleek solutions including &lt;a target="_blank" href="http://beebole.com/pure/"&gt;PURE&lt;/a&gt;, &lt;a target="_blank" href="http://embeddedjs.com/"&gt;EJS&lt;/a&gt;, &lt;a target="_blank" href="http://ejohn.org/blog/javascript-micro-templating/"&gt;Jhon Resig&amp;#8217;s Micro Templates&lt;/a&gt;, &lt;a target="_blank" href="http://code.google.com/p/jstemplate/"&gt;jsTemplates&lt;/a&gt;, &lt;a target="_blank" href="http://www.yajet.net/yajet/doc/yajet.html"&gt;YAJET&lt;/a&gt; and a list of on going ones. I was constantly in pursuit of simplicity, minimality! To sum up engines claiming micro were just and overkill for my scenario. Templating at times is pretty trivial a simple case might be display set of links fetched from JSON in anchor tags, displaying list of emails with DIV elements, replacing items in a template URL etc. Having such a full fledged template engine on such puny never makes sense to me (yes I did this in some of my recent projects). I used String.prototype.replace at a lot of places and did some boilerplate work for saving extra lives at times (Yep I know there are loads of template engines out there doing this; but I required a precisely fine tuned engine). So in my labs I did another experiment and came up with my own version of really bare-bones yet flexible template engine. Checkout &lt;a href="http://jsbin.com/ubefo4/edit" target="_blank"&gt;demo here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Practical:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well here is what I came up with (not meant for good readability but for experts it won&amp;#8217;t be a problem). But full-fills the purpose its under almost 350 bytes and when YUI compressed goes under 330 bytes:&lt;/p&gt;
&lt;pre&gt;function fitb(tar, data, opt) {
    var reg = /(:\w+)/g,
		iht = tar.innerHTML,
        tpl = ((tar._$$f = tar._$$f || iht)) || tar;
    opt = opt || {};
    return (
		iht &amp;amp;&amp;amp; 
		(tar.innerHTML = ((opt.append &amp;amp;&amp;amp; tar.innerHTML) || "") + (opt.pre||"")+fitb(tpl, data, opt)+(opt.post||""))
	) || (
		data.length &amp;amp;&amp;amp; 
		data.map(function(el) { return fitb(tpl, el, opt); }).join(opt.glue || "")
	) || (
		tpl.replace(reg, function(match) { return (data[match.substr(1)] || opt.none || "");})
	);
};
&lt;/pre&gt;
&lt;p&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Now what about usage&lt;/p&gt;
&lt;pre&gt;// :name is replaced by Looping and :type is replaced by array
fitb('hello :name this was a simple :type. ', {'name': 'Looping', 'type': 'array'}); 
// outputs "hello A this was a simple array. hello Looping this was a simple array. 
fitb('hello :name this was a simple :type. ', [{'name': 'Again', 'type': 'array'}, {'name': 'Looping', 'type': 'array'}]);
&lt;/pre&gt;
&lt;p&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Wait that&amp;#8217;s not it! It can do more once you use third parameter:&lt;/p&gt;
&lt;pre&gt;// outputs "hello A this was a simple array. &lt;br/&gt;hello Looping this was a simple array. 
fitb('hello :name this was a simple :type. ', [{'name': 'Again', 'type': 'array'}, {'name': 'Looping', 'type': 'array'}], {glue: '&lt;br/&gt;'}); 
&lt;/pre&gt;
&lt;p&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#8217;s still not enough, you can even do direct operations on a DOM node:&lt;/p&gt;
&lt;pre&gt;// innerHTML of DOM node is used as template string and cached
fitb(document.getElementById('myNode'), [{'name': 'Again', 'type': 'array'}, {'name': 'Looping', 'type': 'array'}]);
// Calling multiple times is not effected by innerHTML of DOM node (it cache's original template string).
firtb(document.getElementById('myNode'), [{'name': 'Some other data', 'type': 'array'}, {'name': 'More data', 'type': 'array'}]); 
// Append the templated results in myNode excellent for adding new data
firtb(document.getElementById('myNode'), [{'name': 'Again', 'type': 'array'}, {'name': 'Looping', 'type': 'array'}], {append: true});
&lt;/pre&gt;
&lt;p&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s pretty minimal yet usable; you can checkout &lt;a href="http://jsbin.com/ubefo4/edit" target="_blank"&gt;demo here&lt;/a&gt;.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/2373501604</link><guid>http://blog.creapptives.com/post/2373501604</guid><pubDate>Sun, 19 Dec 2010 19:01:00 +0500</pubDate><category>template engine</category><category>javascript</category><category>html</category></item><item><title>Flash or HTML5 the digibats!</title><description>&lt;blockquote&gt;
&lt;p&gt;Flash is no longer necessary to watch video or consume any kind of web content&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.apple.com/hotnews/thoughts-on-flash/"&gt;Apple CEO - Steve Jobs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;When you’re displaying content, any technology will use more power to display, versus not displaying content. If you used HTML5, for example, to display advertisements, that would use as much or more processing power than what Flash uses.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.fastcompany.com/1700949/adobe-on-macbook-air-html5-flash-battery-problems-a-false-argument"&gt;Adobe CTO - Kevin Lynch&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;After the dog fight there is still an ongoing argument for the future of Flash. I may sound little biased during the article, but standing in designer&amp;#8217;s shoes and being a programmer as well gives me a different perspective. First of all lets make it clear, Apple was the one with its &lt;a target="_blank" href="http://www.apple.com/hotnews/thoughts-on-flash/"&gt;open letter&lt;/a&gt; to start Flash War for real. I&amp;#8217;ve got to comment on the statements Apple made, recently they announced about &lt;a target="_blank" href="http://weblogs.java.net/blog/fabriziogiudici/archive/2010/10/24/apple-drops-java-and-more-so-what"&gt;dropping Java support&lt;/a&gt; but suddenly &lt;a target="_blank" href="http://www.apple.com/pr/library/2010/11/12openjdk.html"&gt;OpenJDK&lt;/a&gt; was announced, which really confused me for second time (Flash first time). I am great fan of Apple especially Steve Jobs, he inspires me at times. But looking at pattern of events from past, I think Apple is not &lt;strong&gt;calculating &lt;/strong&gt;anymore (first they dropped Flash but &lt;a target="_blank" href="http://business2press.com/2010/09/09/apple-changes-app-store-rules-to-become-more-open-and-transparent/"&gt;then allowed it in App Store&lt;/a&gt;, then Java and now the OpenJDK story), and I think its enough for us (me at-least) to convince us that we have to make our own choice in technology. Since &lt;strong&gt;we ultimately &lt;/strong&gt;are the technology consumers not &lt;strong&gt;Apple&lt;/strong&gt;! It&amp;#8217;s almost the same mistake that we did when IE6 became our favorite browser.&lt;/p&gt;
&lt;p&gt;Now for second part, is Flash really the &lt;strong&gt;cursed &lt;/strong&gt;technology? I recently came across the site &lt;a target="_blank" href="http://html5vsflash.tumblr.com/"&gt;HTML5 vs Flash&lt;/a&gt;, and honestly speaking I found the Flash animations smoother than HTML5 ones (Try it yourself). I did notice the processor usage while I was having the fun and I think I can sum it up in a single statement from Apple in 20XX &amp;#8220;Disable &lt;strong&gt;JavaScript &lt;/strong&gt;in your browser; it will increase your battery life to 1 Month&amp;#8221;. HTML5 was &lt;strong&gt;&lt;em&gt;almost &lt;/em&gt;&lt;/strong&gt;all the time taking more CPU usage than Flash. Here is one of the images from one of the experiments I tried:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img574.imageshack.us/img574/1263/snap.png" align="middle"/&gt;&lt;/p&gt;
&lt;p&gt;I tried chrome 8 too as well it varied from 28% to 35%. I have to agree with Adobe CTO if its processor intensive in Flash it&amp;#8217;s (most probably more) processor intensive in HTML5. I am not giving any clear decisions about which technology is ultimate winner; I am only saying HTML5 is &lt;strong&gt;immature&lt;/strong&gt; (I said it again) and there is no way it&amp;#8217;s justified for me to drop out Flash (In fact its the only graceful degrading to supply rich media experience).&lt;/p&gt;
&lt;p&gt;I only want the designers and programmers to realize the &lt;strong&gt;responsibility&lt;/strong&gt;; we are just in phase of recovery from IE 6 (yes I consider it as viral infection). Over here we have to setup a framework for next decade. So be smart, don&amp;#8217;t be foolish!&lt;/p&gt;</description><link>http://blog.creapptives.com/post/1562302795</link><guid>http://blog.creapptives.com/post/1562302795</guid><pubDate>Sat, 13 Nov 2010 20:34:00 +0500</pubDate></item><item><title>Playing around for javascript classes</title><description>&lt;p&gt;Closures is a well known methodology to have public and private variables under JavaScript objects(in my opinion I think we exploit the closure technology). After spending some long time &lt;a target="_blank" href="http://mootools.net/docs/core/Class/Class"&gt;Mootools class module&lt;/a&gt; (I simply love it), &lt;a target="_blank" href="http://www.prototypejs.org/learn/class-inheritance"&gt;PrototypeJS&lt;/a&gt;, &lt;a target="_blank" href="http://jsclass.jcoglan.com/"&gt;JS.Class&lt;/a&gt; , and &lt;a target="_blank" href="http://docs.dojocampus.org/dojo/index#objects-oo-tools"&gt;Dojo&lt;/a&gt; I asked myself; why can&amp;#8217;t I have same JSON styled public, private structure? The exquisite way I used to do &amp;#8220;&lt;em&gt;this.&lt;strong&gt;privateVariableName&amp;#8221;&lt;/strong&gt;&lt;/em&gt; in Java or C++ was still not available by any of libraries (at-least the ones I mentioned); due the constraint that if we introduce anything in &lt;em&gt;&lt;strong&gt;this &lt;/strong&gt;&lt;/em&gt;structure, it will be accessible like any public property. As an example:&lt;/p&gt;
&lt;pre&gt;var Klass = function(){
    this.x = 'hello';
};

var v = new Klass();
v.x; // gives me hello
&lt;/pre&gt;
&lt;p&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;So I spent some time hacking around, and I finally came up with a sleek hack to get the job done.&lt;/p&gt;
&lt;p&gt;By &lt;em&gt;exploiting&lt;/em&gt; &lt;strong&gt;Function.prototype.apply&lt;/strong&gt; one can easily bind any arbitrary object to a method. So for each public method I can bind an object that contains both public and private data. After spending time, and putting my head into problem I finally came up with my &lt;a href="http://maxpert.github.com/oorja/" target="_blank"&gt;own solution&lt;/a&gt; (For the time being I&amp;#8217;ve named it &lt;strong&gt;OOrJa&lt;/strong&gt; abrivating &lt;strong&gt;O&lt;/strong&gt;bject &lt;strong&gt;Or&lt;/strong&gt;iented &lt;strong&gt;Ja&lt;/strong&gt;vascript).&lt;/p&gt;
&lt;p&gt;Since code is pretty immature yet, I know there is a long journey ahead before it really becomes stable and robustly usable.&lt;/p&gt;
&lt;p&gt;Below is a sample code demonstrating a proof of concept about how simple and elegant code can look:&lt;/p&gt;
&lt;pre&gt;//Animal base class
var animal = Class({
    Init: function(){
        console.log('animal');
    },
     
    Public: {
        eat: function(){
            console.log(this.name+' eats');
            this.name = 'animal';
        },
         
        name: 'animal',
         
        walk: function(){
            this.pwalk();
        }
    },
     
    Private: {
        pwalk: function(){
            console.log(this.name+' walks');
        }
    }
});
 
//Dog derived class from animal overriding eat
var dog = Class(animal, {
    Init: function(){
        console.log('dog');
    },
     
    Public: {
        eat: function(){
            console.log(this.name + ' eats');
            this.walk();
        },
         
        name: 'dog'
    }
});
 
//Hound inherited from dog provides a new method howl
var hound = Class(dog, {
    Init: function(){
        console.log('hound'); // log constructor
    },
     
    Public: {
        howl: function(){
            console.log(this.name+" howls"); // log name
            this.eat();
        }
    }
});
 
 
var dh = new hound(); // logs animal, dog, hound
dh.howl(); // Logs dog howls, dog eats, animal walks
&lt;/pre&gt;
&lt;p&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Sweet. It follows the perfect C++ styled inheritance, since variable &lt;em&gt;name&lt;/em&gt; is both in dog and animal class, each one of them creates it&amp;#8217;s own context, hence the output is dog eats, and then animal walks (since dog class has no implementation of walk it inherits it from the parent class animal; and under animal class the name contains value &amp;#8220;animal&amp;#8221;).&lt;/p&gt;
&lt;p&gt;Based on feedback and the taste of my own food (ya I always use my own code) I am looking forward to improve it.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/1407794398</link><guid>http://blog.creapptives.com/post/1407794398</guid><pubDate>Tue, 26 Oct 2010 23:22:00 +0500</pubDate></item><item><title>Bluraity</title><description>&lt;a href="http://maxpert.github.com/Bluraity/"&gt;Bluraity&lt;/a&gt;: &lt;p&gt;Library emulating the blur effect on your HTML elements. I consider it to be the step into future of HTML, that will eventually lead to a CSS property may be something like:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;blur-radius: 3px;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Use cases can be many ranging from gallery scripts to HTML forms.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/1306242262</link><guid>http://blog.creapptives.com/post/1306242262</guid><pubDate>Wed, 13 Oct 2010 20:15:24 +0500</pubDate></item><item><title>IE 9 b5 vs FF 4 b5 vs Chrome 6 vs Opera 10.61</title><description>&lt;p&gt;Ok since last night I have been listening and watching that IE 9 beating Firefox and microsoft doing some really unfair comparison &lt;a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie-9/compare" target="_blank"&gt;on there site&lt;/a&gt;. So I thought why not give it a shot my self and give Firefox a fair chance to compete with other browsers (excluding Chrome since its already fast chrome 7 is even more faster on GPU) and have the so called SunSpider benchmark quoted by &lt;a href="http://www.engadget.com/2010/09/15/internet-explorer-9-beta-review/" target="_blank"&gt;engadget&lt;/a&gt; myself (BTW I was not able to replicate results engadget reports). Lets see the results first:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.engadget.com/2010/09/15/internet-explorer-9-beta-review/" target="_blank"&gt;Internet Explorer 9&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://dromaeo.com/?id=117456" target="_blank"&gt;Firefox 4 beta 5&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://dromaeo.com/?id=117459" target="_blank"&gt;Chrome 6&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://dromaeo.com/?id=117460" target="_blank"&gt;Opera 10.61&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;I would say Internet Explorer has hardly reached the point where Firefox is already positioned. I won&amp;#8217;t lie I am a Firefox fan and even with bias factor there is no reason for to say Internet Explorer 9 is a bad browser. But it really makes me wonder when a company like microsoft is doing a comparison on their official site and doing and changing it so frequently as if they made some assumptions about the checklist and someone added correction later on ( I am not joking here is the &lt;a href="http://img214.imageshack.us/img214/7913/20100916020029.png" target="_blank"&gt;clipping &lt;/a&gt;that I posted to my friend last night from &lt;a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie-9/compare" target="_blank"&gt;this link&lt;/a&gt;; it totally changed within half an hour).&lt;/p&gt;
&lt;p&gt;Before I close let me declare this &amp;#8220;I am not saying IE 9 is bad; its probably the best IE release I&amp;#8217;ve seen till today; I am only criticizing the false paradigm that microsoft may create around itself and stop the good development in browsers giving us an other IE 6 nightmare&amp;#8221;.&lt;/p&gt;</description><link>http://blog.creapptives.com/post/1131340634</link><guid>http://blog.creapptives.com/post/1131340634</guid><pubDate>Thu, 16 Sep 2010 15:18:00 +0500</pubDate></item></channel></rss>

