PHP mysqlnd connection multiplexing plugin

U
Ulf WendelSenior Software Engineer um Oracle
Ulf Wendel, Oracle



    PHP mysqlnd
Connection Multiplexing

    PECL/mysqlnd_mux 1.0.0-prototype
The speaker says...
When fast is not fast enough, you pull all triggers. This
includes attempts to optimize an already reasonable fast
operation: connect time to MySQL.


The PHP mysqlnd connection multiplexing plugin,
shares a physical connection among multiple user
handles. Thus, connection overhead is saved on the client
side and the number of opened connection is reduced on the
server side.
PECL/mysqlnd_mux is an Oracle open source development
available from pecl.php.net. Developed by Andrey
Hristov.
Plugins are mostly transparent
 WordPress, Drupal, Symfony, Oxid, ZendFramework, ...


               mysql, mysqli, PDO_MYSQL

                       mysqlnd

              PECL/mysqlnd_mux plugin

               Connection Multiplexing



                     MySQL Server
The speaker says...
PECL/mysqlnd_mux is a plugin for the mysqlnd library. The
mysqlnd library is the default C client library used
by the PHP MySQL extensions mysql, mysqli and
PDO_MySQL internally. Mysqlnd ships with PHP since 5.3.


Plugins operate at a layer beneath the user APIs,
thus improvements are available to all PHP MySQL
APIs.


Other free plugins are PECL/mysqlnd_ms (replication and
load balancing), PECL/mysqlnd_qc (client-side query cache)
and many more.
PECL/mysqlnd_mux
●
    Multiplexing: share connection among handles
       Reduce client connect overhead, reduce server load
       Prototype, requires PHP 5.5.0+

        connect()        connect()         connect()


                    n connection handles

                    PECL/mysqlnd_mux

                        1 connection


                          MySQL
The speaker says...
The PHP mysqlnd connection multiplexing proxies MySQL
connections. Whenever a client attempts to open a
connection to a host, the plugin checks whether there is
already a cached network connection to the host in
question. If not, a new connection is established and
associated with the users' connection handle. Otherwise,
the users' connection handle is linked with an
already opened network connection.

This way, multiple user handles can point to the
same network connection and share it. Connection
overhead is saved and fewer connections are opened.
The price you pay
●
    Multiplexing means serializing tasks
        Possibility of wait situations
        Prototype: no upgrade to dedicated connection
        Prototype: no collision counter


    Query 1
                   MUX     Query 1   Query 2    MySQL
       Query 2


                                                  Time
The speaker says...
Sharing a resource often requires serializing access to it.
This is also the case with a shared connection of the PHP
mysqlnd connection multiplexing plugin. Serializing
actions bares the risks of collisions and wait
situations. In the example, a clients query has to wait for
completion of another clients query before it can be
executed. Query 2 waits for query 1 to finish.


The prototype is using a mutex to synchronize access to a
shared connection.
MUX as a demo of the plugin API
●
    No new API calls, it just works!

        Supports popular buffered queries
        (mysql_query(), mysqli_query(),
        PDO if using PDO::ATTR_EMULATE_PREPARES)

        Prototype does not handle unbuffered queries
        (mysqli_real_query())
        Prepared statements not in 1.0.0-prototype
        (mysqli_stmt_*())
The speaker says...
PECL/mysqlnd_mux 1.0.0-prototype is an example of the
strenghts of the mysqlnd C plugin API. The initial public
release is not a production-ready stable solution. Features
have been skipped for the prototype to keep the
demo of the plugin API short and comprehensive.


The astonishing finding of the plugin is that multiplexing
can be added to add PHP MySQL APIs without
changing the APIs. It just works – for some cases already
today. Other cases could be covered in future
versions, depending on user feedback.
THAT'S IT FOLKS?
Compared to pooling
●
    Connection remains open after close()
        Connection establishment overhead reduced
        Number of concurrent connections not reduced
        Usually, connection state reset upon reuse
                  Client                Client


                     Connection pool


            Connection     Connection     Connection


                            MySQL
The speaker says...
A connection pool is a cache for connections. If a
client openes a connection, the pool is checked for an
already estiablished connection to the requested host. In
case of a hit, the pooled connection is reset, then taken from
the pool of unused connections and returned to the client. If
no connection is found a new one gets opened and returned
to the caller. Then, the connection is used until the client
calls close(). Upon close(), the connection is not closed but
put back into the pool for reuse.


Pooling saves time on reuse but does not reduce the total
number of concurrent connections.
Persistent Connection
●
    Connection remains open after close()
         Connection overhead and reuse costs reduced
         Number of concurrent connections not reduced
         Connection state not reset before reuse

    Client 1               Pool    Connection 1     MySQL

               SET @myvar = 1

    Client 2               Pool    Connection 1     MySQL

               SELECT @myvar
The speaker says...
Persistent connections can be described as a special kind of
 pooled connections. As the name says, the state of a
persistent connection is not reset between use .
PHP persistent database connections have often been
criticised for persisting the state of a connection... - for their
very purpose!


Thus, when „persistent connections“ have been added to the
mysqli extension, mysqli actually got pooled
connections. By default, the connection state is
reset before reuse. Performance fanatics can disable this
during compile time.
Speed-up tricks compared
●
    Every optimization is a trade
         You gain something: fewer connections opened
         You give something: collision possible
         You gain something: lower connection costs
         You give something: no isolation of connection state
                                              MUX   Pooled   Pers. Conn
                                                     Conn.
Reduce connection overhead                    Yes     Yes            Yes
Reduce # concurrently open connections        Yes      No             No
Connection state shared among clients         Yes      No            Yes
                                                             (mysqli: No)
Serialization required, collisions possible   Yes      No             No
The speaker says...
Optimizations, such as multiplexing, pooling or persistent
connections come at a price. There is no one-fits all trick.


Please, try to understand the properties of each
option. Then, decide on a case-by-case basis
which technology to use.
Remember: scope/life-span
●
    Pools are bound to a PHP process
       Depending on deployment model,
       a PHP process handles one or multiple requests


                     HTTP Server

          PHP process          PHP process

         Connection pool     Connection pool

         Conn 1   Conn 2    Conn 3    Conn 4
The speaker says...
Operating systems associate file descriptors, including
network connections, with processes. At the end of the
process, the network connections are closed. Thus, the
life-span of every client-side cache/pool of a PHP
process is that of the PHP process. No matter
whether we are discussing connections cached for
multiplexing or persistent connections as found in
any of the PHP MySQL APIs (mysql, mysqli,
PDO_MySQL).


Depending on the web server deployment model, a PHP
process handles one or multiple requests (script runs).
THE END



      http://www.slideshare.net/nixnutz/
Contact: ulf.wendel@oracle.com, @Ulf_Wendel
1 von 20

Recomendados

MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011 von
MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011
MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011Ulf Wendel
2.4K views17 Folien
Data massage: How databases have been scaled from one to one million nodes von
Data massage: How databases have been scaled from one to one million nodesData massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodesUlf Wendel
24.3K views307 Folien
The PHP mysqlnd plugin talk - plugins an alternative to MySQL Proxy von
The PHP mysqlnd plugin talk - plugins an alternative to MySQL ProxyThe PHP mysqlnd plugin talk - plugins an alternative to MySQL Proxy
The PHP mysqlnd plugin talk - plugins an alternative to MySQL ProxyUlf Wendel
3K views75 Folien
MySQL 5.6 Global Transaction IDs - Use case: (session) consistency von
MySQL 5.6 Global Transaction IDs - Use case: (session) consistencyMySQL 5.6 Global Transaction IDs - Use case: (session) consistency
MySQL 5.6 Global Transaction IDs - Use case: (session) consistencyUlf Wendel
2.8K views25 Folien
Intro to PECL/mysqlnd_ms (4/7/2011) von
Intro to PECL/mysqlnd_ms (4/7/2011)Intro to PECL/mysqlnd_ms (4/7/2011)
Intro to PECL/mysqlnd_ms (4/7/2011)Chris Barber
7K views25 Folien
The mysqlnd replication and load balancing plugin von
The mysqlnd replication and load balancing pluginThe mysqlnd replication and load balancing plugin
The mysqlnd replication and load balancing pluginUlf Wendel
3K views50 Folien

Más contenido relacionado

Was ist angesagt?

MySQL 5.7 Fabric: Introduction to High Availability and Sharding von
MySQL 5.7 Fabric: Introduction to High Availability and Sharding MySQL 5.7 Fabric: Introduction to High Availability and Sharding
MySQL 5.7 Fabric: Introduction to High Availability and Sharding Ulf Wendel
52.5K views65 Folien
Vote NO for MySQL von
Vote NO for MySQLVote NO for MySQL
Vote NO for MySQLUlf Wendel
3.2K views61 Folien
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4 von
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4Ulf Wendel
8.5K views67 Folien
Built-in query caching for all PHP MySQL extensions/APIs von
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/APIsUlf Wendel
3.4K views62 Folien
HTTP Plugin for MySQL! von
HTTP Plugin for MySQL!HTTP Plugin for MySQL!
HTTP Plugin for MySQL!Ulf Wendel
95.4K views105 Folien
MySQL 5.7 clustering: The developer perspective von
MySQL 5.7 clustering: The developer perspectiveMySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspectiveUlf Wendel
5.8K views85 Folien

Was ist angesagt?(20)

MySQL 5.7 Fabric: Introduction to High Availability and Sharding von Ulf Wendel
MySQL 5.7 Fabric: Introduction to High Availability and Sharding MySQL 5.7 Fabric: Introduction to High Availability and Sharding
MySQL 5.7 Fabric: Introduction to High Availability and Sharding
Ulf Wendel52.5K views
Vote NO for MySQL von Ulf Wendel
Vote NO for MySQLVote NO for MySQL
Vote NO for MySQL
Ulf Wendel3.2K views
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4 von Ulf Wendel
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
Ulf Wendel8.5K views
Built-in query caching for all PHP MySQL extensions/APIs von Ulf Wendel
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
Ulf Wendel3.4K views
HTTP Plugin for MySQL! von Ulf Wendel
HTTP Plugin for MySQL!HTTP Plugin for MySQL!
HTTP Plugin for MySQL!
Ulf Wendel95.4K views
MySQL 5.7 clustering: The developer perspective von Ulf Wendel
MySQL 5.7 clustering: The developer perspectiveMySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspective
Ulf Wendel5.8K views
PoC: Using a Group Communication System to improve MySQL Replication HA von Ulf Wendel
PoC: Using a Group Communication System to improve MySQL Replication HAPoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HA
Ulf Wendel6.1K views
DIY: A distributed database cluster, or: MySQL Cluster von Ulf Wendel
DIY: A distributed database cluster, or: MySQL ClusterDIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL Cluster
Ulf Wendel10.6K views
MySQL Group Replication von Ulf Wendel
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
Ulf Wendel33.1K views
Award-winning technology: Oxid loves the query cache von Ulf Wendel
Award-winning technology: Oxid loves the query cacheAward-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cache
Ulf Wendel3.2K views
Highly Available MySQL/PHP Applications with mysqlnd von Jervin Real
Highly Available MySQL/PHP Applications with mysqlndHighly Available MySQL/PHP Applications with mysqlnd
Highly Available MySQL/PHP Applications with mysqlnd
Jervin Real4.9K views
Introduction to Galera von Henrik Ingo
Introduction to GaleraIntroduction to Galera
Introduction to Galera
Henrik Ingo9.6K views
MySQL Multi Master Replication von Moshe Kaplan
MySQL Multi Master ReplicationMySQL Multi Master Replication
MySQL Multi Master Replication
Moshe Kaplan19.9K views
Mysql high availability and scalability von yin gong
Mysql high availability and scalabilityMysql high availability and scalability
Mysql high availability and scalability
yin gong1.8K views
MySQL X protocol - Talking to MySQL Directly over the Wire von Simon J Mudd
MySQL X protocol - Talking to MySQL Directly over the WireMySQL X protocol - Talking to MySQL Directly over the Wire
MySQL X protocol - Talking to MySQL Directly over the Wire
Simon J Mudd3.3K views
Scaling with sync_replication using Galera and EC2 von Marco Tusa
Scaling with sync_replication using Galera and EC2Scaling with sync_replication using Galera and EC2
Scaling with sync_replication using Galera and EC2
Marco Tusa2.6K views
MySQL Database Architectures - InnoDB ReplicaSet & Cluster von Kenny Gryp
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
Kenny Gryp2.6K views

Destacado

The power of mysqlnd plugins von
The power of mysqlnd pluginsThe power of mysqlnd plugins
The power of mysqlnd pluginsUlf Wendel
1.6K views72 Folien
Lecture#04, use case diagram von
Lecture#04, use case diagramLecture#04, use case diagram
Lecture#04, use case diagrambabak danyal
5.9K views24 Folien
Lecture #5 Data Communication and Network von
Lecture #5 Data Communication and NetworkLecture #5 Data Communication and Network
Lecture #5 Data Communication and Networkvasanthimuniasamy
5.9K views32 Folien
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL von
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLUlf Wendel
41.9K views89 Folien
Use case-diagrams von
Use case-diagramsUse case-diagrams
Use case-diagramsMaoelana Noermoehammad
58.1K views20 Folien
Advance Web Designing - Lecture 02 / 30 von
Advance Web Designing - Lecture 02 / 30Advance Web Designing - Lecture 02 / 30
Advance Web Designing - Lecture 02 / 30alishanvr
194 views27 Folien

Destacado(12)

The power of mysqlnd plugins von Ulf Wendel
The power of mysqlnd pluginsThe power of mysqlnd plugins
The power of mysqlnd plugins
Ulf Wendel1.6K views
Lecture#04, use case diagram von babak danyal
Lecture#04, use case diagramLecture#04, use case diagram
Lecture#04, use case diagram
babak danyal5.9K views
Lecture #5 Data Communication and Network von vasanthimuniasamy
Lecture #5 Data Communication and NetworkLecture #5 Data Communication and Network
Lecture #5 Data Communication and Network
vasanthimuniasamy5.9K views
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL von Ulf Wendel
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
Ulf Wendel41.9K views
Advance Web Designing - Lecture 02 / 30 von alishanvr
Advance Web Designing - Lecture 02 / 30Advance Web Designing - Lecture 02 / 30
Advance Web Designing - Lecture 02 / 30
alishanvr194 views
Hospital as an organisation von Nc Das
Hospital as an organisationHospital as an organisation
Hospital as an organisation
Nc Das106.8K views
Advance Web Designing - Lecture 1 / 30 von alishanvr
Advance Web Designing - Lecture 1 / 30Advance Web Designing - Lecture 1 / 30
Advance Web Designing - Lecture 1 / 30
alishanvr279 views
Node.js and The Internet of Things von Losant
Node.js and The Internet of ThingsNode.js and The Internet of Things
Node.js and The Internet of Things
Losant142.7K views
Data communication and network Chapter -1 von Zafar Ayub
Data communication and network Chapter -1Data communication and network Chapter -1
Data communication and network Chapter -1
Zafar Ayub103.6K views
Object-Oriented Analysis & Design (OOAD) Domain Modeling Introduction von Dang Tuan
  Object-Oriented Analysis & Design (OOAD)  Domain Modeling Introduction  Object-Oriented Analysis & Design (OOAD)  Domain Modeling Introduction
Object-Oriented Analysis & Design (OOAD) Domain Modeling Introduction
Dang Tuan24.8K views

Similar a PHP mysqlnd connection multiplexing plugin

Mysqlnd, an unknown powerful PHP extension von
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionjulien pauli
6.8K views60 Folien
Talon systems - Distributed multi master replication strategy von
Talon systems - Distributed multi master replication strategyTalon systems - Distributed multi master replication strategy
Talon systems - Distributed multi master replication strategySaptarshi Chatterjee
244 views7 Folien
Midwest PHP Presentation - New MSQL Features von
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesDave Stokes
104 views59 Folien
Reactive Applications with Apache Pulsar and Spring Boot von
Reactive Applications with Apache Pulsar and Spring BootReactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring BootVMware Tanzu
1.1K views23 Folien
Performance evaluation of larger matrices over cluster of four nodes using mpi von
Performance evaluation of larger matrices over cluster of four nodes using mpiPerformance evaluation of larger matrices over cluster of four nodes using mpi
Performance evaluation of larger matrices over cluster of four nodes using mpieSAT Journals
87 views5 Folien
A Domain-Specific Embedded Language for Programming Parallel Architectures. von
A Domain-Specific Embedded Language for Programming Parallel Architectures.A Domain-Specific Embedded Language for Programming Parallel Architectures.
A Domain-Specific Embedded Language for Programming Parallel Architectures.Jason Hearne-McGuiness
348 views15 Folien

Similar a PHP mysqlnd connection multiplexing plugin(20)

Mysqlnd, an unknown powerful PHP extension von julien pauli
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
julien pauli6.8K views
Talon systems - Distributed multi master replication strategy von Saptarshi Chatterjee
Talon systems - Distributed multi master replication strategyTalon systems - Distributed multi master replication strategy
Talon systems - Distributed multi master replication strategy
Midwest PHP Presentation - New MSQL Features von Dave Stokes
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL Features
Dave Stokes104 views
Reactive Applications with Apache Pulsar and Spring Boot von VMware Tanzu
Reactive Applications with Apache Pulsar and Spring BootReactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring Boot
VMware Tanzu1.1K views
Performance evaluation of larger matrices over cluster of four nodes using mpi von eSAT Journals
Performance evaluation of larger matrices over cluster of four nodes using mpiPerformance evaluation of larger matrices over cluster of four nodes using mpi
Performance evaluation of larger matrices over cluster of four nodes using mpi
eSAT Journals87 views
A Domain-Specific Embedded Language for Programming Parallel Architectures. von Jason Hearne-McGuiness
A Domain-Specific Embedded Language for Programming Parallel Architectures.A Domain-Specific Embedded Language for Programming Parallel Architectures.
A Domain-Specific Embedded Language for Programming Parallel Architectures.
ProxySQL Tutorial - PLAM 2016 von Derek Downey
ProxySQL Tutorial - PLAM 2016ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016
Derek Downey1.4K views
Clustering Multiple Instances in Cold Fusion von Mindfire Solutions
Clustering Multiple Instances in Cold FusionClustering Multiple Instances in Cold Fusion
Clustering Multiple Instances in Cold Fusion
Mindfire Solutions1.6K views
MOOC backbone using Netty and Protobuf von Gaurav Bhardwaj
MOOC backbone using Netty and ProtobufMOOC backbone using Netty and Protobuf
MOOC backbone using Netty and Protobuf
Gaurav Bhardwaj1.6K views
MySQL PHP native driver : Advanced Functions / PHP forum Paris 2013 von Serge Frezefond
 MySQL PHP native driver  : Advanced Functions / PHP forum Paris 2013   MySQL PHP native driver  : Advanced Functions / PHP forum Paris 2013
MySQL PHP native driver : Advanced Functions / PHP forum Paris 2013
Serge Frezefond16.4K views
Develop PHP Applications with MySQL X DevAPI von Dave Stokes
Develop PHP Applications with MySQL X DevAPIDevelop PHP Applications with MySQL X DevAPI
Develop PHP Applications with MySQL X DevAPI
Dave Stokes785 views
Software architecture for data applications von Ding Li
Software architecture for data applicationsSoftware architecture for data applications
Software architecture for data applications
Ding Li192 views
Client Centric Consistency Model von Rajat Kumar
Client Centric Consistency ModelClient Centric Consistency Model
Client Centric Consistency Model
Rajat Kumar4.9K views
Www Kitebird Com Articles Pydbapi Html Toc 1 von AkramWaseem
Www Kitebird Com Articles Pydbapi Html Toc 1Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1
AkramWaseem834 views

Último

State of the Union - Rohit Yadav - Apache CloudStack von
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStackShapeBlue
297 views53 Folien
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... von
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...ShapeBlue
106 views12 Folien
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue von
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueShapeBlue
135 views13 Folien
The Role of Patterns in the Era of Large Language Models von
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language ModelsYunyao Li
85 views65 Folien
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... von
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...ShapeBlue
159 views25 Folien
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... von
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...ShapeBlue
180 views18 Folien

Último(20)

State of the Union - Rohit Yadav - Apache CloudStack von ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue297 views
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... von ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue106 views
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue von ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue135 views
The Role of Patterns in the Era of Large Language Models von Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li85 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... von ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue159 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... von ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue180 views
NTGapps NTG LowCode Platform von Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu423 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... von ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue139 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... von ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue126 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... von ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue161 views
Optimizing Communication to Optimize Human Behavior - LCBM von Yaman Kumar
Optimizing Communication to Optimize Human Behavior - LCBMOptimizing Communication to Optimize Human Behavior - LCBM
Optimizing Communication to Optimize Human Behavior - LCBM
Yaman Kumar38 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... von Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
LLMs in Production: Tooling, Process, and Team Structure von Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage42 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online von ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue221 views
Future of AR - Facebook Presentation von Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty64 views
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... von BookNet Canada
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
BookNet Canada41 views

PHP mysqlnd connection multiplexing plugin

  • 1. Ulf Wendel, Oracle PHP mysqlnd Connection Multiplexing PECL/mysqlnd_mux 1.0.0-prototype
  • 2. The speaker says... When fast is not fast enough, you pull all triggers. This includes attempts to optimize an already reasonable fast operation: connect time to MySQL. The PHP mysqlnd connection multiplexing plugin, shares a physical connection among multiple user handles. Thus, connection overhead is saved on the client side and the number of opened connection is reduced on the server side. PECL/mysqlnd_mux is an Oracle open source development available from pecl.php.net. Developed by Andrey Hristov.
  • 3. Plugins are mostly transparent WordPress, Drupal, Symfony, Oxid, ZendFramework, ... mysql, mysqli, PDO_MYSQL mysqlnd PECL/mysqlnd_mux plugin Connection Multiplexing MySQL Server
  • 4. The speaker says... PECL/mysqlnd_mux is a plugin for the mysqlnd library. The mysqlnd library is the default C client library used by the PHP MySQL extensions mysql, mysqli and PDO_MySQL internally. Mysqlnd ships with PHP since 5.3. Plugins operate at a layer beneath the user APIs, thus improvements are available to all PHP MySQL APIs. Other free plugins are PECL/mysqlnd_ms (replication and load balancing), PECL/mysqlnd_qc (client-side query cache) and many more.
  • 5. PECL/mysqlnd_mux ● Multiplexing: share connection among handles Reduce client connect overhead, reduce server load Prototype, requires PHP 5.5.0+ connect() connect() connect() n connection handles PECL/mysqlnd_mux 1 connection MySQL
  • 6. The speaker says... The PHP mysqlnd connection multiplexing proxies MySQL connections. Whenever a client attempts to open a connection to a host, the plugin checks whether there is already a cached network connection to the host in question. If not, a new connection is established and associated with the users' connection handle. Otherwise, the users' connection handle is linked with an already opened network connection. This way, multiple user handles can point to the same network connection and share it. Connection overhead is saved and fewer connections are opened.
  • 7. The price you pay ● Multiplexing means serializing tasks Possibility of wait situations Prototype: no upgrade to dedicated connection Prototype: no collision counter Query 1 MUX Query 1 Query 2 MySQL Query 2 Time
  • 8. The speaker says... Sharing a resource often requires serializing access to it. This is also the case with a shared connection of the PHP mysqlnd connection multiplexing plugin. Serializing actions bares the risks of collisions and wait situations. In the example, a clients query has to wait for completion of another clients query before it can be executed. Query 2 waits for query 1 to finish. The prototype is using a mutex to synchronize access to a shared connection.
  • 9. MUX as a demo of the plugin API ● No new API calls, it just works! Supports popular buffered queries (mysql_query(), mysqli_query(), PDO if using PDO::ATTR_EMULATE_PREPARES) Prototype does not handle unbuffered queries (mysqli_real_query()) Prepared statements not in 1.0.0-prototype (mysqli_stmt_*())
  • 10. The speaker says... PECL/mysqlnd_mux 1.0.0-prototype is an example of the strenghts of the mysqlnd C plugin API. The initial public release is not a production-ready stable solution. Features have been skipped for the prototype to keep the demo of the plugin API short and comprehensive. The astonishing finding of the plugin is that multiplexing can be added to add PHP MySQL APIs without changing the APIs. It just works – for some cases already today. Other cases could be covered in future versions, depending on user feedback.
  • 12. Compared to pooling ● Connection remains open after close() Connection establishment overhead reduced Number of concurrent connections not reduced Usually, connection state reset upon reuse Client Client Connection pool Connection Connection Connection MySQL
  • 13. The speaker says... A connection pool is a cache for connections. If a client openes a connection, the pool is checked for an already estiablished connection to the requested host. In case of a hit, the pooled connection is reset, then taken from the pool of unused connections and returned to the client. If no connection is found a new one gets opened and returned to the caller. Then, the connection is used until the client calls close(). Upon close(), the connection is not closed but put back into the pool for reuse. Pooling saves time on reuse but does not reduce the total number of concurrent connections.
  • 14. Persistent Connection ● Connection remains open after close() Connection overhead and reuse costs reduced Number of concurrent connections not reduced Connection state not reset before reuse Client 1 Pool Connection 1 MySQL SET @myvar = 1 Client 2 Pool Connection 1 MySQL SELECT @myvar
  • 15. The speaker says... Persistent connections can be described as a special kind of pooled connections. As the name says, the state of a persistent connection is not reset between use . PHP persistent database connections have often been criticised for persisting the state of a connection... - for their very purpose! Thus, when „persistent connections“ have been added to the mysqli extension, mysqli actually got pooled connections. By default, the connection state is reset before reuse. Performance fanatics can disable this during compile time.
  • 16. Speed-up tricks compared ● Every optimization is a trade You gain something: fewer connections opened You give something: collision possible You gain something: lower connection costs You give something: no isolation of connection state MUX Pooled Pers. Conn Conn. Reduce connection overhead Yes Yes Yes Reduce # concurrently open connections Yes No No Connection state shared among clients Yes No Yes (mysqli: No) Serialization required, collisions possible Yes No No
  • 17. The speaker says... Optimizations, such as multiplexing, pooling or persistent connections come at a price. There is no one-fits all trick. Please, try to understand the properties of each option. Then, decide on a case-by-case basis which technology to use.
  • 18. Remember: scope/life-span ● Pools are bound to a PHP process Depending on deployment model, a PHP process handles one or multiple requests HTTP Server PHP process PHP process Connection pool Connection pool Conn 1 Conn 2 Conn 3 Conn 4
  • 19. The speaker says... Operating systems associate file descriptors, including network connections, with processes. At the end of the process, the network connections are closed. Thus, the life-span of every client-side cache/pool of a PHP process is that of the PHP process. No matter whether we are discussing connections cached for multiplexing or persistent connections as found in any of the PHP MySQL APIs (mysql, mysqli, PDO_MySQL). Depending on the web server deployment model, a PHP process handles one or multiple requests (script runs).
  • 20. THE END http://www.slideshare.net/nixnutz/ Contact: ulf.wendel@oracle.com, @Ulf_Wendel