The Golang comes with a net/http package that creates a process to handle the request, so the blocked 2 second does not suspend the main process, and the main process still receives the request and creates a coprocessor to process the request.
The ability of the swoole to start the built-in coprocessor (Coroutine) in 2.0 provides the ability to have a co-capable IO interface (unified in the namespace swoolecoroutine*).
The Swoole Server will be transparent to the same golang as net/http, but we need to use some pre-provided methods or clients in Swoole to trigger the co-operation to perform the high performance of the process.
Swoole Client: https://wiki.swoole.com/wiki/...
3, AB pressure measurement
Server configuration slightly slag, vsphere on a small self-service server 1 core 2G, do not care
Pressure measurement 200 Concurrent 5000 requests
ab -c 200 -n 5000 -k http://127.0.0.1:8081ab -c 200 -n 5000 -k http://127.0.0.1:8082
Go
Swoole
Pressure measurement 500 Concurrent 5000 requests
ab -c 500 -n 5000 -k http://127.0.0.1:8081ab -c 500 -n 5000 -k http://127.0.0.1:8082
Go
Swoole
Pressure measurement 1000 Concurrent 5000 requests
ab -c 1000 -n 5000 -k http://127.0.0.1:8081ab -c 1000 -n 5000 -k http://127.0.0.1:8082
Go
Swoole
Pressure Measurement 2000 Concurrent 5000 requests
ab -c 2000 -n 5000 -k http://127.0.0.1:8081ab -c 2000 -n 5000 -k http://127.0.0.1:8082
Go
Swoole
Can be seen from the above groups of data, Golang::goroutine and Swoole::coroutine two of the performance of the basic no gap, and the co-process in high concurrency can be more intuitive to reflect the excellent performance.
The same 5000 of requests, 200-500-1000-2000 processing time is getting smaller, it means that I do not eat, it is your hair too slow. When 2000 is concurrent, my 1-core 2G server can run to 600-concurrency in a 2-second blocking scenario.
But Swoole still to occupy more memory, I test machine memory is smaller, no way to use swoole perfect run c10k, memory is not enough, no way to create more concurrent processing request, but go can also, back in the next look at the Go::goroutine is not occupied memory smaller bar, Run a look first.
Go 10k Concurrent 200k Requests
Go 20k concurrent 1000k requests
AB Maximum concurrent analog is 20k, for reference only