SlideShare a Scribd company logo
MYSQL Handler Socket

              Philip zhong
               5 .10 .2011
Outline
   Why using Handler Socket
   How to build Handler Socket Plug-in
   Handler Socket configuration parameter
   Handler Socket java client program
   Best Practice for java client
   Helpful sites
Why using Handler Socket
Mysql handle socket
item                 with handlesocket          without handlesocket

Process=16 and       QPS:130429                 QPS:95291
request=1000000*16   Mysql server               Mysql server
                     Cpu(s): 29.0%us, 20.6%sy   Cpu(s): 71.2%us, 20.8%sy


Process=32 and       QPS:268294                 QPS:103165
request=1000000*32   Mysql server               Mysql server Cpu(s):
                     Cpu(s): 58.1%us, 27.8%sy   71.1%us, 21.1%sy


Process=64 and       QPS:291960                 QPS:104180
request=1000000*64   Mysql server Cpu(s):       Mysql server Cpu(s):
                     58.8%us, 28.7%sy           71.3%us, 22.3%sy
How to build Handler Socket Plug-in
./autogen.sh
./configure --
   prefix=/home/oracle/mysql5.1.55/lib/mysql/pl
   ugin --with-mysql-source=/package/mysql-
   5.1.55 --with-mysql-
   bindir=/home/oracle/mysql5.1.55/bin --with-
   mysql-
   plugindir=/home/oracle/mysql5.1.55/lib/mysql
   /plugin
make
make install
mysql> install plugin handlersocket soname
 'handlersocket.so';
Handler Socket configuration
          parameter
•   handlersocket_port (default = '9998')
•   handlersocket_port_wr (default = '9999')
•   handlersocket_threads (default = 16, min = 1, max = 3000)
•   handlersocket_threads_wr (default = 1, min = 1, max = 3000)
•   handlersocket_sndbuf (default = 0, min = 0, max = 1677216)
•   handlersocket_rcvbuf (default = 0, min = 0, max = 1677216)
•   handlersocket_readsize (default = 0, min = 0, max = 1677216)
•   handlersocket_wrlock_timeout (default = 12, min = 0, max = 3600)
•   handlersocket_timeout (default = 300, min = 30, max = 3600)
•   open_files_limit = 65535
•   innodb_buffer_pool_size =8G
Handler Socket java client program
Dependent Packages
hs4j-0.1.jar
log4j-1.2.8.jar
slf4j-api-1.5.6.jar
slf4j-log4j12-1.3.0.jar
Java Key methods(1)
• public HSClientImpl(InetSocketAddress
  inetSocketAddress, int poolSize)
• public IndexSession openIndexSession(String
  dbname, String tableName,String indexName,
  String[] columns)
• public IndexSession openIndexSession(int
  indexId, String dbname,            String
  tableName, String indexName, String[]
  columns)
Java Key methods(2)
• public boolean insert(String[] values)
• public int delete(String[] keys)
• public int delete(String[] keys, FindOperator
  operator)
• public int delete(String[] keys, FindOperator
  operator, int limit,int offset)
• public int update(String[] keys, String[] values,
  FindOperator operator)
Java Key methods(3)
• public int update(String[] keys, String[] values,
  FindOperator operator,int limit, int offset)
• public ResultSet find(String[] keys)
• public ResultSet find(String[] keys,
  FindOperator operator, int limit,int offset)
• public ModifyStatement createStatement()
Create the MYSQL tables
create table mt_data
(
 guid     varchar(18) not null,
 orgid    int(9)   not null,
 tabid    int(9)   not null,
 name      varchar(128) not null,
 IsDeleted char(1) not null,
 createtime datetime not null,
 modifytime datetime not null,
 ....
 primary key(guid,orgid)
) ENGINE=InnoDB CHARSET=utf8;
Java example code fragment
• HSClient hsClient = new HSClientImpl(new
   InetSocketAddress("10.224.56.188", 9999), connectionPoolSize);
• final String[] columns = { "guid", "orgid", "tabid", "name",
"IsDeleted", "createtime", "modifytime", "value0",
"value1", "value2", "value3", "value4", "value5", "value6",
"value7", "value8", "value9", "value10", "value11",
"value12", "value13", "value14", "value15" };
IndexSession session =
   hsClient.openIndexSession("meetingdb","mt_data", "PRIMARY",
   columns);
• Bind values
    final String[] values3 = new String[9];
    values3[0] = guid;
    values3[1] = "1";
     ……
• session.insert(values)
• hsClient.shutdown();
Best Practice for java client
• HSClient is thread-safe, so you must use it as
  SINGLETON object in your application.
• Open index is an expensive operation, so
  reuse an opened index id as much as possible.
• IndexSession is thread-safe,so please reuse an
  opened IndexSession as much as possible.
• Use IndexSession rather than HSClient
• Use ModifyStatement to insert/update data
ModifyStatement example code
ModifyStatement stmt =
  this.session.createStatement();
stmt.setInt(1, 0);
stmt.setString(2, "dennis");
stmt.setInt(4, 27);
stmt.setString(5, "2010-11-28 13:24:00");
stmt.update(keys, FindOperator.EQ);
Helpful sites
• http://code.google.com/p/hs4j/
• http://yoshinorimatsunobu.blogspot.com/201
  0/10/using-mysql-as-nosql-story-for.html
• https://github.com/ahiguti/HandlerSocket-
  Plugin-for-MySQL
Mysql handle socket

More Related Content

PPTX
Compare mysql5.1.50 mysql5.5.8
PPTX
Mysql5.1 character set testing
PDF
PyCon KR 2019 sprint - RustPython by example
PDF
Google App Engine Developer - Day3
PDF
Openstack taskflow 簡介
PDF
JJUG CCC 2011 Spring
PDF
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
PDF
The Ring programming language version 1.5.1 book - Part 65 of 180
Compare mysql5.1.50 mysql5.5.8
Mysql5.1 character set testing
PyCon KR 2019 sprint - RustPython by example
Google App Engine Developer - Day3
Openstack taskflow 簡介
JJUG CCC 2011 Spring
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
The Ring programming language version 1.5.1 book - Part 65 of 180

What's hot (20)

PDF
Prometheus Storage
PDF
Deep dive into PostgreSQL statistics.
PDF
The Ring programming language version 1.6 book - Part 71 of 189
PDF
Node.js flow control
PDF
Rop and it's friends
PDF
The Ring programming language version 1.5.3 book - Part 25 of 184
PDF
Numerical Methods with Computer Programming
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
PPTX
What is row level isolation on cassandra
PDF
Data structure programs in c++
PDF
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
PDF
Zone.js 2017
PDF
Профилирование и оптимизация производительности Ruby-кода
ODP
Intravert Server side processing for Cassandra
PPTX
All you need to know about the JavaScript event loop
PDF
Nodejs - Should Ruby Developers Care?
PDF
Taipei.py 2018 - Control device via ioctl from Python
PDF
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
PPTX
Jk rubyslava 25
Prometheus Storage
Deep dive into PostgreSQL statistics.
The Ring programming language version 1.6 book - Part 71 of 189
Node.js flow control
Rop and it's friends
The Ring programming language version 1.5.3 book - Part 25 of 184
Numerical Methods with Computer Programming
Wprowadzenie do technologi Big Data i Apache Hadoop
What is row level isolation on cassandra
Data structure programs in c++
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Zone.js 2017
Профилирование и оптимизация производительности Ruby-кода
Intravert Server side processing for Cassandra
All you need to know about the JavaScript event loop
Nodejs - Should Ruby Developers Care?
Taipei.py 2018 - Control device via ioctl from Python
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
Jk rubyslava 25
Ad

Viewers also liked (20)

PPTX
Edtc 6340-66 copyright crash course alberto tudon 6th ed
ODP
公共施設白書を知ろう会 資料
PPT
Definition of Matter Lab + Phase Change- Day 2
PDF
อติมา อุ่นจิตร
PDF
Panduan si harka_sebagai_pegawai
PDF
Cso oow12-summit-sonny-sing hv4
PDF
Notam 15-nov-16
PDF
Funcionários públicos foram gratificados para atuar no dops
PPTX
Pres eucome 2016_v3
PDF
How oracle-uses-idm-chirag-v2
PDF
Purely practical data structures
PDF
KVH Whitepaper: Trading in Asia
PDF
SOP OC COMM
PPTX
Tutorial1 - Part 2
PDF
Business Architecture: Overview
PPT
Social media strategy essentials
DOCX
Setting FTP, SSH, NsLookup di linux
PPT
68 avenue Gurgaon 7428424386
Edtc 6340-66 copyright crash course alberto tudon 6th ed
公共施設白書を知ろう会 資料
Definition of Matter Lab + Phase Change- Day 2
อติมา อุ่นจิตร
Panduan si harka_sebagai_pegawai
Cso oow12-summit-sonny-sing hv4
Notam 15-nov-16
Funcionários públicos foram gratificados para atuar no dops
Pres eucome 2016_v3
How oracle-uses-idm-chirag-v2
Purely practical data structures
KVH Whitepaper: Trading in Asia
SOP OC COMM
Tutorial1 - Part 2
Business Architecture: Overview
Social media strategy essentials
Setting FTP, SSH, NsLookup di linux
68 avenue Gurgaon 7428424386
Ad

Similar to Mysql handle socket (20)

PPT
HandlerSocket - A NoSQL plugin for MySQL
PPT
HandlerSocket plugin for MySQL (English)
KEY
第三回月次セミナー(公開版)
PDF
HandlerSocket plugin Client for Javaとそれを用いたベンチマーク
ODP
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
PDF
MySQL NoSQL APIs
KEY
MySQLでNoSQL - アメーバピグでのNoSQLの実例
PDF
HTTP Plugin for MySQL!
PDF
HandlerSocket
PDF
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
ODP
1. MySql plugins
PDF
MySQL Performance for DevOps
PPTX
HBaseConAsia2018 Track2-3: Bringing MySQL Compatibility to HBase using Databa...
PDF
High-Performance JDBC Voxxed Bucharest 2016
PDF
56 Query Optimization
PDF
20151010 my sq-landjavav2a
PDF
NoSQL with MySQL
ODP
Built-in query caching for all PHP MySQL extensions/APIs
PDF
Php through the eyes of a hoster pbc10
PDF
Ipc mysql php
HandlerSocket - A NoSQL plugin for MySQL
HandlerSocket plugin for MySQL (English)
第三回月次セミナー(公開版)
HandlerSocket plugin Client for Javaとそれを用いたベンチマーク
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
MySQL NoSQL APIs
MySQLでNoSQL - アメーバピグでのNoSQLの実例
HTTP Plugin for MySQL!
HandlerSocket
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
1. MySql plugins
MySQL Performance for DevOps
HBaseConAsia2018 Track2-3: Bringing MySQL Compatibility to HBase using Databa...
High-Performance JDBC Voxxed Bucharest 2016
56 Query Optimization
20151010 my sq-landjavav2a
NoSQL with MySQL
Built-in query caching for all PHP MySQL extensions/APIs
Php through the eyes of a hoster pbc10
Ipc mysql php

More from Philip Zhong (12)

PPTX
Cisco Webex Distributed Framework and Data Store Design
PPTX
How to Implement Distributed Data Store
PPT
MongoDB Knowledge Shareing
PPT
Adapter Poxy Pattern
PPTX
How to estimate_oracle_cost
PDF
Mongo db program_installation_guide
PDF
Mongo db sharding_cluster_installation_guide
PDF
Vitess percona 2012
PDF
Distributed_Database_System
PPTX
Mysql performance tuning
PPTX
How to write_language_compiler
PPTX
Mysql architecture&parameters
Cisco Webex Distributed Framework and Data Store Design
How to Implement Distributed Data Store
MongoDB Knowledge Shareing
Adapter Poxy Pattern
How to estimate_oracle_cost
Mongo db program_installation_guide
Mongo db sharding_cluster_installation_guide
Vitess percona 2012
Distributed_Database_System
Mysql performance tuning
How to write_language_compiler
Mysql architecture&parameters

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Approach and Philosophy of On baking technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Cloud computing and distributed systems.
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
KodekX | Application Modernization Development
PDF
cuic standard and advanced reporting.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Encapsulation theory and applications.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
Approach and Philosophy of On baking technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Empathic Computing: Creating Shared Understanding
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Digital-Transformation-Roadmap-for-Companies.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Cloud computing and distributed systems.
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
KodekX | Application Modernization Development
cuic standard and advanced reporting.pdf
Big Data Technologies - Introduction.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Understanding_Digital_Forensics_Presentation.pptx

Mysql handle socket

  • 1. MYSQL Handler Socket Philip zhong 5 .10 .2011
  • 2. Outline  Why using Handler Socket  How to build Handler Socket Plug-in  Handler Socket configuration parameter  Handler Socket java client program  Best Practice for java client  Helpful sites
  • 5. item with handlesocket without handlesocket Process=16 and QPS:130429 QPS:95291 request=1000000*16 Mysql server Mysql server Cpu(s): 29.0%us, 20.6%sy Cpu(s): 71.2%us, 20.8%sy Process=32 and QPS:268294 QPS:103165 request=1000000*32 Mysql server Mysql server Cpu(s): Cpu(s): 58.1%us, 27.8%sy 71.1%us, 21.1%sy Process=64 and QPS:291960 QPS:104180 request=1000000*64 Mysql server Cpu(s): Mysql server Cpu(s): 58.8%us, 28.7%sy 71.3%us, 22.3%sy
  • 6. How to build Handler Socket Plug-in
  • 7. ./autogen.sh ./configure -- prefix=/home/oracle/mysql5.1.55/lib/mysql/pl ugin --with-mysql-source=/package/mysql- 5.1.55 --with-mysql- bindir=/home/oracle/mysql5.1.55/bin --with- mysql- plugindir=/home/oracle/mysql5.1.55/lib/mysql /plugin make make install
  • 8. mysql> install plugin handlersocket soname 'handlersocket.so';
  • 10. handlersocket_port (default = '9998') • handlersocket_port_wr (default = '9999') • handlersocket_threads (default = 16, min = 1, max = 3000) • handlersocket_threads_wr (default = 1, min = 1, max = 3000) • handlersocket_sndbuf (default = 0, min = 0, max = 1677216) • handlersocket_rcvbuf (default = 0, min = 0, max = 1677216) • handlersocket_readsize (default = 0, min = 0, max = 1677216) • handlersocket_wrlock_timeout (default = 12, min = 0, max = 3600) • handlersocket_timeout (default = 300, min = 30, max = 3600) • open_files_limit = 65535 • innodb_buffer_pool_size =8G
  • 11. Handler Socket java client program
  • 13. Java Key methods(1) • public HSClientImpl(InetSocketAddress inetSocketAddress, int poolSize) • public IndexSession openIndexSession(String dbname, String tableName,String indexName, String[] columns) • public IndexSession openIndexSession(int indexId, String dbname, String tableName, String indexName, String[] columns)
  • 14. Java Key methods(2) • public boolean insert(String[] values) • public int delete(String[] keys) • public int delete(String[] keys, FindOperator operator) • public int delete(String[] keys, FindOperator operator, int limit,int offset) • public int update(String[] keys, String[] values, FindOperator operator)
  • 15. Java Key methods(3) • public int update(String[] keys, String[] values, FindOperator operator,int limit, int offset) • public ResultSet find(String[] keys) • public ResultSet find(String[] keys, FindOperator operator, int limit,int offset) • public ModifyStatement createStatement()
  • 16. Create the MYSQL tables create table mt_data ( guid varchar(18) not null, orgid int(9) not null, tabid int(9) not null, name varchar(128) not null, IsDeleted char(1) not null, createtime datetime not null, modifytime datetime not null, .... primary key(guid,orgid) ) ENGINE=InnoDB CHARSET=utf8;
  • 17. Java example code fragment • HSClient hsClient = new HSClientImpl(new InetSocketAddress("10.224.56.188", 9999), connectionPoolSize); • final String[] columns = { "guid", "orgid", "tabid", "name", "IsDeleted", "createtime", "modifytime", "value0", "value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9", "value10", "value11", "value12", "value13", "value14", "value15" }; IndexSession session = hsClient.openIndexSession("meetingdb","mt_data", "PRIMARY", columns); • Bind values final String[] values3 = new String[9]; values3[0] = guid; values3[1] = "1"; …… • session.insert(values) • hsClient.shutdown();
  • 18. Best Practice for java client
  • 19. • HSClient is thread-safe, so you must use it as SINGLETON object in your application. • Open index is an expensive operation, so reuse an opened index id as much as possible. • IndexSession is thread-safe,so please reuse an opened IndexSession as much as possible. • Use IndexSession rather than HSClient • Use ModifyStatement to insert/update data
  • 20. ModifyStatement example code ModifyStatement stmt = this.session.createStatement(); stmt.setInt(1, 0); stmt.setString(2, "dennis"); stmt.setInt(4, 27); stmt.setString(5, "2010-11-28 13:24:00"); stmt.update(keys, FindOperator.EQ);
  • 22. • http://code.google.com/p/hs4j/ • http://yoshinorimatsunobu.blogspot.com/201 0/10/using-mysql-as-nosql-story-for.html • https://github.com/ahiguti/HandlerSocket- Plugin-for-MySQL