IT_Architect
Verified User
- Joined
- Feb 27, 2006
- Messages
- 1,084
How To:
The HOW TO is the easy part.
http://help.directadmin.com/item.php?id=252
These are the lines that change:
These are the lines you need to change.
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
WHY you should care:
The WHY is a little more complicated. PHP has been going through a metamorphosis from a simple scripting language to something that has more in common with programming language. PHP and MySQL have been kinda joined at the hip in the ?NIX world, and it also has evolved from Mickey Mouse to real. The underlying driver in the past has been libmysql. However, libmysql has a license problem, and it also runs outside of the Zend Engine, which means PHP has less control. mysqlnd is where the development has been and where the new features of the language and database are supported. Thus, the default driver for 5.3 and 5.4 is mysqlnd. Until custombuild 2.0 is rolled out, there is a single config file per major release, which is why a standard DA install of 5.3 uses libmysql instead of mysqlnd. Dropping in huge changes between full numbered releases is a new phenomenon. It also seems to have caught on at Apache with their new 2.4. This spawned new requirements that custombuild 2.0 addresses.
The three common libraries to access MySQL data from PHP are mysql, mysqli, and pdo-mysql. New capabilities have only been added to mysqli and pdo-mysql. Thus, you need to use one of these two in order to benefit from the new language features, but they are only supported by the mysqlnd driver.
PHP 5.3 brings together the pieces that developers have longed for, and that is a way to do MYSQLI_ASYNC queries. E.G. your script can be in control while you are waiting for a query. With 5.2 and below, let's say you were to put a 1 second timeout in your PHP code so that if it doesn't complete in 1 second, exit rather than hang the web page. The problem was time stopped when the query started. So if it takes a 1/10th of a second to get to the query, and there is a 1/10th of a second of code that executes afterward, it doesn't matter if the query takes 10 minutes, the script only sees it as 1/5th of a second has elapsed. CURL is not the answer. It is far more resource intensive, and it abandons running queries that are being worked on that nobody wants anymore. With 5.3 and newer, and with an asynchronous query, the script remains alive, and you can cancel the query. With 5.3 you can also do persistent connections WITH mysqli. Those are just the advantages that come to mind. For the code that uses the old mysql library, and there is a lot of it, it doesn't help at all. However keep in mind that the people driving the changes are not the PHP authors, they are the people who write the scripts for Drupal, Wordpress, Installatron, etc. They need the changes to be able to write secure, maintainable code.
Edit: I've been asked by a couple people if it makes sense to switch to the the native driver with 5.2. I had to take some time to think about that since the main reason I wanted this driver was for the async query ability, which is only available in 5.3+. mysqlnd wasn't the default driver for 5.2, probably because it was pretty new back then. For 5.2, the biggest two advantages I can see are it uses a lot less RAM, and supports persistent connections for mysqli. Others are you don't need to link in libmysql, it uses PHP memory management, supports PHP memory limit, keeps every row only once in memory instead of twice, more performance stats, a couple more my.ini tweaks. It's unlikely to do anything one way or the other for performance. You lose the ability to support connections to MySQL servers via named pipes on Win32 systems. You would also need to set up and maintain a custom config for php instead of having DA maintain it. IMHO, for servers without 5.3, there aren't enough benefits to warrant making the change.
That's the HOW TO and the WHY you should care!
The HOW TO is the easy part.
http://help.directadmin.com/item.php?id=252
These are the lines that change:
These are the lines you need to change.
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
WHY you should care:
The WHY is a little more complicated. PHP has been going through a metamorphosis from a simple scripting language to something that has more in common with programming language. PHP and MySQL have been kinda joined at the hip in the ?NIX world, and it also has evolved from Mickey Mouse to real. The underlying driver in the past has been libmysql. However, libmysql has a license problem, and it also runs outside of the Zend Engine, which means PHP has less control. mysqlnd is where the development has been and where the new features of the language and database are supported. Thus, the default driver for 5.3 and 5.4 is mysqlnd. Until custombuild 2.0 is rolled out, there is a single config file per major release, which is why a standard DA install of 5.3 uses libmysql instead of mysqlnd. Dropping in huge changes between full numbered releases is a new phenomenon. It also seems to have caught on at Apache with their new 2.4. This spawned new requirements that custombuild 2.0 addresses.
The three common libraries to access MySQL data from PHP are mysql, mysqli, and pdo-mysql. New capabilities have only been added to mysqli and pdo-mysql. Thus, you need to use one of these two in order to benefit from the new language features, but they are only supported by the mysqlnd driver.
PHP 5.3 brings together the pieces that developers have longed for, and that is a way to do MYSQLI_ASYNC queries. E.G. your script can be in control while you are waiting for a query. With 5.2 and below, let's say you were to put a 1 second timeout in your PHP code so that if it doesn't complete in 1 second, exit rather than hang the web page. The problem was time stopped when the query started. So if it takes a 1/10th of a second to get to the query, and there is a 1/10th of a second of code that executes afterward, it doesn't matter if the query takes 10 minutes, the script only sees it as 1/5th of a second has elapsed. CURL is not the answer. It is far more resource intensive, and it abandons running queries that are being worked on that nobody wants anymore. With 5.3 and newer, and with an asynchronous query, the script remains alive, and you can cancel the query. With 5.3 you can also do persistent connections WITH mysqli. Those are just the advantages that come to mind. For the code that uses the old mysql library, and there is a lot of it, it doesn't help at all. However keep in mind that the people driving the changes are not the PHP authors, they are the people who write the scripts for Drupal, Wordpress, Installatron, etc. They need the changes to be able to write secure, maintainable code.
Edit: I've been asked by a couple people if it makes sense to switch to the the native driver with 5.2. I had to take some time to think about that since the main reason I wanted this driver was for the async query ability, which is only available in 5.3+. mysqlnd wasn't the default driver for 5.2, probably because it was pretty new back then. For 5.2, the biggest two advantages I can see are it uses a lot less RAM, and supports persistent connections for mysqli. Others are you don't need to link in libmysql, it uses PHP memory management, supports PHP memory limit, keeps every row only once in memory instead of twice, more performance stats, a couple more my.ini tweaks. It's unlikely to do anything one way or the other for performance. You lose the ability to support connections to MySQL servers via named pipes on Win32 systems. You would also need to set up and maintain a custom config for php instead of having DA maintain it. IMHO, for servers without 5.3, there aren't enough benefits to warrant making the change.
That's the HOW TO and the WHY you should care!
Last edited: