HANDLERSOCKET - A NOSQL PLUGIN FOR MYSQL Jui-Nan Lin
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>...
What is HandlerSocket? <ul><li>“ A NoSQL interface for MySQL” </li></ul><ul><li>Only supports queries which use index </li...
Architecture libmysql libhsclient Application (Ex.  PHP, Ruby, Perl …) Listener for libmysql SQL Layer Handler Interface I...
NoSQL for Web Application  <ul><li>Most operations in web application are simple CRUD. </li></ul><ul><li>RDBMS is too powe...
NoSQL for Web Application  <ul><li>Pros: </li></ul><ul><ul><li>Scalable </li></ul></ul><ul><ul><li>Fast </li></ul></ul><ul...
HandlerSocket for MySQL <ul><li>MySQL is very stable </li></ul><ul><li>HandlerSocket provides a NoSQL interface for MySQL ...
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 +...
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...
Why HandlerSocket is fast from  http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html
Why HandlerSocket is fast <ul><li>HandlerSocket do not need to do: </li></ul><ul><ul><li>Parsing SQL Statements </li></ul>...
Why HandlerSocket is fast <ul><li>HandlerSocket does do: </li></ul><ul><ul><li>Plain text-based protocol </li></ul></ul><u...
Language Bindings <ul><li>PHP: php-handlersocket </li></ul><ul><li>Java: hs4j </li></ul><ul><li>Python: python-handler-soc...
Programming Example <ul><li>PHP </li></ul><ul><li>Read Operation </li></ul><ul><li>Port used for write operation is differ...
Configuration (my.cnf) <ul><li>handlersocket_port = 9998 </li></ul><ul><ul><li>Port for reading </li></ul></ul><ul><li>han...
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...
Pros and Cons <ul><li>Cons </li></ul><ul><ul><li>No Security </li></ul></ul><ul><ul><ul><li>Without username and password ...
Q&A <ul><li>Thank you! </li></ul>
Upcoming SlideShare
Loading in...5
×

HandlerSocket - A NoSQL plugin for MySQL

6,248

Published on

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,248
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
118
Comments
0
Likes
12
Embeds 0
No embeds

No notes for slide

HandlerSocket - A NoSQL plugin for MySQL

  1. 1. HANDLERSOCKET - A NOSQL PLUGIN FOR MYSQL Jui-Nan Lin
  2. 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. 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. 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. 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. 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. 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. 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. 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. 10. Why HandlerSocket is fast from http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html
  11. 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. 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. 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. 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. 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. 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. 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. 18. Q&A <ul><li>Thank you! </li></ul>
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×