Welcome! Log In Create A New Profile

Advanced

php-fpm unix-socket contention

Posted by sumitg 
php-fpm unix-socket contention
July 28, 2009 07:10PM
I recently tried listening on unix sockets instead of IP sockets for a slow application I had, and saw that the performance (tested using ab) using unix sockets was far greater. However, on heavy loads, I started getting this in the nginx error logs:

[code]
...connect() to unix:/dev/shm/php-fpm.1.socket failed (11: Resource temporarily unavailable) while connecting to upstream...
[/code]

I made multiple pools in php-fpm.conf, but still get the errors. Many (but not all) requests fail during loads, some requests result in partial data transfers. It seems that there is some sort of contention that's happening over the unix-sockets, which wasn't there in IP-sockets. Can someone with a working unix-sockets based setup help me out here, as the performance gain is quite impressive?

Thanks,

Sumit.
Re: php-fpm unix-socket contention
July 28, 2009 07:47PM
Weird, last I heard there was no real difference between unix sockets
and TCP/IP. Maybe I should be looking into that too?!

What OS and version, distro, etc? What version of PHP?

On Tue, Jul 28, 2009 at 4:10 PM, sumitg<nginx-forum@nginx.us> wrote:
>
> I recently tried listening on unix sockets instead of IP sockets for a slow application I had, and saw that the performance (tested using ab) using unix sockets was far greater. However, on heavy loads, I started getting this in the nginx error logs:
>
>
> ...connect() to unix:/dev/shm/php-fpm.1.socket failed (11: Resource temporarily unavailable) while connecting to upstream...
>
>
> I made multiple pools in php-fpm.conf, but still get the errors. Many (but not all) requests fail during loads, some requests result in partial data transfers. It seems that there is some sort of contention that's happening over the unix-sockets, which wasn't there in IP-sockets. Can someone with a working unix-sockets based setup help me out here, as the performance gain is quite impressive?
>
> Thanks,
>
> Sumit.
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?3,4542,4542#msg-4542
>
>
Re: php-fpm unix-socket contention
July 29, 2009 01:13AM
Using RHEL5, PHP 5.2.10, php-fpm, nginx 0.7.61

The difference in speed is massive. Also, while using IP Sockets, I was running out of sockets in my loadtests, as two sockets were used per connection, and a lot of them ended up in TIME_WAIT.

The only issue is the lack of reliability - many of my requests during loads fail. I tested some more, and I was able to handle 512 concurrents in various configurations, but if I bump it up to even 550, almost 50% of requests fail. The CPU is not the bottleneck - it's a dual quad-core xeon, 12MB cache. 8GB of RAM on the machie. During tests, there's only about 30% CPU utilization (apache+mod_php loads up all the cores fully, ngix just hums along)

The difference is speed probably comes from the fact that Unix sockets will not have the TCP overhead of IP sockets (which even the loopback interface has). The system does not have to follow framing and packet guidelines of TCP, and processes can effectively negotiate data exchange directly with each other.

Sumit.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 318
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready