This is a creation in Article, where the information may have evolved or changed.
Nginx is very good at dealing with high concurrency, and go is a new era of Internet language designed to achieve high concurrency at the beginning of the design. The Ngx_lua is handled by Nginx to handle network events and uses a co-process to implement non-blocking for high concurrency. The Go language level provides a non-blocking API, which also uses a thread to provide high concurrency processing.
Let's test and compare the performance of both.
ngx_lua:tengine/1.4.3+luajit+ngx_luago:go1.0.3
The output of 512 bytes of content is achieved, compared to the QPS under different concurrency.
Test machine:
16core Intel (R) Xeon (r) CPU E5520 @ 2.27GHz Linux localhost 2.6.18-164.el5 #1 SMP Tue 15:51:48 EDT x86 _64 x86_64 x86_64 Gnu/linux
Using AB for testing, the test results are as follows:
From the results, it can be seen that when the short connection, the two QPS difference is not big, and long connection, the difference between the two. Go CPU usage is much higher than Ngx_lua. In addition, go continues to perform well in the case of increased concurrency.
Related test code.
Lua Code:
Ngx.print ("AAAAA ... 512...aaa ")
Go code:
Package Mainimport ( "net/http" "Log" " fmt" "Runtime") Func handler512 (w http. Responsewriter, R *http. Request) { w.header (). Set ("Connection", "keep-alive") A: = []byte ("AAAAA ... 512...aaa ") W.header (). Set ("Content-length", FMT. Sprintf ("%d", Len (A))) W.write (a)}func main () { runtime. Gomaxprocs (runtime. NUMCPU ()) http. Handlefunc ("/512b", handler512) log. Fatal (http. Listenandserve (": 8080", nil))}
Link:http://os.51cto.com/art/201307/403474.htm