Is fastcgi_pass in nginx set to monitor unix socket more efficient than monitoring tcp socket?
漂亮男人
漂亮男人 2017-05-16 17:26:00
0
2
755

I saw that fastcgi_pass in other people’s nginx configuration is unix:/tmp/php-cgi.sock

But my configuration is 127.0.0.1:9000 (not talking about load balancing, just the simplest oneserver)

What is the difference between

unix:/tmp/php-cgi.sock and 127.0.0.1:9000?

Is the former processing faster?

I see in my php-fpm.conf

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

Should you change the configuration of listen to /tmp/php-cgi.sock?

漂亮男人
漂亮男人

reply all(2)
刘奇

Well, unix socket will be faster and does not use the network
In addition, it is better to put it in the /tmp directory than to put it in the memory
I usually put it in /dev/shm/php-fpm.sock
Put it in the memory and read it faster

PHPzhong

Theoretically, unix socket will be faster if it does not go through the network,
However, the stability is not so ideal,
Someone has done the test here, you can refer to it
http://blog.csdn.net/liv2005/article/details/7741732

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template