Benchmarking PHP over unix socket vs tcp with ab and wrk

When testing regular PHP 5.6 over unix socket, the results are many orders of magnitude greater than the tcp port.

When I run the command like this:

$ ab -k -n 10000 -c 1000 http://127.0.0.1/api/user/1

      

I am getting avg 3272 reqs per second.

But with tcp port instead of unix socket, I get 6.5 reqs per second.

With wrk

$ wrk -t1 -c1000 -d5s http://127.0.0.1:80/api/user/1

      

on a Unix socket: 6500 bps

on tcp port: 300 rivers per second

How should I use these tests to understand how my server and code can handle the load when I get results like this?

Should I trust the tcp port or unix one?

+3


source to share


1 answer


How are you using the Unix socket in your example? The parameter -k

is http keep alive.

Unix sockets are used for inter-process communication, so I'm pretty sure the primary access method used to access your web server is through tcp.



Indeed, it tests the efficiency of your code and web server. If you are most interested in the efficiency of your code, you should also consider checking the output of xdebug.

-1


source







All Articles