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

What's hot (20)

PDF
Prometheus Storage
Fabian Reinartz
 
PDF
Deep dive into PostgreSQL statistics.
Alexey Lesovsky
 
PDF
The Ring programming language version 1.6 book - Part 71 of 189
Mahmoud Samir Fayed
 
PDF
Node.js flow control
Simon Su
 
PDF
Rop and it's friends
nuc13us
 
PDF
The Ring programming language version 1.5.3 book - Part 25 of 184
Mahmoud Samir Fayed
 
PDF
Numerical Methods with Computer Programming
Utsav Patel
 
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
PPTX
What is row level isolation on cassandra
Kazutaka Tomita
 
PDF
Data structure programs in c++
mmirfan
 
PDF
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Ontico
 
PDF
Zone.js 2017
Jia Li
 
PDF
Профилирование и оптимизация производительности Ruby-кода
samsolutionsby
 
ODP
Intravert Server side processing for Cassandra
Edward Capriolo
 
PPTX
All you need to know about the JavaScript event loop
Saša Tatar
 
PDF
Nodejs - Should Ruby Developers Care?
Felix Geisendörfer
 
PDF
Taipei.py 2018 - Control device via ioctl from Python
Hua Chu
 
PDF
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
Ontico
 
PPTX
Jk rubyslava 25
Jozef Képesi
 
Prometheus Storage
Fabian Reinartz
 
Deep dive into PostgreSQL statistics.
Alexey Lesovsky
 
The Ring programming language version 1.6 book - Part 71 of 189
Mahmoud Samir Fayed
 
Node.js flow control
Simon Su
 
Rop and it's friends
nuc13us
 
The Ring programming language version 1.5.3 book - Part 25 of 184
Mahmoud Samir Fayed
 
Numerical Methods with Computer Programming
Utsav Patel
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
What is row level isolation on cassandra
Kazutaka Tomita
 
Data structure programs in c++
mmirfan
 
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Ontico
 
Zone.js 2017
Jia Li
 
Профилирование и оптимизация производительности Ruby-кода
samsolutionsby
 
Intravert Server side processing for Cassandra
Edward Capriolo
 
All you need to know about the JavaScript event loop
Saša Tatar
 
Nodejs - Should Ruby Developers Care?
Felix Geisendörfer
 
Taipei.py 2018 - Control device via ioctl from Python
Hua Chu
 
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
Ontico
 
Jk rubyslava 25
Jozef Képesi
 

Viewers also liked (20)

PPTX
Edtc 6340-66 copyright crash course alberto tudon 6th ed
albertotudon
 
ODP
公共施設白書を知ろう会 資料
長野市議会議員小泉一真
 
PPT
Definition of Matter Lab + Phase Change- Day 2
jmori1
 
PDF
อติมา อุ่นจิตร
อติมา อุ่นจิตร
 
PDF
Panduan si harka_sebagai_pegawai
Wenni Meliana
 
PDF
Cso oow12-summit-sonny-sing hv4
OracleIDM
 
PDF
Notam 15-nov-16
Carlos Carvalho
 
PDF
Funcionários públicos foram gratificados para atuar no dops
Miguel Rosario
 
PPTX
Pres eucome 2016_v3
Marco Leonesio
 
PDF
How oracle-uses-idm-chirag-v2
OracleIDM
 
PDF
Purely practical data structures
Евгений Лазин
 
PDF
KVH Whitepaper: Trading in Asia
KVH Co. Ltd.
 
PDF
SOP OC COMM
antiik
 
PPTX
Tutorial1 - Part 2
hstryk
 
PDF
Business Architecture: Overview
Chris Moloney
 
PPT
Social media strategy essentials
Rather Inventive
 
DOCX
Setting FTP, SSH, NsLookup di linux
Robby Firmansyah
 
PPT
68 avenue Gurgaon 7428424386
Adore Global Pvt. Ltd
 
Edtc 6340-66 copyright crash course alberto tudon 6th ed
albertotudon
 
公共施設白書を知ろう会 資料
長野市議会議員小泉一真
 
Definition of Matter Lab + Phase Change- Day 2
jmori1
 
อติมา อุ่นจิตร
อติมา อุ่นจิตร
 
Panduan si harka_sebagai_pegawai
Wenni Meliana
 
Cso oow12-summit-sonny-sing hv4
OracleIDM
 
Notam 15-nov-16
Carlos Carvalho
 
Funcionários públicos foram gratificados para atuar no dops
Miguel Rosario
 
Pres eucome 2016_v3
Marco Leonesio
 
How oracle-uses-idm-chirag-v2
OracleIDM
 
Purely practical data structures
Евгений Лазин
 
KVH Whitepaper: Trading in Asia
KVH Co. Ltd.
 
SOP OC COMM
antiik
 
Tutorial1 - Part 2
hstryk
 
Business Architecture: Overview
Chris Moloney
 
Social media strategy essentials
Rather Inventive
 
Setting FTP, SSH, NsLookup di linux
Robby Firmansyah
 
68 avenue Gurgaon 7428424386
Adore Global Pvt. Ltd
 
Ad

Similar to Mysql handle socket (20)

PDF
Nodejs性能分析优化和分布式设计探讨
flyinweb
 
PDF
The powerful toolset of the go-mysql library
Daniël van Eeden
 
PPTX
Where the wild things are - Benchmarking and Micro-Optimisations
Matt Warren
 
PDF
The Ring programming language version 1.10 book - Part 10 of 212
Mahmoud Samir Fayed
 
PPTX
Building and Scaling Node.js Applications
Ohad Kravchick
 
PDF
Presto anatomy
Dongmin Yu
 
PDF
20160821 coscup-my sql57docstorelab01
Ivan Ma
 
PDF
Maintenance for MongoDB Replica Sets
Igor Donchovski
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PPTX
Run Node Run
Kevin Swiber
 
PDF
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
Dave Stokes
 
PDF
Preparse Query Rewrite Plugins
Sveta Smirnova
 
PPTX
Hazelcast and MongoDB at Cloud CMS
uzquiano
 
PPTX
Performance and how to measure it - ProgSCon London 2016
Matt Warren
 
PDF
Solr @ Etsy - Apache Lucene Eurocon
Giovanni Fernandez-Kincade
 
PDF
The Ring programming language version 1.8 book - Part 54 of 202
Mahmoud Samir Fayed
 
PDF
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Universitat Politècnica de Catalunya
 
PDF
How to make a high-quality Node.js app, Nikita Galkin
Sigma Software
 
PDF
Scala to assembly
Jarek Ratajski
 
ODP
Built-in query caching for all PHP MySQL extensions/APIs
Ulf Wendel
 
Nodejs性能分析优化和分布式设计探讨
flyinweb
 
The powerful toolset of the go-mysql library
Daniël van Eeden
 
Where the wild things are - Benchmarking and Micro-Optimisations
Matt Warren
 
The Ring programming language version 1.10 book - Part 10 of 212
Mahmoud Samir Fayed
 
Building and Scaling Node.js Applications
Ohad Kravchick
 
Presto anatomy
Dongmin Yu
 
20160821 coscup-my sql57docstorelab01
Ivan Ma
 
Maintenance for MongoDB Replica Sets
Igor Donchovski
 
NodeJS for Beginner
Apaichon Punopas
 
Run Node Run
Kevin Swiber
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
Dave Stokes
 
Preparse Query Rewrite Plugins
Sveta Smirnova
 
Hazelcast and MongoDB at Cloud CMS
uzquiano
 
Performance and how to measure it - ProgSCon London 2016
Matt Warren
 
Solr @ Etsy - Apache Lucene Eurocon
Giovanni Fernandez-Kincade
 
The Ring programming language version 1.8 book - Part 54 of 202
Mahmoud Samir Fayed
 
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Universitat Politècnica de Catalunya
 
How to make a high-quality Node.js app, Nikita Galkin
Sigma Software
 
Scala to assembly
Jarek Ratajski
 
Built-in query caching for all PHP MySQL extensions/APIs
Ulf Wendel
 
Ad

More from Philip Zhong (12)

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

Recently uploaded (20)

PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 

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