Code of swoole
<?php
$http = new swoole_http_server("127.0.0.1", 9501);
$http->on("start", function ($server) {
echo "Swoole http server is started at http://127.0.0.1:9501\n";
});
$http->on("request", function ($request, $response) {
$response->header("Content-Type", "text/plain");
$response->end("Hello World\n");
});
$http->start();
Code of golang
package main
import (
"io"
"net/http"
)
func main() {
http.HandleFunc("/", handle)
http.ListenAndServe("0.0.0.0:10056", nil)
}
func handle(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "text/html")
io.WriteString(rw, "<h3>http server</h3>")
}
are all tested on my machine
ab-n 30000-c 100 "http://127.0.0.1:10056/"
swoole results
Server Software: swoole-http-server
Server Hostname: 127.0.0.1
Server Port: 9501
Document Path: /
Document Length: 12 bytes
Concurrency Level: 100
Time taken for tests: 1.910 seconds
Complete requests: 30000
Failed requests: 0
Total transferred: 4830000 bytes
HTML transferred: 360000 bytes
Requests per second: 15708.78 [-sharp/sec] (mean)
Time per request: 6.366 [ms] (mean)
Time per request: 0.064 [ms] (mean, across all concurrent requests)
Transfer rate: 2469.84 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 0.5 3 8
Processing: 1 4 0.9 3 18
Waiting: 0 3 0.9 2 16
Total: 2 6 0.9 6 21
WARNING: The median and mean for the processing time are not within a normal deviation
These results are probably not that reliable.
WARNING: The median and mean for the waiting time are not within a normal deviation
These results are probably not that reliable.
Percentage of the requests served within a certain time (ms)
50% 6
66% 6
75% 7
80% 7
90% 7
95% 7
98% 8
99% 9
100% 21 (longest request)
golang results
Server Software:
Server Hostname: 127.0.0.1
Server Port: 10056
Document Path: /
Document Length: 20 bytes
Concurrency Level: 100
Time taken for tests: 4.364 seconds
Complete requests: 30000
Failed requests: 0
Total transferred: 3630000 bytes
HTML transferred: 600000 bytes
Requests per second: 6873.89 [-sharp/sec] (mean)
Time per request: 14.548 [ms] (mean)
Time per request: 0.145 [ms] (mean, across all concurrent requests)
Transfer rate: 812.25 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 6 4.6 5 54
Processing: 0 9 5.8 7 63
Waiting: 0 7 4.4 6 50
Total: 0 14 8.7 12 101
Percentage of the requests served within a certain time (ms)
50% 12
66% 14
75% 15
80% 16
90% 20
95% 28
98% 47
99% 59
100% 101 (longest request)