-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http performance test result is bad #8246
Comments
Can you post your php script and the configuration of the web server? Did you also benchmark single-process mode, i.e., without cluster? |
If without cluster, in single-process mode.ab test command is: ab -c 50 -n 10000.The benchmark result is bellow.
php version: 5.6.24 <?php
$server = new \Swoole\Http\Server('0.0.0.0', '8001');
$server->set(array(
'worker_num' => 1,
'daemonize' => 1,
'dispatch_mode' => 3,
'open_tcp_nodelay' => 1,
));
$server->on('Request', function(\Swoole\Http\Request $request, \Swoole\Http\Response $response){
$response->header('Last-Modified', 'Thu, 18 Jun 2015 10:24:27 GMT');
$response->header('E-Tag', '55829c5b-17');
$response->header('Accept-Ranges', 'bytes');
$response->status(200);
$response->end("hello world\n");
});
$server->start(); nodejs code:
If with keepalive options, the result is even worse. ab test command: ab -c 50 -n 10000 -k. The result is bellow:
|
One thing you're doing in your php code that you aren't doing in the node.js script, is enabling TCP nodelay. Another is setting a static Date header whereas the node.js script has to generate one for you (something that is more expensive than you might think it is.) You should investigate whether both servers are doing roughly the same unit of work per request. If swoole is taking shortcuts left and right, it's going to be faster but not necessarily more correct. Meaningful comparative benchmarks are a pretty broad subject. For example, how frequently does the garbage collector run in your php script vs. node.js? How many system calls do they make in total / per request? What is peak and average memory consumption like? And so on. |
I agree with your point of view. |
That's platform-specific right now. Linux generally defaults to enabled TCP_NODELAY, while other platforms generally do not. There's #906 about enabling it everywhere.
You'd do something like this: server.on('connection', function(socket) {
socket.setNoDelay(true);
}); Let is know if it helps your performance. It might help our decision on enabling it. |
I think if you want to set http nodelay, code should like this
whether set false or not, the performance is same.So I think the key point of my problem is that set "Content-Length" on http header or not. |
I make ab test between nodejs and php, but result is confuse me.The os is 16 core cpu, so I start 16 process with nodejs and php. The ab command is: ab -c 1000 -n 100000. The result is below:
nodejs code is bellow:
If I dont set cluster.schedulingPolicy = cluster.SCHED_NONE , the performance is even worse.
Is there some thing wrong with my code?Or this is normal.
The text was updated successfully, but these errors were encountered: