SlideShare a Scribd company logo
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 enterprise
Rafael Bagmanov
 
Cassandra Development Nirvana
Cassandra Development Nirvana Cassandra Development Nirvana
Cassandra Development Nirvana
DataStax
 
Approaching graph db
Approaching graph dbApproaching graph db
Approaching graph db
Sergey 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 HTTP
datamantra
 
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 beginners
Carlos Sierra
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automation
Carlos Sierra
 
Introduction to ScalaZ
Introduction to ScalaZIntroduction to ScalaZ
Introduction to ScalaZ
Knoldus 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 messages
Codecamp 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 DB
Oliver Lockwood
 
CNIT 141 9. Hard Problems
CNIT 141 9. Hard ProblemsCNIT 141 9. Hard Problems
CNIT 141 9. Hard Problems
Sam Bowne
 
JugMarche: Neo4j 2 (Cypher)
JugMarche: Neo4j 2 (Cypher)JugMarche: Neo4j 2 (Cypher)
JugMarche: Neo4j 2 (Cypher)
Onofrio Panzarino
 
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
datamantra
 
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 Java
Strannik_2013
 
Thinking Functionally with Clojure
Thinking Functionally with ClojureThinking Functionally with Clojure
Thinking Functionally with Clojure
John 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 spark
Demi 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 learned
Tin 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 cassandra
Brian Enochson
 
OscaR.cbls3.0_V7
OscaR.cbls3.0_V7OscaR.cbls3.0_V7
OscaR.cbls3.0_V7
Renaud De Landtsheer
 
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
 
SFScon18 - Stefano Pampaloni - The SQL revenge
SFScon18 - Stefano Pampaloni - The SQL revengeSFScon18 - Stefano Pampaloni - The SQL revenge
SFScon18 - Stefano Pampaloni - The SQL revenge
South Tyrol Free Software Conference
 
Ipc mysql php
Ipc mysql php Ipc mysql php
Ipc mysql php
Anis Berejeb
 
Scaling for Performance
Scaling for PerformanceScaling for Performance
Scaling for Performance
ScyllaDB
 
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 Programming
Supun 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 Flexibility
Ivan Zoratti
 
MySQL on Ceph
MySQL on CephMySQL on Ceph
MySQL on Ceph
Kyle Bader
 
My SQL on Ceph
My SQL on CephMy SQL on Ceph
My SQL on Ceph
Red_Hat_Storage
 
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
Amazon 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-langit
Data Con LA
 
Bleeding Edge Databases
Bleeding Edge DatabasesBleeding Edge Databases
Bleeding Edge Databases
Lynn 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 models
Monal 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 Options
Amazon 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

Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 

Recently uploaded (20)

Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Artificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic WarfareArtificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic Warfare
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 

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!