MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011
Upcoming SlideShare
Loading in...5
×
 

MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011

on

  • 6,182 views

A quick overview on the MySQL native driver for PHP (mysqlnd) and its unique features. Edition 2011. What is mysqlnd, why use it, which plugins exist, where to find more information.... the current ...

A quick overview on the MySQL native driver for PHP (mysqlnd) and its unique features. Edition 2011. What is mysqlnd, why use it, which plugins exist, where to find more information.... the current state. Expect a new summary every year.

Statistics

Views

Total Views
6,182
Views on SlideShare
3,346
Embed Views
2,836

Actions

Likes
1
Downloads
25
Comments
0

12 Embeds 2,836

http://blog.ulf-wendel.de 2813
http://localhost 5
http://us-w1.rockmelt.com 4
http://a0.twimg.com 3
http://tweetedtimes.com 2
http://www.blog.ulf-wendel.de 2
http://translate.googleusercontent.com 2
http://www.twylah.com 1
http://www.planet-php.net 1
http://www.slideshare.net 1
http://www.hanrss.com 1
https://twitter.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011 MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011 Presentation Transcript

  • Ulf Wendel, Oracle Introduction and overview, Edition 2011 The MySQL native driver for PHP (mysqlnd)
  • The speaker says... The MySQL native driver for PHP (mysqlnd) is a drop-in replacement for the MySQL Client Library (AKA libmysql). All PHP MySQL extensions can be compiled to use mysqlnd instead of libmysql. The mysqlnd library ships with PHP as PHP 5.3. Mysqlnd is part of the PHP source tree and distributed under the terms of the PHP license to avoid any license issues. PHP builds for Windows obtained from php.net use mysqlnd since PHP 5.3. Mysqlnd is a compile time default for all PHP MySQL extensions as of PHP 5.4.
    • New, unmatched features
      • Plugin API for extensions – client-side proxies View slide
      • Asynchronous, non-blocking queries View slide
      • Performance statistics, read-only variables, ...
    The mysqlnd library MySQL Server
  • The speaker says... The mysqlnd library implements the MySQL Client Server protocol. All three PHP MySQL extensions can be compiled to use it to communicate with MySQL. Mysqlnd is tightly integrated into PHP and highly optimized for it. Therefore, it can outperform the MySQL Client Library in certain areas. The MySQL Client Library is a general purpose library for all kinds of C/C++ clients. As such, it cannot offer all mysqlnd features. For example, memory savings by read-only variables (transparent for users) or respect of PHP memory limits is not possible without tight integration into PHP.
    • Open source plugins available from PECL
      • mysqlnd_ms – Replication and Load Balancing
      • mysqlnd_qc – Client-side query caching
      • mysqlnd_uh – Monitoring, rewriting, ... with PHP
      • Prototypes: SQL injection protection, multi-query, ...
    Plugin API for extensions -> Presentation -> Documentation
  • The speaker says... A C plugin API is available for extending the mysqlnd C library. Open source, ready-to-use plugins are available from PECL. Plugins for MySQL replication and load balancing support (mysqlnd_ms), a client-side query cache (mysqlnd_qc), a swiss-army-knife plugin (mysqlnd_uh) which allows writing plugins with PHP for easy query monitoring, query rewriting and more. Plugins are client-side proxies. They operate on their own layer below the application. Plugins can be drop-in solutions requiring no application changes!
    • MySQL Replication support drop-in solution
      • Read/write splitting: automatic, user-defined
      • Load Balancing: round robin, random, user-defined
      • Client failover, master on write, transaction aware, ...
    Replication and Load Balancing -> Presentation -> Documentation MySQL Server 1 MySQL Server 2 MySQL Server n
  • The speaker says... The Replication and Load Balancing plugin (mysqlnd_ms) has been designed as a drop-in solution. For simple use cases no application changes are required when stepping up from a single MySQL server to a MySQL replication cluster. Advanced users can overwrite all automatic decisions of the plugin to handle arbitrary complex use cases. Goodies built-in to version 1.1.1 (early - more to come!) include use of master after first write to fight replication lag, transaction awareness and use of master, optional failover.
    • Transparent and fast TTL-based client-side cache
      • Cache control: TTL using SQL hint, user-defined, all
      • Storage: Memcache, SHM (APC), memory, user, ...
      • Slam/overload detection, no-double serialization, ...
    Client-side cache -> Presentation -> Documentation MySQL Server Memcache SHM (APC), ...
  • The speaker says... PECL/mysqlnd_qc is an easy to use client-side query cache. The cache is TTL based. Cached query results can be stored in various places: Memcache, shared memory (APC), process memory, SQLite or user-defined. Depending on the storage the cache results can be shared within the PHP process, all PHP processes running on a server or multiple servers. Caching is controlled with SQL hints. Optionally, all queries can be cache or a callback can be installed to control caching. The plugin is faster than any PHP solution by avoiding double-serialization. Goodies built-in to version 1.0.1 (early - more to come!) include slam protection ala Memcache and variable storage.
    • Swiss-army-knife for debugging and prototyping
      • Hooking of mysqlnd library calls with PHP
      • 'Plugins' with PHP not C, no application changes
      • Monitoring, Rewriting, Failover, you-name-it...
    User handler -> Presentation -> Documentation MySQL Server
  • The speaker says... PECL/mysqlnd_uh is the swiss-army knife of the plugins. Developed by Mayflower Open Source Labs, it lets you hook internal mysqlnd library calls from PHP! In other words: you can manipulate many library calls, such as connect() or query(), to write client-side proxies that work around application limitations. Use cases include query monitoring, query rewriting, auditing, failover, … Consider it, whenever you need a quick hack and you can't change the applications source code. It is best used for debugging and prototyping. Take care when using: you are hacking mysqlnd!
    • Non-blocking queries with mysqli @ mysqlnd
      • Non-blocking time: max(t1, t2, ..., tn)
      • Blocking time always higher: t1 + t2 + … + tn
      • Perfect for application-level sharding!
    Asynchronous queries -> Presentation -> Documentation
  • The speaker says... The mysqlnd library features non-blocking queries. A PHP script can perform other tasks, while waiting for a query result to be computed by MySQL. For example, the script can open additional connections to send additional statements. The total processing time for all statements performed in a non-blocking stlye is the run-time of the slowest statement. This is always faster than running statements in a blocking way, when individual run-times add up to the total run-time. Typical use-case: application-level sharding. Query multiple shards in a non-blocking way without extra message queue!
    • Unique to mysqlnd...
      • 150+ core performance statistics
      • 30+ query cache performance statistics
      • read-only variable concept for memory savings
      • debug and trace log
      • … find documentation: php.net/
      • … read development blogs: planet.mysql.com
      • … read more development blogs: planet-php.org
      • … follow on Twitter: @phperror , @Ulf_Wendel
    Other goodies
  • The speaker says... The mysqlnd library and its plugins are under constant development. It is well worth checking the documentation at php.net frequently for updates. It is even better to scan planet.mysql.com and planet-php.org. The mysqlnd developers try to blog and twitter about ideas, prototypes and latest developments, seeking for early feedback. However, if you are seriously interested in contacting us, which we hope you are, it should not be difficult to get in touch. Personally and virtually. Looking forward to answer your mysqlnd requests!
  • THE END Credits: Andrey Hristov, Johannes Schlüter - Contact: ulf.wendel@oracle.com