Mixing the Apache Worker MPM, php-zts and php-pecl-mongo: is it possible on Linux?

549 views
Skip to first unread message

steph

unread,
May 25, 2011, 5:47:41 AM5/25/11
to mongodb-user
Hi all,

Been hunting around for about a day and haven't found a solution or
even any pointers so any help would be greatly appreciated.

Short version:

How do I compile the mongo driver for threaded operation with php-zts
for use with Apache Worker MPM on Linux. Is it even possible?

Long version:

We're in the process of scaling our PHP application and are now
hitting problems that happen with Apache prefork under high volumes
(e.g. MaxChild limits, memory constraints etc.) so we're looking at
moving to the Worker module.

The PHP core is (supposed to be!) thread safe but we use MongoDB and
simply copying the mongo.so from /usr/lib64/php/modules to /usr/lib64/
modules-zts/ doesn't work:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/
php/modules-zts/mongo.so' - /usr/lib64/php/modules-zts/mongo.so:
undefined symbol: executor_globals in Unknown on line 0


Pulling down the source for the driver and trying to compile it by
hand results in a mongo.so that does the same thing. I've now started
messing around with various thread-related settings (setting PTHREADS
1 in /usr/include/php/main/php_config.h, setting thread_safe=yes in
ltmain.sh and so on) but it's all feeling very hackish and as yet
doesn't work.

Is the module thread safe, and if so how do I build it as such. As I
say, any help would be greatly appreciated.

The environment is CentOS 5.6 but with Remi Collet's repository
enabled for the newest PHP:

rpm -qa | egrep -E "php|mongo"
php-cli-5.3.6-4.el5.remi
php-5.3.6-4.el5.remi
php-mbstring-5.3.6-4.el5.remi
php-pecl-memcache-3.0.6-1.el5.remi
php-pecl-mongo-1.0.10-4.el5.remi
mongodb-server-1.6.4-1.el5
php-pdo-5.3.6-4.el5.remi
php-zts-5.3.6-4.el5.remi
php-gd-5.3.6-4.el5.remi
php-mcrypt-5.3.6-4.el5.remi
php-devel-5.3.6-4.el5.remi
php-pear-1.9.2-3.el5.remi
mongodb-1.6.4-1.el5
php-common-5.3.6-4.el5.remi
php-mysql-5.3.6-4.el5.remi
php-xml-5.3.6-4.el5.remi

k

unread,
May 25, 2011, 5:55:03 PM5/25/11
to mongodb-user
You definitely can build a thread-safe module, you probably have non-
thread-safe PHP libraries lurking somewhere that the module is linking
against. Try:

1. Starting over from a fresh checkout of the source, so you don't
have any lingering non-thread-safe linkage.
2. Run:

$ /path/to/zts/phpize

...instead of just phpize.

3. Then ./configure && make install should compile against/link to to
the correct php.

Probably there's still a non-thread-safe phpize on your system that's
further up your PATH than the thread-safe one is.
Reply all
Reply to author
Forward
0 new messages