MySQL+HandlerSocket


MySQL + HandlerSocket
Yoshinori Matsunobu是Sun/Oracle的前雇员,从事MySQL的研发工作,目前是DeNA的首席数据库和基础

设施架构师,他以插件的方式为MySQL/InnoDB提供解决方案,可以在一台2.53GHZ、8核CPU、32G内存的

Nehalem服务器上把每秒的查询数量(qps)提升到750,000以上。在同样的硬件环境下,无插件的MySQL

只能提供100,000左右的qps,如果使用memecached的话,可以增加到大约400,000。经过对RDBMS的分析

,Matsunobu意识到大部分时间都花在SQL的开销上,比如调用MYSQLparse()、MYSQLlex()、

make_join_statistics()和JOIN::optimize()等。他写到:

很显然性能降低的原因主要在SQL层,而不是“InnoDB(存储)”层。MySQL必须做很多事情......但

memcached/NoSQL是不需要做这些额外工作的。

参考:
MySQL/HandlerSocket和VoltDB:NoSQL的竞争者
http://hi.baidu.com/%CA%AB%D5%B9/blog/item/30e9aed38d3af024960a1649.html


通常,MySQL Server可以被看成两层架构:即SQL Layer和Storage Engine Layer,它们之间通过

Handler API进行交互。MySQL Server在接收到客户端的Query请求后,通常需要在SQL layer中进行词法

分析,语法分析,优化等过程,最终生成一个树型的查询计划,交由执行引擎执行。执行引擎根据查询

计划,跟相应的存储引擎通信,得到查询结果。
HandlerSocket的作者认为,对于CPU bound的MySQL server来说,SQL layer消耗了过多的资源,以致总

体性能不佳。HandlerSocket则绕过了MySQL Server的SQL layer,直接跟存储引擎交互,从而带来了大

幅的性能提升。默认情况下HandlerSocket Plugin监听9998和9999两个端口,其中9998只支持读操作,

9999支持读写操作,但是性能跟9998端口相比稍慢。
参考:
http://whitesock.javaeye.com/blog/811339

有人认为目前HandlerSocket还不能跟Memcache比较:
HandlerSocket is great, but don't compare it to Memcache just yet.
Dec. 28th, 2010 at 11:34 AM
The HandlerSocket plugin for MySQL currently lacks atomic operations .  It is impossible to

implement counters (increment/decrement value) or REPLACE functionality with the current

implementation. 
It currently exceeds the performance of Memcache for get/set operations, but I want to see

how fast it is once atomic operations are implemented. Until then, I don't think it is a

serious contender for replacing Memcache for the cache layer in a complex environment.

HandlerSocket性能评测:
HandlerSocket on SSD
http://www.mysqlperformanceblog.com/2010/11/02/handlersocket-on-ssd/


在CentOS 5中安装Percona-Server和HandlerSocket:
Installing HandlerSocket on CentOS 5 + Percona-Server in Five Easy Steps
1 – Set up the Percona Yum Repository
%> rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-

1.x86_64.rpm
Additional documentation for other distributions can be found at

http://www.percona.com/docs/wiki/repositories:start
2 – Install Percona-Server Packages
%> yum install Percona-Server-client-51.x86_64 Percona-Server-devel-51.x86_64 Percona-

Server-server-51.x86_64 Percona-Server-shared-51.x86_64 Percona-Server-shared-compat.x86_64
3 – Enable the PlugIn in my.cnf by adding the following lines in [mysqld]:
loose_handlersocket_port = 9998
loose_handlersocket_port_wr = 9999
loose_handlersocket_threads = 16
loose_handlersocket_threads_wr = 1
open_files_limit = 65535
4 – Install the PlugIn
mysql> install plugin handlersocket soname 'handlersocket.so';
5 – Verify
The easiest way to verify that HandlerSocket is running is to simply telnet to ports 9998

and 9999 on the localhost.


安装参考:
http://whitesock.javaeye.com/blog/811339
http://hi.baidu.com/higkoo/blog/item/fdb7a8fc51645deffd037f06.html

NoSQL:
NoSQL 是非关系型数据存储的广义定义。它打破了长久以来关系型数据库与 ACID 理论大一统的局面。

NoSQL 数据存储不需要固定的表结构,通常也不存在连接 操作。在大数据存取上具备关系型数据库无法

比拟的性能优势。该术语在 2009 年初得到了广泛认同。
当今的应用体系结构需要数据存储在横向伸缩性 上能够满足需求。而 NoSQL 存储就是为了实现这个需

求。Google 的 BigTable 与 Amazon 的 Dynamo 是非常成功的商业 NoSQL 实现。一些开源的 NoSQL 体

系,如Facebook 的 Cassandra , Apache 的 HBase ,也得到了广泛认同。
参考:
http://blog.csdn.net/DL88250/archive/2010/01/14/5191092.aspx

原文地址:https://www.cnblogs.com/preftest/p/1932751.html