Ngx_lua and go high concurrency performance comparison

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.