Your SlideShare is downloading. ×
0
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket - A NoSQL plugin for MySQL
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

HandlerSocket - A NoSQL plugin for MySQL

6,158

Published on

Presented on osdc.tw, 2011

Presented on osdc.tw, 2011

Published in: Technology
0 Comments
12 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,158
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
118
Comments
0
Likes
12
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. HANDLERSOCKET - A NOSQL PLUGIN FOR MYSQL Jui-Nan Lin
  • 2. About this talk <ul><li>URL of this Slide: </li></ul><ul><ul><li>http://0rz.tw/jqQqY </li></ul></ul><ul><li>QRCode: </li></ul>
  • 3. What is HandlerSocket? <ul><li>“ A NoSQL interface for MySQL” </li></ul><ul><li>Only supports queries which use index </li></ul><ul><li>Developed by DeNA (a Japanese social gaming provider) </li></ul><ul><li>https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL </li></ul>
  • 4. Architecture libmysql libhsclient Application (Ex. PHP, Ruby, Perl …) Listener for libmysql SQL Layer Handler Interface InnoDB MyISAM Other storage engines HandlerSocket Plugin application mysqld Reference: http://www.slideshare.net/akirahiguchi/handlersocket-plugin-for-mysql-4664154
  • 5. NoSQL for Web Application <ul><li>Most operations in web application are simple CRUD. </li></ul><ul><li>RDBMS is too powerful for web application. </li></ul><ul><li>Typical solution: </li></ul><ul><ul><li>Memcached + MySQL </li></ul></ul><ul><ul><li>Cassandra </li></ul></ul><ul><ul><li>Apache CouchDB </li></ul></ul><ul><ul><li>Amazon SimpleDB </li></ul></ul>
  • 6. NoSQL for Web Application <ul><li>Pros: </li></ul><ul><ul><li>Scalable </li></ul></ul><ul><ul><li>Fast </li></ul></ul><ul><li>Cons: </li></ul><ul><ul><li>Unstable </li></ul></ul><ul><ul><ul><li>Twitter drops Cassandra in 2010: http://engineering.twitter.com/2010/07/cassandra-at-twitter-today.html </li></ul></ul></ul>
  • 7. HandlerSocket for MySQL <ul><li>MySQL is very stable </li></ul><ul><li>HandlerSocket provides a NoSQL interface for MySQL </li></ul><ul><li>HandlerSocket is very fast. Faster than MySQL. </li></ul>
  • 8. How fast is it <ul><li>750,000 qps on a commodity server (tested by original developers) </li></ul><ul><ul><li>MySQL 5.1 + E5540 2.53Ghz + 32 GB RAM </li></ul></ul><ul><ul><li>All data fits in memory </li></ul></ul><ul><ul><li>All Clients are written in C </li></ul></ul><ul><ul><li>100,000 qps with Original MySQL </li></ul></ul><ul><li>About 7.5x faster than original MySQL! </li></ul>
  • 9. How fast is it <ul><li>1m PK SELECT queries each test on 1 table contains 1m rows. Client is written in PHP. </li></ul><ul><ul><li>SELECT * from table1 WHERE pk = ? </li></ul></ul>Concurrent Connections 1 10 50 100 HandlerSocket Time (sec) 256 28 15 13 QPS 3906 35714 66667 76923 MySQL Time (sec) 372 83 87 85 QPS 2688 12048 11494 11765
  • 10. Why HandlerSocket is fast from http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html
  • 11. Why HandlerSocket is fast <ul><li>HandlerSocket do not need to do: </li></ul><ul><ul><li>Parsing SQL Statements </li></ul></ul><ul><ul><li>Opening, locking table </li></ul></ul><ul><ul><li>Making SQL execution plans </li></ul></ul><ul><ul><ul><li>Index usage </li></ul></ul></ul><ul><ul><li>Unlocking, closing tables </li></ul></ul>
  • 12. Why HandlerSocket is fast <ul><li>HandlerSocket does do: </li></ul><ul><ul><li>Plain text-based protocol </li></ul></ul><ul><ul><li>Keep table open for reuse </li></ul></ul><ul><ul><li>Event based (use epoll) </li></ul></ul><ul><ul><ul><li>Many Connection per MySQL thread </li></ul></ul></ul><ul><ul><li>Accept only index queries </li></ul></ul><ul><ul><ul><li>Support range query, LIMIT, multi_get operations </li></ul></ul></ul>
  • 13. Language Bindings <ul><li>PHP: php-handlersocket </li></ul><ul><li>Java: hs4j </li></ul><ul><li>Python: python-handler-socket </li></ul><ul><li>Ruby: ruby-handlersocket </li></ul><ul><li>Perl: Net::HanderSocket </li></ul>
  • 14. Programming Example <ul><li>PHP </li></ul><ul><li>Read Operation </li></ul><ul><li>Port used for write operation is different </li></ul>
  • 15. Configuration (my.cnf) <ul><li>handlersocket_port = 9998 </li></ul><ul><ul><li>Port for reading </li></ul></ul><ul><li>handlersocket_port_wr = 9999 </li></ul><ul><ul><li>Port for writing </li></ul></ul><ul><li>handlersocket_threads = 16 </li></ul><ul><ul><li>No. of reader threads </li></ul></ul><ul><ul><li>Recommended Value: # of CPUs </li></ul></ul><ul><li>handlersocket_threads_wr = 1 </li></ul><ul><ul><li>No. of writer threads </li></ul></ul><ul><li>open_files_limit = 65535 </li></ul>
  • 16. Pros and Cons <ul><li>Pros </li></ul><ul><ul><li>Stable </li></ul></ul><ul><ul><li>High Performance </li></ul></ul><ul><ul><li>Support a lot of query types </li></ul></ul><ul><ul><li>No duplicate cache (compared with MySQL + memcached) </li></ul></ul><ul><ul><ul><li>Invalidation Problem </li></ul></ul></ul><ul><ul><li>Flexible </li></ul></ul><ul><ul><ul><li>Support SQL interface. We can still use SQL statements! (ex. report generating) </li></ul></ul></ul><ul><ul><ul><li>Write binlog and support MySQL replication. </li></ul></ul></ul><ul><ul><li>Included in Percona Server </li></ul></ul>
  • 17. Pros and Cons <ul><li>Cons </li></ul><ul><ul><li>No Security </li></ul></ul><ul><ul><ul><li>Without username and password </li></ul></ul></ul><ul><ul><li>Do not update MySQL Query Cache </li></ul></ul><ul><ul><ul><li>Fixed in recent commits </li></ul></ul></ul><ul><ul><li>No “INSERT … ON DUPLICATED KEY UPDATE …” Feature </li></ul></ul><ul><ul><li>Do not support auto increment column while inserting </li></ul></ul><ul><ul><ul><li>Fixed in recent commits </li></ul></ul></ul>
  • 18. Q&A <ul><li>Thank you! </li></ul>

×