SlideShare ist ein Scribd-Unternehmen logo
1 von 23
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
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

Weitere ähnliche Inhalte

Was ist angesagt?

Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandra
Kazutaka Tomita
 
Data structure programs in c++
Data structure programs in c++Data structure programs in c++
Data structure programs in c++
mmirfan
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
Edward Capriolo
 

Was ist angesagt? (20)

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

Andere mochten auch

Edtc 6340-66 copyright crash course alberto tudon 6th ed
Edtc 6340-66 copyright crash course  alberto tudon 6th edEdtc 6340-66 copyright crash course  alberto tudon 6th ed
Edtc 6340-66 copyright crash course alberto tudon 6th ed
albertotudon
 
Definition of Matter Lab + Phase Change- Day 2
Definition of Matter Lab + Phase Change- Day 2Definition of Matter Lab + Phase Change- Day 2
Definition of Matter Lab + Phase Change- Day 2
jmori1
 
Cso oow12-summit-sonny-sing hv4
Cso oow12-summit-sonny-sing hv4Cso oow12-summit-sonny-sing hv4
Cso oow12-summit-sonny-sing hv4
OracleIDM
 
How oracle-uses-idm-chirag-v2
How oracle-uses-idm-chirag-v2How oracle-uses-idm-chirag-v2
How oracle-uses-idm-chirag-v2
OracleIDM
 
Tutorial1 - Part 2
Tutorial1 - Part 2Tutorial1 - Part 2
Tutorial1 - Part 2
hstryk
 

Andere mochten auch (20)

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

Ähnlich wie Mysql handle socket

Ähnlich wie Mysql handle socket (20)

Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 
Where the wild things are - Benchmarking and Micro-Optimisations
Where the wild things are - Benchmarking and Micro-OptimisationsWhere the wild things are - Benchmarking and Micro-Optimisations
Where the wild things are - Benchmarking and Micro-Optimisations
 
The Ring programming language version 1.10 book - Part 10 of 212
The Ring programming language version 1.10 book - Part 10 of 212The Ring programming language version 1.10 book - Part 10 of 212
The Ring programming language version 1.10 book - Part 10 of 212
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
(DEV204) Building High-Performance Native Cloud Apps In C++
(DEV204) Building High-Performance Native Cloud Apps In C++(DEV204) Building High-Performance Native Cloud Apps In C++
(DEV204) Building High-Performance Native Cloud Apps In C++
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
20160821 coscup-my sql57docstorelab01
20160821 coscup-my sql57docstorelab0120160821 coscup-my sql57docstorelab01
20160821 coscup-my sql57docstorelab01
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica Sets
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Run Node Run
Run Node RunRun Node Run
Run Node Run
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite Plugins
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
Performance and how to measure it - ProgSCon London 2016
Performance and how to measure it - ProgSCon London 2016Performance and how to measure it - ProgSCon London 2016
Performance and how to measure it - ProgSCon London 2016
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
The Ring programming language version 1.8 book - Part 54 of 202
The Ring programming language version 1.8 book - Part 54 of 202The Ring programming language version 1.8 book - Part 54 of 202
The Ring programming language version 1.8 book - Part 54 of 202
 
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
 
How to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinHow to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita Galkin
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assembly
 
Built-in query caching for all PHP MySQL extensions/APIs
Built-in query caching for all PHP MySQL extensions/APIsBuilt-in query caching for all PHP MySQL extensions/APIs
Built-in query caching for all PHP MySQL extensions/APIs
 

Mehr von Philip Zhong (12)

Cisco Webex Distributed Framework and Data Store Design
Cisco Webex Distributed Framework and Data Store DesignCisco Webex Distributed Framework and Data Store Design
Cisco Webex Distributed Framework and Data Store Design
 
How to Implement Distributed Data Store
How to Implement Distributed Data Store How to Implement Distributed Data Store
How to Implement Distributed Data Store
 
MongoDB Knowledge Shareing
MongoDB Knowledge ShareingMongoDB Knowledge Shareing
MongoDB Knowledge Shareing
 
Adapter Poxy Pattern
Adapter Poxy PatternAdapter Poxy Pattern
Adapter Poxy Pattern
 
How to estimate_oracle_cost
How to estimate_oracle_costHow to estimate_oracle_cost
How to estimate_oracle_cost
 
Mongo db program_installation_guide
Mongo db program_installation_guideMongo db program_installation_guide
Mongo db program_installation_guide
 
Mongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guideMongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guide
 
Vitess percona 2012
Vitess percona 2012Vitess percona 2012
Vitess percona 2012
 
Distributed_Database_System
Distributed_Database_SystemDistributed_Database_System
Distributed_Database_System
 
Mysql performance tuning
Mysql performance tuningMysql performance tuning
Mysql performance tuning
 
How to write_language_compiler
How to write_language_compilerHow to write_language_compiler
How to write_language_compiler
 
Mysql architecture&parameters
Mysql architecture&parametersMysql architecture&parameters
Mysql architecture&parameters
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

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
  • 4.
  • 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