{"id":110,"date":"2009-05-23T23:55:01","date_gmt":"2009-05-24T04:55:01","guid":{"rendered":"http:\/\/24.183.55.167:8101\/wordpress\/?p=110"},"modified":"2012-08-14T20:54:49","modified_gmt":"2012-08-15T01:54:49","slug":"tokyo-cabinet-is-31-times-faster-than-mysql","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/tokyo-cabinet-is-31-times-faster-than-mysql\/","title":{"rendered":"Tokyo Cabinet is 31 times faster than MySQL!!!"},"content":{"rendered":"<p>Today I was comparing the performance of Tokyo Cabinet, MySQL and Memcached using PHP. The result of Tokyo Cabinet is really impressive!<\/p>\n<p>(Note that these results are generated from my computer. If you perform your own benchmarks, then you might find different results due to different system configurations. In fact, I encourage you to perform your own benchmarks. )<\/p>\n<h2><strong>1. Quick Result<\/strong><\/h2>\n<p>Total time used to write 10000 records and retrieve them back by each candidate\u00a0 (The lower the better):<br \/>\n<strong><span style=\"color: #ff6600;\">Tokyo Cabinet: <\/span><span style=\"color: #ff6600;\">18.87s<\/span><\/strong><strong><br \/>\n<\/strong>Memcached: <strong>11.309s<\/strong><br \/>\nMySQL:<strong> 562.21s<\/strong><\/p>\n<p><strong>A completed result will be given below.<br \/>\n<\/strong><\/p>\n<h2 id=\"testing_environment\">2. Testing environment<\/h2>\n<p>Hardware<\/p>\n<ul>\n<li> Intel Pentium II 450MHz<\/li>\n<li>160 MB RAM<\/li>\n<\/ul>\n<p>Software<\/p>\n<ul>\n<li>FreeBSD 7.2<\/li>\n<li>Apache 2.2.11<\/li>\n<li>PHP 5.2.9<\/li>\n<li>Tokyo Cabinet 1.4.20<\/li>\n<li>Tokyo Tyrant 1.1.26<\/li>\n<li>MySQL 5.1.34<\/li>\n<li>Memcached 1.2.6<\/li>\n<\/ul>\n<h2 id=\"test_scenario\">3. Test scenario<\/h2>\n<p>For each candidate, I measure its performance using the following strategies through PHP:<\/p>\n<p>1.) The time used to create all of the necessary objects.<\/p>\n<p>2.) The time used to connect to the database.<\/p>\n<p>3.) The time used to store 10000 randomly generated data.<\/p>\n<p>4.) The time used to read 10000 randomly generated data.<\/p>\n<p>5.) The time used to close the connection.<br \/>\n<\/p>\n<h2 id=\"test_results\">4. Test results<\/h2>\n<h3><strong>Tokyo Cabinet<\/strong><\/h3>\n<table border=\"1\">\n<tbody>\n<tr>\n<td><\/td>\n<td align=\"center\"><strong>time index<\/strong><\/td>\n<td align=\"center\"><strong>ex time<\/strong><\/td>\n<td align=\"center\"><strong>%<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>Start<\/strong><\/td>\n<td>1243136772.72818600<\/td>\n<td>&#8211;<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr>\n<td><strong>create<\/strong><\/td>\n<td>1243136772.72838700<\/td>\n<td>0.000201<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr>\n<td><strong>connect<\/strong><\/td>\n<td>1243136772.73224200<\/td>\n<td>0.003855<\/td>\n<td align=\"right\">0.02%<\/td>\n<\/tr>\n<tr>\n<td><strong>vanish<\/strong><\/td>\n<td>1243136772.73526800<\/td>\n<td>0.003026<\/td>\n<td align=\"right\">0.02%<\/td>\n<\/tr>\n<tr>\n<td><strong>put<\/strong><\/td>\n<td>1243136781.53287200<\/td>\n<td>8.797604<\/td>\n<td align=\"right\">46.60%<\/td>\n<\/tr>\n<tr>\n<td><strong>get<\/strong><\/td>\n<td>1243136791.60574800<\/td>\n<td>10.072876<\/td>\n<td align=\"right\">53.35%<\/td>\n<\/tr>\n<tr>\n<td><strong>close<\/strong><\/td>\n<td>1243136791.60755900<\/td>\n<td>0.001811<\/td>\n<td align=\"right\">0.01%<\/td>\n<\/tr>\n<tr>\n<td><strong>Stop<\/strong><\/td>\n<td>1243136791.60782300<\/td>\n<td>0.000264<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr style=\"background: silver none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\">\n<td><strong>total<\/strong><\/td>\n<td>&#8211;<\/td>\n<td>18.879637<\/td>\n<td>100.00%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong><br \/>\n<\/strong><\/p>\n<h3><strong>Memcached<\/strong><\/h3>\n<table border=\"1\">\n<tbody>\n<tr>\n<td><\/td>\n<td align=\"center\"><strong>time index<\/strong><\/td>\n<td align=\"center\"><strong>ex time<\/strong><\/td>\n<td align=\"center\"><strong>%<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>Start<\/strong><\/td>\n<td>1243131185.86078100<\/td>\n<td>&#8211;<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr>\n<td><strong>create<\/strong><\/td>\n<td>1243131185.86092500<\/td>\n<td>0.000144<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr>\n<td><strong>connect<\/strong><\/td>\n<td>1243131185.86688300<\/td>\n<td>0.005958<\/td>\n<td align=\"right\">0.05%<\/td>\n<\/tr>\n<tr>\n<td><strong>put<\/strong><\/td>\n<td>1243131191.49702900<\/td>\n<td>5.630146<\/td>\n<td align=\"right\">49.78%<\/td>\n<\/tr>\n<tr>\n<td><strong>get<\/strong><\/td>\n<td>1243131197.16868100<\/td>\n<td>5.671652<\/td>\n<td align=\"right\">50.15%<\/td>\n<\/tr>\n<tr>\n<td><strong>close<\/strong><\/td>\n<td>1243131197.16982400<\/td>\n<td>0.001143<\/td>\n<td align=\"right\">0.01%<\/td>\n<\/tr>\n<tr>\n<td><strong>Stop<\/strong><\/td>\n<td>1243131197.17003400<\/td>\n<td>0.000210<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr style=\"background: silver none repeat scroll 0% 0%;\">\n<td><strong>total<\/strong><\/td>\n<td>&#8211;<\/td>\n<td>11.309253<\/td>\n<td>100.00%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><strong>MySQL<\/strong><\/h3>\n<table border=\"1\">\n<tbody>\n<tr>\n<td><\/td>\n<td align=\"center\"><strong>time index<\/strong><\/td>\n<td align=\"center\"><strong>ex time<\/strong><\/td>\n<td align=\"center\"><strong>%<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>Start<\/strong><\/td>\n<td>1243136138.19049000<\/td>\n<td>&#8211;<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr>\n<td><strong>create<\/strong><\/td>\n<td>1243136138.19064700<\/td>\n<td>0.000157<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr>\n<td><strong>connect<\/strong><\/td>\n<td>1243136138.22529900<\/td>\n<td>0.034652<\/td>\n<td align=\"right\">0.01%<\/td>\n<\/tr>\n<tr>\n<td><strong>put<\/strong><\/td>\n<td>1243136150.70760600<\/td>\n<td>12.482307<\/td>\n<td align=\"right\">2.22%<\/td>\n<\/tr>\n<tr>\n<td><strong>get<\/strong><\/td>\n<td>1243136700.40063700<\/td>\n<td>549.693031<\/td>\n<td align=\"right\">97.77%<\/td>\n<\/tr>\n<tr>\n<td><strong>close<\/strong><\/td>\n<td>1243136700.40078900<\/td>\n<td>0.000152<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr>\n<td><strong>Stop<\/strong><\/td>\n<td>1243136700.40104500<\/td>\n<td>0.000256<\/td>\n<td align=\"right\">0.00%<\/td>\n<\/tr>\n<tr style=\"background: silver none repeat scroll 0% 0%;\">\n<td><strong>total<\/strong><\/td>\n<td>&#8211;<\/td>\n<td>562.210555<\/td>\n<td>100.00%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The overhead time (create objects, making connections, closing connections etc) of all candidates are about the same. The only difference is storing the record and retrieving the record. Both Tokyo Cabinet and MySQL took about <strong>10 seconds<\/strong> to store 10000 records in the database. However, Tokyo Cabinet took about <strong>10 seconds<\/strong> to retrieve the records while MySQL took about <strong>550 seconds<\/strong>! <strong>That&#8217;s about 31 times longer!<\/strong><\/p>\n<h2 style=\"text-align: center;\"><a href=\"\/wordpress\/wp-content\/uploads\/2009\/05\/benchmark-tokyocabinet-memcached-mysql.jpg\" target=\"_blank\"><img decoding=\"async\" data-attachment-id=\"116\" data-permalink=\"https:\/\/icesquare.com\/wordpress\/tokyo-cabinet-is-31-times-faster-than-mysql\/benchmark-tokyocabinet-memcached-mysql\/#main\" data-orig-file=\"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2009\/05\/benchmark-tokyocabinet-memcached-mysql.jpg\" data-orig-size=\"800,603\" data-comments-opened=\"1\" data-image-title=\"benchmark-tokyocabinet-memcached-mysql\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2009\/05\/benchmark-tokyocabinet-memcached-mysql.jpg\" class=\"aligncenter size-full wp-image-116\" title=\"benchmark-tokyocabinet-memcached-mysql\" src=\"\/wordpress\/wp-content\/uploads\/2009\/05\/benchmark-tokyocabinet-memcached-mysql.jpg\" alt=\"benchmark-tokyocabinet-memcached-mysql\" width=\"300\" srcset=\"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2009\/05\/benchmark-tokyocabinet-memcached-mysql.jpg 800w, https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2009\/05\/benchmark-tokyocabinet-memcached-mysql-300x226.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/h2>\n<h2 id=\"test_results\">5. Materials<\/h2>\n<p>Here is the material I used to make this benchmark test.<br \/>\n<a href=\"\/download\/Benchmark-TokyoCabinet-MemCached-MySQL.zip\" target=\"_blank\">Click here to download the package.<\/a><\/p>\n<p>Please feel free to let me know if you have any question or comment.<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I was comparing the performance of Tokyo Cabinet, MySQL and Memcached using PHP. The result of Tokyo Cabinet is really impressive! (Note that these results are generated from my <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/tokyo-cabinet-is-31-times-faster-than-mysql\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[141,6],"tags":[20,11,9,172,27],"class_list":["post-110","post","type-post","status-publish","format-standard","hentry","category-programming-problems","category-technology","tag-benchmark","tag-memcached","tag-mysql","tag-php","tag-tokyo-cabinet"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-1M","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":106,"url":"https:\/\/icesquare.com\/wordpress\/oracle-mysql-and-berkeley-db\/","url_meta":{"origin":110,"position":0},"title":"Oracle, MySQL and Berkeley DB, what&#8217;s next?","author":"Derrick","date":"May 22, 2009","format":false,"excerpt":"When Oracle acquired Berkeley DB, the quality of Berkeley DB has gone worse after that. Now Oracle acquired Sun who owns MySQL, will the history repeat again? (By the way, I am going to fall in love with Tokyo Cabinet.) Tokyo Cabinet is now the new black. [ad#ad-bottom]","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":41,"url":"https:\/\/icesquare.com\/wordpress\/installing-apache-php-mysql-and-memcached-on-os-x\/","url_meta":{"origin":110,"position":1},"title":"Installing Apache, PHP, MySQL and MemCached on OS X","author":"Derrick","date":"May 19, 2009","format":false,"excerpt":"This is my note on how to to install Apache, PHP and MySQL on a an OS X box. Although some of these applications are come with the operating systems, it is always good to know how to upgrade them to the latest version. 1. Apple Developer Tools and Mac\u2026","rel":"","context":"In &quot;Server Problems&quot;","block_context":{"text":"Server Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/sever-problem\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":376,"url":"https:\/\/icesquare.com\/wordpress\/updated-what-technologies-or-toys-i-am-playing-recently\/","url_meta":{"origin":110,"position":2},"title":"Updated: What technologies (or toys) I am playing recently?","author":"Derrick","date":"November 16, 2009","format":false,"excerpt":"Recently I am playing the following technologies (toys): Tornado Web - Not sure how long will Apache + PHP last. Time to learn Python. Tokyo Cabinet & Tyrant - Another one of my long term plans to step away from SQL. PHP API for Tokyo Tyrant -- I decide to\u2026","rel":"","context":"In &quot;Fun Stuffs&quot;","block_context":{"text":"Fun Stuffs","link":"https:\/\/icesquare.com\/wordpress\/category\/fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":31,"url":"https:\/\/icesquare.com\/wordpress\/installing-apache-php-mysql-and-memcached-on-freebsd\/","url_meta":{"origin":110,"position":3},"title":"Installing Apache, PHP, MySQL and MemCached on FreeBSD","author":"Derrick","date":"May 19, 2009","format":false,"excerpt":"This is my note on how to to install Apache, PHP, MySQL and MemCached on a FreeBSD 7 Box. 1. MySQL Go to the mysql52-server port directory by typing the command: cd \/usr\/ports\/databases\/mysql51-server Build the port by typing: make BUILD_OPTIMIZED=yes BUILD_STATIC=yes Using these two options will speed up the execution\u2026","rel":"","context":"In &quot;FreeBSD&quot;","block_context":{"text":"FreeBSD","link":"https:\/\/icesquare.com\/wordpress\/category\/sever-problem\/freebsd\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":603,"url":"https:\/\/icesquare.com\/wordpress\/weird-php-error-after-freebsd-port-upgrade\/","url_meta":{"origin":110,"position":4},"title":"Weird PHP Error after FreeBSD port upgrade (PHP Warning:  PHP Startup: Unable to load dynamic library)","author":"Derrick","date":"April 6, 2010","format":false,"excerpt":"Today I upgraded the port on my FreeBSD box using portmaster tools: portmaster -Dai After that, I found that the PHP gave the following weird error: php -v PHP Warning: PHP Startup: Unable to load dynamic library '\/usr\/local\/lib\/php\/20060613\/memcached.so' - \/usr\/local\/lib\/php\/20060613\/memcached.so: Undefined symbol \" php_session_create_id\" in Unknown on line 0 PHP\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1489,"url":"https:\/\/icesquare.com\/wordpress\/php-warning-php-startup-unable-to-load-dynamic-library-usrlocallibphp20090626tokyo_tyrant-so-usrlocallibphp20090626tokyo_tyrant-so-undefined-symbol-ps_globals-in-unknown-on-l\/","url_meta":{"origin":110,"position":5},"title":"PHP Warning:  PHP Startup: Unable to load dynamic library &#8216;\/usr\/local\/lib\/php\/20090626\/tokyo_tyrant.so&#8217; &#8211; \/usr\/local\/lib\/php\/20090626\/tokyo_tyrant.so: Undefined symbol &#8220;ps_globals&#8221; in Unknown on line 0","author":"Derrick","date":"August 23, 2011","format":false,"excerpt":"Every time I upgrade the PHP and related extensions, I always run into the same problem with some PHP-PECL modules. Recently with the new release of PHP 5.3.7, there is no exception for the trouble. So what kind of trouble I have today? The Tokyo Tyrant (The middleman between my\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"\/wordpress\/wp-content\/uploads\/2011\/08\/tokyocabinet.png","width":350,"height":200},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/comments?post=110"}],"version-history":[{"count":21,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":2944,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/110\/revisions\/2944"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}