Too many pipes open in php-fpm

Configuring php-fpm I had a problem – even when configured in php-fpm.conf

<value name="max_children">150</value>

I got only about 120 childrens.  I found that the problem was krenel maximum open files limit. You can check it with

ulimit -a
core file size (blocks)     unlimited
data seg size (kbytes)      unlimited
file size (blocks)          unlimited
open files                  256
pipe size (512 bytes)       10
stack size (kbytes)         8192
cpu time (seconds)          unlimited
max user processes          29995
virtual memory (kbytes)     unlimited

These values can be globally changed in

/etc/system

. In this case reboot is needed, but for me it was easier  to add

ulimit -n 1024 

at the top

sbin/php-fpm

startup script.

php-fpm on Solaris 9 Sparc

If  any one was trying to use php-fpm knows that on Sparc platform have seen: “unsupported processor. please write a patch and send it to me”.

Php-fpm is a great project, so I decided to write my own patch for php 5.2.10 – you can download it here.

Mainly I’ve added necessary assembler code in /sapi/cgi/fpm/fpm_atomic.h for Sparc platform.  Patch also solves issues which I found on my Solaris 9 :

-broken switching between systems with inttypes.h or  stdint.h – I added #if HAVE_INTTYPES_H directives in few places

-if system doesn’t have unsetenv() function it won’t compile – I added #ifndef HAVE_UNSETENV and my implementation of this function in /sapi/cgi/fpm/fpm_env.c if wasn’t in system

-in /sapi/cgi/fpm/fpm_env.c setenv() function wasn’t working properly – on my solaris 9 was adding some stupid data do ENV, I don’t know if it was ok or not on other systems. I’ve rewritten it in other way.

– when /libevent/libevent.a was compiling no proper /libevent/event-config.h was generated. It was a problem when for example system doesn’t have stdint.h – I  added this file in
/libevent/Makefile.in like this “libevent.a: event-config.h $(libevent_a_OBJECTS) $(libevent_a_DEPENDENCIES)”  and changed order in /sapi/cgi/Makefile.frag to: “$(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS) $(SAPI_EXTRA_DEPS) $(PHP_SAPI_OBJS)

Now as I tested everything compiles and work on Solaris 9 Sparc even in 64bit mode. I’m using it on site with about 250 000 shows per day and for now have no problems. It should be universal for all platforms now! 🙂