Why Workerman Beats Go in Simple HelloWorld Benchmarks on an Aliyun Server
The author benchmarked Go's standard HTTP library against PHP frameworks Workerman, Webman, and Swoole (including coroutine mode) on a 4‑core Ubuntu 20.04 Aliyun instance using ApacheBench with and without keep‑alive, revealing that Workerman and Webman often outperform Go in raw request‑per‑second throughput.
Overview
A short performance test was conducted to compare Go's built‑in HTTP server with several PHP frameworks—Workerman, Webman, Swoole, and Swoole with coroutines—using a simple "hello" endpoint. The goal was to see how a minimal hello‑world service behaves under heavy load and whether the differences observed in a Bilibili video were reproducible.
Test Environment
4‑core (vCPU) 4 GiB Ubuntu 20.04 (64‑bit) instance on Aliyun
PHP 7.4.3
Go version go1.13.8 (linux/amd64)
Benchmark Commands
ApacheBench (ab) was used to generate 100,000 requests with a concurrency of 200. Two variants were run: ab -n100000 -c200 http://127.0.0.1:xxx/ (no keep‑alive) ab -n100000 -c200 -k http://127.0.0.1:xxx/ (keep‑alive enabled)
Results
The measured requests per second (RPS) for each implementation are shown below (first column: without keep‑alive, second column: with keep‑alive):
golang 19995 98546
workerman 30120 125986
webman 29301 85938
swoole 25836 73304
swoole+coroutine27093 54596Key observations:
Workerman achieved higher RPS than Go in both short‑connection and keep‑alive tests.
Webman’s short‑connection performance exceeded Go, while its keep‑alive performance was slightly lower.
Swoole (plain) outperformed Go on short connections but fell behind when keep‑alive was enabled.
Both Workerman and Webman consistently outperformed Swoole regardless of connection mode.
Code Samples
Go (standard library)
package main
import (
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello"))
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}Workerman
require_once __DIR__ . '/vendor/autoload.php';
use Workerman\Worker;
$worker = new Worker('http://0.0.0.0:12345');
$worker->onMessage = function($connection, $request) {
// without -k parameter need to close
$connection->close('hello');
};
Worker::runAll(); require_once __DIR__ . '/vendor/autoload.php';
use Workerman\Worker;
$worker = new Worker('http://0.0.0.0:12345');
$worker->onMessage = function($connection, $request) {
// without -k use send
$connection->send('hello');
};
Worker::runAll();Webman
<?php
namespace app\controller;
use support\Request;
class Index {
public function index(Request $request) {
return 'hello';
}
}Swoole (plain)
<?php
$http = new Swoole\Http\Server('0.0.0.0', 12346, SWOOLE_BASE);
$http->on('Request', function ($request, $response) {
$response->end('hello');
});
$http->start();Swoole with Coroutine
<?php
use Swoole\Coroutine\Http\Server;
use function Swoole\Coroutine\run;
run(function () {
$server = new Server('127.0.0.1', 9502, false);
$server->handle('/', function ($request, $response) {
$response->end("hello");
});
$server->start();
});Conclusion
Even though Go’s HTTP server benefits from native goroutine concurrency, the simple hello‑world benchmark shows that PHP frameworks such as Workerman and Webman can deliver higher raw throughput under the tested conditions, especially when using a single worker process. The author acknowledges that hello‑world benchmarks have limited real‑world relevance but argues they still expose the theoretical performance ceiling of each framework.
Additional references include a LearnKU discussion and the TechEmpower benchmark suite for more extensive comparisons.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
