When benchmarking regular PHP 5.6 through unix socket the results are many order of magnitues better than tcp port.
通过unix socket对常规PHP 5.6进行基准测试时,结果比tcp端口的结果要好很多。
When I run a command like this:
当我运行这样的命令时:
$ ab -k -n 10000 -c 1000 http://127.0.0.1/api/user/1
I get an avg 3272 reqs per second.
我得到平均每秒3272 reqs。
But with tcp port instead of unix socket I get 6.5 reqs per second.
但是使用tcp端口而不是unix socket我每秒得到6.5 req。
With wrk
随着wrk
$ wrk -t1 -c1000 -d5s http://127.0.0.1:80/api/user/1
on unix socket: 6500 req per second
在unix socket上:每秒6500 req
on tcp port: 300 req per second
在tcp端口:每秒300 req
How am I supposed to use these benchmarks to get a feel of how my server and code can handle load when I get these kinds of results?
当我得到这些结果时,我应该如何使用这些基准来了解我的服务器和代码如何处理负载?
Should I trust the tcp port or unix socket one?
我应该信任tcp端口或unix socket吗?
1 个解决方案
#1
-1
How are you using a Unix socket in your example? The -k
option is http keep alive.
你在例子中如何使用Unix套接字? -k选项是http keep alive。
Unix sockets are used for inter-process communication, so I'm almost certain that the primary access method used to access your webserver is via tcp.
Unix套接字用于进程间通信,因此我几乎可以肯定用于访问Web服务器的主要访问方法是通过tcp进行的。
Really this is testing the efficiency of your code AND webserver. If you care most about the efficiency of your code, you should consider inspecting xdebug output also.
真的,这是测试你的代码和网络服务器的效率。如果您最关心代码的效率,则还应考虑检查xdebug输出。
#1
-1
How are you using a Unix socket in your example? The -k
option is http keep alive.
你在例子中如何使用Unix套接字? -k选项是http keep alive。
Unix sockets are used for inter-process communication, so I'm almost certain that the primary access method used to access your webserver is via tcp.
Unix套接字用于进程间通信,因此我几乎可以肯定用于访问Web服务器的主要访问方法是通过tcp进行的。
Really this is testing the efficiency of your code AND webserver. If you care most about the efficiency of your code, you should consider inspecting xdebug output also.
真的,这是测试你的代码和网络服务器的效率。如果您最关心代码的效率,则还应考虑检查xdebug输出。