Thinking of switch to PHP w/Fast CGI?

Posted on

If you're contemplating switching to running PHP5 under FastCGI, to take advantage of apache's threaded worker model and improve your server's performance, think again. If you're used to setting and overriding php values via .htaccess files or using php_value/php_flag in your virtual host directory, this is not supported with FastCGI.  You'll have to figure out how to set those values via some other means. Some PHP ini directives can be set in your script directly, with ini_set, but others have to be set outside of it (register_globals for example). There are ways to set them, but making the switch from prefork to worker is not trivial, especially if you have multiple PHP applications on a single server.

Why we like php-fastcgi and its flexibility

So if you'd like to use php-fcgi but still need some flexibility with your php configuration, (since the php-fcgi scripts are just wrappers) you can create php.ini files for whatever feature-set you need, duplicate the wrapper scripts, defining different PHPRC values for each, then use a .htaccess in each of the subfolders to define which one of the wrappers to use with the following directives.

 

Tags: Apache, PHP

─── ✧ ─── ✦ ─── ✧ ───

Troubleshooting connection problems with memcached

Posted on

I was noticing today many apache segfaults on this server, and pretty high traffic loads at times. I haven't pinpointed the exact cause of high traffic, there are a couple candidates, but the apache segfaults seem to accompanied by the following PHP errors:

[13-Aug-2008 13:55:27] PHP Notice:  MemcachePool::get() [memcachepool.get]: Server 127.0.0.1 (tcp 11211, udp 0) failed with: Network timeout (0) in /var/vhosts/oam/soccerblogs.net/inc/Db/Slopject/Collection.php on line 579
[13-Aug-2008 13:55:29] PHP Notice:  MemcachePool::get() [memcachepool.get]: Server 127.0.0.1 (tcp 11211, udp 0) failed with: Network timeout (0) in /var/vhosts/oam/soccerblogs.net/inc/Db/Slopject/Collection.php on line 579

This may be related to the local firewall and ip_conntrack, which has a known problem with memcached

> This is because kernel try to track all your memcached connections - ie watch > all tcp/ip connection that you made to your memcache. and because conntrack > table have a limited size , and it must hold a connection information for > relative long time, when this table get overloaded, packets are dropped .

The required iptables rule in that email isn't quite right, I had to do the following on the server

iptables -t raw -I OUTPUT  -s ip_addrsss of your memcached box --protocol tcp --sport port of your memcached daemon   -j NOTRACK

Here may end my brief fling with memcached. I'd originally installed it after switching to using prepared SQL statements, which do not use mysql's query cache. I suspect mysql's query cache is better for local caching, as it may allow mysql to handle client requests much faster. As it is now, mysql is taking more time to do its work, which at some point, knocks memcached offline. For local caches, using the caching mechanism available through php accelerators such as eaccelerator may be a better option to running a local memcached

Tags: Linux, PHP

─── ✧ ─── ✦ ─── ✧ ───

Two extremes of blogging

Posted on

I find the time to write about the econmics behind my thrilling ISP/TV swtich and Patty writes a touching post about what it was like to meet Nicholas. Can you guess which one of us was described as emotional as a robot in college? Shouldn't be too hard a task.

Patty, your post deserves a better response, so I owe you one + pictures. But suffice to say that meeting Ian was the highlight of my summer. Even at a couple of months age, Nicholas and Ian have their own special qualities and personalities, so you can't compare them on any meaningful level. But Ian was a lot of fun to play with, he's way more giggly/loud, like his Mom, and it was amazing to have the two of them together contemplating each other and, for me, thinking of what future adventures/trouble they would get into.

Tags: Family

─── ✧ ─── ✦ ─── ✧ ───