SlideShare a Scribd company logo
1 of 38
Download to read offline
HANDLERSOCKET
A NOSQL APPROACH TO MYSQL
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
ABOUT ME
Lukasz Barulski
• backend dev AKA IAmDoingEverythingExceptFrontend dev
• been with DocPlanner since dinosaurs
• kicks butts in MK X
/lbarulski /in/lukaszbarulski
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
FETCHING DATA - THE MYSQL WAY
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SAMPLE QUERIES
— OR —
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SO, WHAT’S WRONG WITH THAT?
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
BUT…LET’S TEST THE SPEED
• PHP 7.0.4 • MariaDB 10.0.22
500 000 records with random data
+
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL WAY | SPEED TEST
$resultsInMs = [];

$statement = $pdo->prepare('SELECT value FROM t WHERE id=:id LIMIT 1');

for ($i = 1; $i <= 500000; ++$i)

{

$before = microtime(true);


$statement->execute(['id' => $i]);

$data = $statement->fetchColumn();


$after = microtime(true);

$resultsInMs[] = ($after-$before)*1000;

}

$resultInMs = array_sum($resultsInMs)/count($resultsInMs);

echo round($resultInMs, 3) . ' ms.' . PHP_EOL;

echo round(stats_standard_deviation($resultsInMs, true), 3) . ' ms.' .
PHP_EOL;

HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL WAY | TEST RESULTS
Average time: 0.131 ms.
Standard deviation: 0.012 ms.
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL WAY… WITHOUT STEROIDS| SPEED TEST
$resultsInMs = [];

for ($i = 1; $i <= 500000; ++$i)

{

$before = microtime(true);



$data = $pdo

->query('SELECT value FROM t WHERE id='.$i.' LIMIT 1')

->fetchColumn();



$after = microtime(true);

$resultsInMs[] = ($after-$before)*1000;

}

$resultInMs = array_sum($resultsInMs)/count($resultsInMs);

echo round($resultInMs, 3) . ' ms.' . PHP_EOL;

echo round(stats_standard_deviation($resultsInMs, true), 3) . ' ms.' .
PHP_EOL;
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL WAY… WITHOUT STEROIDS| TEST RESULTS
Average time: 0.257 ms.
Standard deviation: 0.074 ms.
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL WAY | EXAMPLES
SQL Prepared Statements AVG: 0.131 ms.
SQL AVG: 0.257 ms.
Wordpress 4.4.2 homepage: 21 SELECT
21 x 0.257 ms. = 5.397 ms.
Where that (sometimes) matters?
• API
• High frequency operations
• Complicated (long running) reports
• Microservices
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SIMPLE SOLUTION?
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL WAY | SOLUTION OR A HALF-MEASURE?
• Warmup
• Invalidation
Problems:
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
HANDLERSOCKET TO THE RESCUE!
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
HANDLERSOCKET | THEORY
•MySQL based SQL servers plugin
•Text-like binary protocol - not SQL queries
•TCP connection
•Single thread for modifying data
•Multiple threads for reading data
•Coexists with standard way of using MySQL
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
HANDLERSOCKET WAY | SPEED TEST
$indexId = $hs->getIndexId('test', 't', '', 'id,value');

$resultsInMs = [];

for ($i = 1; $i <= 500000; ++$i)

{

$before = microtime(true);



$hs->select($indexId, '=', [$i]);

$data = $hs->readResponse();



$after = microtime(true);

$resultsInMs[] = ($after-$before)*1000;

}

$resultInMs = array_sum($resultsInMs)/(float)count($resultsInMs);

echo round($resultInMs, 3) . ' ms.' . PHP_EOL;

echo round(stats_standard_deviation($resultsInMs, true), 3) . ' ms.' .
PHP_EOL;
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
HANDLERSOCKET WAY | TEST RESULTS
Average time: 0.073 ms.
Standard deviation: 0.009 ms.
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL VS. HANDLERSOCKET
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL VS. HANDLERSOCKET | AVG(FETCHING TIME) BOXING NIGHT
SQL
SQL PS
HS
0 0,065 0,13 0,195 0,26
0,073MS
0,131MS
0,257MS
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL VS. HANDLERSOCKET | STDEV(FETCHING TIME) BOXING NIGHT
SQL
SQL PS
HS
0 0,02 0,04 0,06 0,08
0,009MS
0,012MS
0,074MS
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
OK, BUT WHY IS IT FASTER?
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL VS. HANDLERSOCKET | LEO, WHY?
Few steps less
Few bytes less
• No query parsing
• No query analysis
• No query execution plan
• ~40% smaller request size
• ~40% smaller response size
Less CPU usage
Less network traffic
Based on our examples
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
COMMUNICATION
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
COMMUNICATION | THEORY
• Port 9998
• Port 9999
• Read only
• Multi threaded
• Write allowed
• Single threaded
• One-line request
• One-line response
• Many requests on single connection
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
PROTOCOL
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
PROTOCOL BASICS | THEORY
• Text-like binary protocol
• Message delimiter -> n, 0x0a
• Column delimiter -> t, 0x09
• Null -> 0, 0x00
• Empty string -> tt, tn
• Characters [0x00 - 0x0f] -> prefixed by 0x01 and shifted by 0x40
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
OPEN INDEX | THEORY
P <index_id> <db> <table> <index> <columns> [<fcolumns>]
<index_id>
Opened index identifier, integer, opened until the client connection
is closed
<db> Database name
<table> Table name
<index> Index name or "PRIMARY" to use primary key
<columns> List of columns to return in response, delimited by ","
[<fcolumns>] Optional argument, list of columns to filter result on
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
FIND DATA | THEORY
<index_id> <op> <vlen> <v1> … <vn> [LIM] [IN] [FILTER …]
<index_id> Opened index identifier
<op> Comparison operation to use: =, >, >=, <, <=
<vlen> Number parameters to compare, equal or less than number of
columns in opened index
<v1> Value to compare using <op> with corresponding column from
index
[LIM] <limit> <offset> default values: limit=1, offset=0
[IN] @ <icol> <ivlen> <iv1> ... <ivn>
[FILTER …] <ftyp> <fop> <fcol> <fval>
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
RESPONSE | THEORY
<errorcode> <numcolumns> <r1> ... <rn>
<errorcode>
Request has successfully executed or not.
'0' means success. Non-zero means an error
<numcolumns> Number of columns of the result set
<r1> … <rn> Result set, n equals <numcolumns>
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
RESPONSE | THEORY
„If <errorcode> is non-zero, <numcolumns>
is always 1 and <r1> indicates a
human-readable error message, though
sometimes <r1> is not provided.”
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SQL TO HANDLERSOCKET | THEORY
SELECT value FROM t WHERE id=1 LIMIT 1
P 1 test t PRIMARY value
= 0 1
1 = 1 1 0 1 600a5841de
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
SUMMARY
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
PROS | SUMMARY
• Stable
• High performance
• Data consistency
• Replication support
• Not dependent on data storage engine
• Shipped with MariaDB, Percona Server
• Still allows to use SQL client/server protocol
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
CONS | SUMMARY
• Filtering only using indexes
• Non-standard protocol
• Very simple authentication (password per port)
• Lack of support for transactions
• Small community
• Rarely used on production
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
KNOWN ISSUES | SUMMARY
• Persistent connections
• Too many indexes (> 1024?)
• Concurrent structure changes via SQL and data
modification via HandlerSocket
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
Q’N’A
Questions?
HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
THANK YOU!
docplanner.com/career
Join us!

More Related Content

What's hot

Scala in a wild enterprise
Scala in a wild enterpriseScala in a wild enterprise
Scala in a wild enterpriseRafael Bagmanov
 
Cassandra Development Nirvana
Cassandra Development Nirvana Cassandra Development Nirvana
Cassandra Development Nirvana DataStax
 
Approaching graph db
Approaching graph dbApproaching graph db
Approaching graph dbSergey Enin
 
Building scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPBuilding scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPdatamantra
 
Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...
Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...
Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...Carlos Sierra
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersCarlos Sierra
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automationCarlos Sierra
 
Introduction to ScalaZ
Introduction to ScalaZIntroduction to ScalaZ
Introduction to ScalaZKnoldus Inc.
 
Sînică Alboaie - Programming for cloud computing Flows of asynchronous messages
Sînică Alboaie - Programming for cloud computing Flows of asynchronous messagesSînică Alboaie - Programming for cloud computing Flows of asynchronous messages
Sînică Alboaie - Programming for cloud computing Flows of asynchronous messagesCodecamp Romania
 
ELK Wrestling (Leeds DevOps)
ELK Wrestling (Leeds DevOps)ELK Wrestling (Leeds DevOps)
ELK Wrestling (Leeds DevOps)Steve Elliott
 
Apache Cassandra: building a production app on an eventually-consistent DB
Apache Cassandra: building a production app on an eventually-consistent DBApache Cassandra: building a production app on an eventually-consistent DB
Apache Cassandra: building a production app on an eventually-consistent DBOliver Lockwood
 
CNIT 141 9. Hard Problems
CNIT 141 9. Hard ProblemsCNIT 141 9. Hard Problems
CNIT 141 9. Hard ProblemsSam Bowne
 
Building Distributed Systems from Scratch - Part 1
Building Distributed Systems from Scratch - Part 1Building Distributed Systems from Scratch - Part 1
Building Distributed Systems from Scratch - Part 1datamantra
 
Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"Demi Ben-Ari
 
Effectiveness and code optimization in Java
Effectiveness and code optimization in JavaEffectiveness and code optimization in Java
Effectiveness and code optimization in JavaStrannik_2013
 
Thinking Functionally with Clojure
Thinking Functionally with ClojureThinking Functionally with Clojure
Thinking Functionally with ClojureJohn Stevenson
 
Scala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkScala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkDemi Ben-Ari
 
Loading 350M documents into a large Solr cluster: Presented by Dion Olsthoorn...
Loading 350M documents into a large Solr cluster: Presented by Dion Olsthoorn...Loading 350M documents into a large Solr cluster: Presented by Dion Olsthoorn...
Loading 350M documents into a large Solr cluster: Presented by Dion Olsthoorn...Lucidworks
 
ELK at LinkedIn - Kafka, scaling, lessons learned
ELK at LinkedIn - Kafka, scaling, lessons learnedELK at LinkedIn - Kafka, scaling, lessons learned
ELK at LinkedIn - Kafka, scaling, lessons learnedTin Le
 

What's hot (20)

Scala in a wild enterprise
Scala in a wild enterpriseScala in a wild enterprise
Scala in a wild enterprise
 
Cassandra Development Nirvana
Cassandra Development Nirvana Cassandra Development Nirvana
Cassandra Development Nirvana
 
Approaching graph db
Approaching graph dbApproaching graph db
Approaching graph db
 
Building scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPBuilding scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTP
 
Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...
Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...
Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginners
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automation
 
Introduction to ScalaZ
Introduction to ScalaZIntroduction to ScalaZ
Introduction to ScalaZ
 
Sînică Alboaie - Programming for cloud computing Flows of asynchronous messages
Sînică Alboaie - Programming for cloud computing Flows of asynchronous messagesSînică Alboaie - Programming for cloud computing Flows of asynchronous messages
Sînică Alboaie - Programming for cloud computing Flows of asynchronous messages
 
ELK Wrestling (Leeds DevOps)
ELK Wrestling (Leeds DevOps)ELK Wrestling (Leeds DevOps)
ELK Wrestling (Leeds DevOps)
 
Apache Cassandra: building a production app on an eventually-consistent DB
Apache Cassandra: building a production app on an eventually-consistent DBApache Cassandra: building a production app on an eventually-consistent DB
Apache Cassandra: building a production app on an eventually-consistent DB
 
CNIT 141 9. Hard Problems
CNIT 141 9. Hard ProblemsCNIT 141 9. Hard Problems
CNIT 141 9. Hard Problems
 
JugMarche: Neo4j 2 (Cypher)
JugMarche: Neo4j 2 (Cypher)JugMarche: Neo4j 2 (Cypher)
JugMarche: Neo4j 2 (Cypher)
 
Building Distributed Systems from Scratch - Part 1
Building Distributed Systems from Scratch - Part 1Building Distributed Systems from Scratch - Part 1
Building Distributed Systems from Scratch - Part 1
 
Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"Monitoring Big Data Systems - "The Simple Way"
Monitoring Big Data Systems - "The Simple Way"
 
Effectiveness and code optimization in Java
Effectiveness and code optimization in JavaEffectiveness and code optimization in Java
Effectiveness and code optimization in Java
 
Thinking Functionally with Clojure
Thinking Functionally with ClojureThinking Functionally with Clojure
Thinking Functionally with Clojure
 
Scala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkScala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache spark
 
Loading 350M documents into a large Solr cluster: Presented by Dion Olsthoorn...
Loading 350M documents into a large Solr cluster: Presented by Dion Olsthoorn...Loading 350M documents into a large Solr cluster: Presented by Dion Olsthoorn...
Loading 350M documents into a large Solr cluster: Presented by Dion Olsthoorn...
 
ELK at LinkedIn - Kafka, scaling, lessons learned
ELK at LinkedIn - Kafka, scaling, lessons learnedELK at LinkedIn - Kafka, scaling, lessons learned
ELK at LinkedIn - Kafka, scaling, lessons learned
 

Similar to HandlerSocket

NoSQL Intro with cassandra
NoSQL Intro with cassandraNoSQL Intro with cassandra
NoSQL Intro with cassandraBrian Enochson
 
SQL Now! How Optiq brings the best of SQL to NoSQL data.
SQL Now! How Optiq brings the best of SQL to NoSQL data.SQL Now! How Optiq brings the best of SQL to NoSQL data.
SQL Now! How Optiq brings the best of SQL to NoSQL data.Julian Hyde
 
Scaling for Performance
Scaling for PerformanceScaling for Performance
Scaling for PerformanceScyllaDB
 
DataStax C*ollege Credit: What and Why NoSQL?
DataStax C*ollege Credit: What and Why NoSQL?DataStax C*ollege Credit: What and Why NoSQL?
DataStax C*ollege Credit: What and Why NoSQL?DataStax
 
Solve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSolve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSupun Dissanayake
 
Predicting SPARQL query execution time and suggesting SPARQL queries based on...
Predicting SPARQL query execution time and suggesting SPARQL queries based on...Predicting SPARQL query execution time and suggesting SPARQL queries based on...
Predicting SPARQL query execution time and suggesting SPARQL queries based on...Rakebul Hasan
 
NOSQL Meets Relational - The MySQL Ecosystem Gains More Flexibility
NOSQL Meets Relational - The MySQL Ecosystem Gains More FlexibilityNOSQL Meets Relational - The MySQL Ecosystem Gains More Flexibility
NOSQL Meets Relational - The MySQL Ecosystem Gains More FlexibilityIvan Zoratti
 
Databases in the Cloud - DevDay Austin 2017 Day 2
Databases in the Cloud - DevDay Austin 2017 Day 2Databases in the Cloud - DevDay Austin 2017 Day 2
Databases in the Cloud - DevDay Austin 2017 Day 2Amazon Web Services
 
NoSQL Now! Webinar Series: Innovations in NoSQL Query Languages
NoSQL Now! Webinar Series: Innovations in NoSQL Query Languages  NoSQL Now! Webinar Series: Innovations in NoSQL Query Languages
NoSQL Now! Webinar Series: Innovations in NoSQL Query Languages DATAVERSITY
 
Is there a SQL for NoSQL?
Is there a SQL for NoSQL?Is there a SQL for NoSQL?
Is there a SQL for NoSQL?Arthur Keen
 
0bbleedingedge long-140614012258-phpapp02 lynn-langit
0bbleedingedge long-140614012258-phpapp02 lynn-langit0bbleedingedge long-140614012258-phpapp02 lynn-langit
0bbleedingedge long-140614012258-phpapp02 lynn-langitData Con LA
 
Bleeding Edge Databases
Bleeding Edge DatabasesBleeding Edge Databases
Bleeding Edge DatabasesLynn Langit
 
Declarative benchmarking of cassandra and it's data models
Declarative benchmarking of cassandra and it's data modelsDeclarative benchmarking of cassandra and it's data models
Declarative benchmarking of cassandra and it's data modelsMonal Daxini
 
C* Summit 2013: Real-time Analytics using Cassandra, Spark and Shark by Evan ...
C* Summit 2013: Real-time Analytics using Cassandra, Spark and Shark by Evan ...C* Summit 2013: Real-time Analytics using Cassandra, Spark and Shark by Evan ...
C* Summit 2013: Real-time Analytics using Cassandra, Spark and Shark by Evan ...DataStax Academy
 
AWS Summit 2013 | Singapore - Understanding Databases Options
AWS Summit 2013 | Singapore - Understanding Databases OptionsAWS Summit 2013 | Singapore - Understanding Databases Options
AWS Summit 2013 | Singapore - Understanding Databases OptionsAmazon Web Services
 

Similar to HandlerSocket (20)

NoSQL Intro with cassandra
NoSQL Intro with cassandraNoSQL Intro with cassandra
NoSQL Intro with cassandra
 
OscaR.cbls3.0_V7
OscaR.cbls3.0_V7OscaR.cbls3.0_V7
OscaR.cbls3.0_V7
 
SQL Now! How Optiq brings the best of SQL to NoSQL data.
SQL Now! How Optiq brings the best of SQL to NoSQL data.SQL Now! How Optiq brings the best of SQL to NoSQL data.
SQL Now! How Optiq brings the best of SQL to NoSQL data.
 
SFScon18 - Stefano Pampaloni - The SQL revenge
SFScon18 - Stefano Pampaloni - The SQL revengeSFScon18 - Stefano Pampaloni - The SQL revenge
SFScon18 - Stefano Pampaloni - The SQL revenge
 
Ipc mysql php
Ipc mysql php Ipc mysql php
Ipc mysql php
 
Scaling for Performance
Scaling for PerformanceScaling for Performance
Scaling for Performance
 
DataStax C*ollege Credit: What and Why NoSQL?
DataStax C*ollege Credit: What and Why NoSQL?DataStax C*ollege Credit: What and Why NoSQL?
DataStax C*ollege Credit: What and Why NoSQL?
 
Solve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSolve it Differently with Reactive Programming
Solve it Differently with Reactive Programming
 
Predicting SPARQL query execution time and suggesting SPARQL queries based on...
Predicting SPARQL query execution time and suggesting SPARQL queries based on...Predicting SPARQL query execution time and suggesting SPARQL queries based on...
Predicting SPARQL query execution time and suggesting SPARQL queries based on...
 
NOSQL Meets Relational - The MySQL Ecosystem Gains More Flexibility
NOSQL Meets Relational - The MySQL Ecosystem Gains More FlexibilityNOSQL Meets Relational - The MySQL Ecosystem Gains More Flexibility
NOSQL Meets Relational - The MySQL Ecosystem Gains More Flexibility
 
MySQL on Ceph
MySQL on CephMySQL on Ceph
MySQL on Ceph
 
My SQL on Ceph
My SQL on CephMy SQL on Ceph
My SQL on Ceph
 
Databases in the Cloud - DevDay Austin 2017 Day 2
Databases in the Cloud - DevDay Austin 2017 Day 2Databases in the Cloud - DevDay Austin 2017 Day 2
Databases in the Cloud - DevDay Austin 2017 Day 2
 
NoSQL Now! Webinar Series: Innovations in NoSQL Query Languages
NoSQL Now! Webinar Series: Innovations in NoSQL Query Languages  NoSQL Now! Webinar Series: Innovations in NoSQL Query Languages
NoSQL Now! Webinar Series: Innovations in NoSQL Query Languages
 
Is there a SQL for NoSQL?
Is there a SQL for NoSQL?Is there a SQL for NoSQL?
Is there a SQL for NoSQL?
 
0bbleedingedge long-140614012258-phpapp02 lynn-langit
0bbleedingedge long-140614012258-phpapp02 lynn-langit0bbleedingedge long-140614012258-phpapp02 lynn-langit
0bbleedingedge long-140614012258-phpapp02 lynn-langit
 
Bleeding Edge Databases
Bleeding Edge DatabasesBleeding Edge Databases
Bleeding Edge Databases
 
Declarative benchmarking of cassandra and it's data models
Declarative benchmarking of cassandra and it's data modelsDeclarative benchmarking of cassandra and it's data models
Declarative benchmarking of cassandra and it's data models
 
C* Summit 2013: Real-time Analytics using Cassandra, Spark and Shark by Evan ...
C* Summit 2013: Real-time Analytics using Cassandra, Spark and Shark by Evan ...C* Summit 2013: Real-time Analytics using Cassandra, Spark and Shark by Evan ...
C* Summit 2013: Real-time Analytics using Cassandra, Spark and Shark by Evan ...
 
AWS Summit 2013 | Singapore - Understanding Databases Options
AWS Summit 2013 | Singapore - Understanding Databases OptionsAWS Summit 2013 | Singapore - Understanding Databases Options
AWS Summit 2013 | Singapore - Understanding Databases Options
 

Recently uploaded

Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfFIDO Alliance
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 

Recently uploaded (20)

Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 

HandlerSocket

  • 2. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL ABOUT ME Lukasz Barulski • backend dev AKA IAmDoingEverythingExceptFrontend dev • been with DocPlanner since dinosaurs • kicks butts in MK X /lbarulski /in/lukaszbarulski
  • 3. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL FETCHING DATA - THE MYSQL WAY
  • 4. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SAMPLE QUERIES — OR —
  • 5. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SO, WHAT’S WRONG WITH THAT?
  • 6. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL
  • 7. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL BUT…LET’S TEST THE SPEED • PHP 7.0.4 • MariaDB 10.0.22 500 000 records with random data +
  • 8. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL WAY | SPEED TEST $resultsInMs = [];
 $statement = $pdo->prepare('SELECT value FROM t WHERE id=:id LIMIT 1');
 for ($i = 1; $i <= 500000; ++$i)
 {
 $before = microtime(true); 
 $statement->execute(['id' => $i]);
 $data = $statement->fetchColumn(); 
 $after = microtime(true);
 $resultsInMs[] = ($after-$before)*1000;
 }
 $resultInMs = array_sum($resultsInMs)/count($resultsInMs);
 echo round($resultInMs, 3) . ' ms.' . PHP_EOL;
 echo round(stats_standard_deviation($resultsInMs, true), 3) . ' ms.' . PHP_EOL;

  • 9. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL WAY | TEST RESULTS Average time: 0.131 ms. Standard deviation: 0.012 ms.
  • 10. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL WAY… WITHOUT STEROIDS| SPEED TEST $resultsInMs = [];
 for ($i = 1; $i <= 500000; ++$i)
 {
 $before = microtime(true);
 
 $data = $pdo
 ->query('SELECT value FROM t WHERE id='.$i.' LIMIT 1')
 ->fetchColumn();
 
 $after = microtime(true);
 $resultsInMs[] = ($after-$before)*1000;
 }
 $resultInMs = array_sum($resultsInMs)/count($resultsInMs);
 echo round($resultInMs, 3) . ' ms.' . PHP_EOL;
 echo round(stats_standard_deviation($resultsInMs, true), 3) . ' ms.' . PHP_EOL;
  • 11. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL WAY… WITHOUT STEROIDS| TEST RESULTS Average time: 0.257 ms. Standard deviation: 0.074 ms.
  • 12. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL WAY | EXAMPLES SQL Prepared Statements AVG: 0.131 ms. SQL AVG: 0.257 ms. Wordpress 4.4.2 homepage: 21 SELECT 21 x 0.257 ms. = 5.397 ms. Where that (sometimes) matters? • API • High frequency operations • Complicated (long running) reports • Microservices
  • 13. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SIMPLE SOLUTION?
  • 14. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL WAY | SOLUTION OR A HALF-MEASURE? • Warmup • Invalidation Problems:
  • 15. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL HANDLERSOCKET TO THE RESCUE!
  • 16. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL HANDLERSOCKET | THEORY •MySQL based SQL servers plugin •Text-like binary protocol - not SQL queries •TCP connection •Single thread for modifying data •Multiple threads for reading data •Coexists with standard way of using MySQL
  • 17. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL HANDLERSOCKET WAY | SPEED TEST $indexId = $hs->getIndexId('test', 't', '', 'id,value');
 $resultsInMs = [];
 for ($i = 1; $i <= 500000; ++$i)
 {
 $before = microtime(true);
 
 $hs->select($indexId, '=', [$i]);
 $data = $hs->readResponse();
 
 $after = microtime(true);
 $resultsInMs[] = ($after-$before)*1000;
 }
 $resultInMs = array_sum($resultsInMs)/(float)count($resultsInMs);
 echo round($resultInMs, 3) . ' ms.' . PHP_EOL;
 echo round(stats_standard_deviation($resultsInMs, true), 3) . ' ms.' . PHP_EOL;
  • 18. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL HANDLERSOCKET WAY | TEST RESULTS Average time: 0.073 ms. Standard deviation: 0.009 ms.
  • 19. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL VS. HANDLERSOCKET
  • 20. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL VS. HANDLERSOCKET | AVG(FETCHING TIME) BOXING NIGHT SQL SQL PS HS 0 0,065 0,13 0,195 0,26 0,073MS 0,131MS 0,257MS
  • 21. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL VS. HANDLERSOCKET | STDEV(FETCHING TIME) BOXING NIGHT SQL SQL PS HS 0 0,02 0,04 0,06 0,08 0,009MS 0,012MS 0,074MS
  • 22. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL OK, BUT WHY IS IT FASTER?
  • 23. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL VS. HANDLERSOCKET | LEO, WHY? Few steps less Few bytes less • No query parsing • No query analysis • No query execution plan • ~40% smaller request size • ~40% smaller response size Less CPU usage Less network traffic Based on our examples
  • 24. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL COMMUNICATION
  • 25. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL COMMUNICATION | THEORY • Port 9998 • Port 9999 • Read only • Multi threaded • Write allowed • Single threaded • One-line request • One-line response • Many requests on single connection
  • 26. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL PROTOCOL
  • 27. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL PROTOCOL BASICS | THEORY • Text-like binary protocol • Message delimiter -> n, 0x0a • Column delimiter -> t, 0x09 • Null -> 0, 0x00 • Empty string -> tt, tn • Characters [0x00 - 0x0f] -> prefixed by 0x01 and shifted by 0x40
  • 28. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL OPEN INDEX | THEORY P <index_id> <db> <table> <index> <columns> [<fcolumns>] <index_id> Opened index identifier, integer, opened until the client connection is closed <db> Database name <table> Table name <index> Index name or "PRIMARY" to use primary key <columns> List of columns to return in response, delimited by "," [<fcolumns>] Optional argument, list of columns to filter result on
  • 29. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL FIND DATA | THEORY <index_id> <op> <vlen> <v1> … <vn> [LIM] [IN] [FILTER …] <index_id> Opened index identifier <op> Comparison operation to use: =, >, >=, <, <= <vlen> Number parameters to compare, equal or less than number of columns in opened index <v1> Value to compare using <op> with corresponding column from index [LIM] <limit> <offset> default values: limit=1, offset=0 [IN] @ <icol> <ivlen> <iv1> ... <ivn> [FILTER …] <ftyp> <fop> <fcol> <fval>
  • 30. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL RESPONSE | THEORY <errorcode> <numcolumns> <r1> ... <rn> <errorcode> Request has successfully executed or not. '0' means success. Non-zero means an error <numcolumns> Number of columns of the result set <r1> … <rn> Result set, n equals <numcolumns>
  • 31. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL RESPONSE | THEORY „If <errorcode> is non-zero, <numcolumns> is always 1 and <r1> indicates a human-readable error message, though sometimes <r1> is not provided.”
  • 32. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SQL TO HANDLERSOCKET | THEORY SELECT value FROM t WHERE id=1 LIMIT 1 P 1 test t PRIMARY value = 0 1 1 = 1 1 0 1 600a5841de
  • 33. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL SUMMARY
  • 34. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL PROS | SUMMARY • Stable • High performance • Data consistency • Replication support • Not dependent on data storage engine • Shipped with MariaDB, Percona Server • Still allows to use SQL client/server protocol
  • 35. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL CONS | SUMMARY • Filtering only using indexes • Non-standard protocol • Very simple authentication (password per port) • Lack of support for transactions • Small community • Rarely used on production
  • 36. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL KNOWN ISSUES | SUMMARY • Persistent connections • Too many indexes (> 1024?) • Concurrent structure changes via SQL and data modification via HandlerSocket
  • 37. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL Q’N’A Questions?
  • 38. HANDLERSOCKET – A NOSQL APPROACH TO MYSQL THANK YOU! docplanner.com/career Join us!