[openstack-dev] [all] Replace mysql-python with mysqlclient

Mike Bayer mbayer at redhat.com
Thu Apr 30 17:48:56 UTC 2015



On 4/30/15 11:00 AM, Victor Stinner wrote:
> Hi,
>
> I propose to replace mysql-python with mysqlclient in OpenStack applications to get Python 3 support, bug fixes and some new features (support MariaDB's libmysqlclient.so, support microsecond in TIME column).

It is not feasible to use MySQLclient in Python 2 because it uses the 
same module name as Python-MySQL, and would wreak havoc with distro 
packaging and many other things.   It is also imprudent to switch 
production openstack applications to a driver that is new and untested 
(even though it is a port), nor is it necessary.   There should be no 
reason Openstack applications are hardcoded to one database driver.    
The approach should be simply that in Python 3, the mysqlclient library 
is installed instead of mysql-python. MySQLclient installs under the 
same name, so in this case there isn't even any change to the SQLAlchemy 
URL required.

>
> The MySQL database is popular, but the Python driver mysql-python doesn't look to be maintained anymore. The latest commit was done in january 2014, before the release of MySQL-python 1.2.5:
>
>     https://github.com/farcepest/MySQLdb1/commits/master
>
> One major issue is that mysql-python doesn't support Python 3. It blocks porting most OpenStack applications to Python 3. There are now 32 open issues and 25 pending pull requests. I also sent an email to Andy Dustman (aka farcepest) last week, but I didn't get any reply yet.
>
>
> There is an open discussion to replace mysql-python with PyMySQL, but PyMySQL has worse performance:
>
>     https://wiki.openstack.org/wiki/PyMySQL_evaluation
PyMySQL is monkeypatchable, so as long as we are using eventlet, it is 
*insane* that we are using MySQL-Python at all, because it is actively 
making openstack applications perform much much more poorly than if we 
just removed eventlet.      So as long as eventlet is running, PyMySQL 
wins the performance argument hands down (as described at the link 
http://www.diamondtin.com/2014/sqlalchemy-gevent-mysql-python-drivers-comparison/ 
which is in the third paragraph of that wiki page).  And it's Py3k 
compatible.

The performance results in that wiki page are also out of date. Naoki 
INADA has merged several performance improvements since then.

My ultimate setup would still use mysql-python Py2K / MySQLclient Py3K, 
and Openstack applications would again use traditional threads for 
database APIs.   But that is two changes.


so to sum up:


1. keep Mysql-python on Py2K, use mysqlclient on py3k, changing the 
implementation of the "MySQLdb" module on Py2K, server-wide, would be 
very disruptive

2. if we actually care about performance, we either A. dump eventlet or 
B. use pymysql.    All other performance arguments are moot right now as 
we are in the basement.





More information about the OpenStack-dev mailing list