How to scalable your application
Most of the scalable application on web use MYSQL+memcached+varnish cache as the back end for their applications. Recently some of them shifted to NOSQL for one of the biggest reason ‘performance’. Certainly, NOSQL performs better than MYSQL for simple queries and primary key look-ups.
Most of the database queries of web applications are simple and related to primary key lookups. So, it seems to be healthy decision of migrating to NOSQL from MYSQL.
Yoshinori Matsunobu recently launched a MySQL plug-in ‘HandlerSocket’ which implements protocol for MySQL. The plug-in allows applications to communicate directly with MySQL storage engines, without the overhead associated with using SQL. Operations such as parsing and optimizing queries, as well as table handling operations (opening, locking, unlocking, closing) are also included in this plug-in.
As a result, HandlerSocket can provide much better performance for applications that using simple queries and primary key look-ups.
How it Works?
Whenever a query is fired on a table in MySQL, MySQL servers upper layer parses the query. Then it opens a table for which query is fired. After performing operations on data table is closed and results are returned, for every single query disk operation involved and MySQL Engine opens a new instance of table and closes it after performing operations.
Opening and closing of tables is very costly as it causes mutex contensions and hampers performance. The biggest difference here in Handlersocket is, it doesn’t open/close tables everytime. It reuses the open table connections.
Advantages
1. Supporting lots of query patterns
2. It can handle lots of concurrent connections
3. Extremely high performance
4. Smaller network packets
5. Running limited number of MySQL internal threads
6. Grouping client requests
7. It can reduce the number of fsync() calls and replication delay
8. No duplicate cache and data inconsistency
9. No need to modify/rebuild MySQL
10.Independent from storage engines
How to install HandlerSocket
1. Install latest version of percona Mysql
2. Enabling the Plugin, First, add the following lines to the [mysqld] section of your my.cnf file:
loose_handlersocket_port = 9998
# the port number to bind to for read requests
loose_handlersocket_port_wr = 9999
# the port number to bind to for write requests
loose_handlersocket_threads = 16
# the number of worker threads for read requests
loose_handlersocket_threads_wr = 1
# the number of worker threads for write requests
open_files_limit = 65535
# to allow handlersocket to accept many concurrent
# connections, make open_files_limit as large as
# possible.
3. Login to mysql as root, and execute the following query:
mysql> install plugin handlersocket soname ‘handlersocket.so’;
4. Testing the Plugin installation
If handlersocket.so was successfully installed, it will begin accepting connections on ports 9998 and 9999. Executing a SHOW PROCESSLIST command should show HandlerSocket worker threads:
mysql> show processlist;
+—-+————-+—————–+—————+———+——+——————————————-+——————+———–+—————+———–+
| Id | User | Host | db | Command | Time | State | Info | Rows_sent | Rows_examined | Rows_read |
+—-+————-+—————–+—————+———+——+——————————————-+——————+———–+—————+———–+
| 1 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 2 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 3 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 4 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 5 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 6 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 7 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 8 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 9 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 10 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 11 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 12 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 13 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 14 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 15 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 16 | system user | connecting host | NULL | Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 17 | system user | connecting host | handlersocket | Connect | NULL | handlersocket: mode=wr, 0 conns, 0 active | NULL | 0 | 0 | 1 |
| 19 | root | localhost | NULL | Query | 0 | NULL | show processlist | 0 | 0 | 1 |
+—-+————-+—————–+—————+———+——+——————————————-+——————+———–+————-
for more details http://www.percona.com/doc/percona-server/5.5/performance/handlersocket.html
Thanks
Manoj

