Go performance test: No optimizations were made

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

The Srs.go TCP module for go and the Web server Martini did a preliminary performance test without any optimizations.

TCP section

TCP section Reference: HTTPS://GITHUB.COM/WINLINVIP/SRS.GO/TREE/MASTER/RESEARCH/TCP

Go as a server

Go as server go build./tcp.server.go &&./tcp.server 1 1990 4096 >/dev/nullg++ tcp.client.cpp-g-o0-o Tcp.client & amp;&./tcp.client 1990 4096 >/dev/null----total-cpu-usage-----dsk/total----net/lo-----paging----- SYSTEM--USR Sys IDL Wai HiQ siq| Read writ|  Recv send| In-out |   int CSW 7 17 51 0 0 25| 0 0 |   680M 680m|   0 0 |2207 48k 7 15 52 0 0 26| 0 0 |   680M 680m|  0 0 |2228 48k PID user pr NI VIRT RES SHR S%cpu%MEM time+ COMMAND PID User pr                                                                                                        NI VIRT RES SHR S%cpu%MEM time+ COMMAND                                                                                         5415 Winlin 0 169m 2220 1404 R 100.4 0.1 0:27.56./tcp.server 1990 4096 5424 Winlin 0 11648 764 R 8 5.1 0.0 0:23.47./tcp.client 1990 4096

C + + as a server

C + + as server g++ tcp.server.cpp-g-o0-o tcp.server &&/tcp.server 1990 4096 >/dev/null g++ tcp.client.cpp-g-O0 -O tcp.client &&/tcp.client 1990 4096 >/dev/null----total-cpu-usage-----dsk/total----net/lo----- Paging-----system--usr sys IDL Wai HiQ siq| Read writ|  Recv send| In-out |   int CSW 6 25 44 0 0 24|   0 224k|2142m 2142m|   0 0 |2439 15k 5 23 48 0 0 23|   0 0 |2028m 2028m|                                                                                                        0 0 |2803 10k PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND   9758 Winlin 0 11648 764 R 98.3 0.0                                                                                          0:11.36./tcp.client 1990 4096 9751 Winlin 0 11648 884 752 R 71.4 0.0 0:07.85./tcp.server 1990 4096

Python as a server

Python as a server Python tcp.server.py 1990 4096 >/dev/nullg++ tcp.client.cpp-g-o0-o tcp.client &&./tcp.client 199 0 4096 >/dev/null----total-cpu-usage-----dsk/total----net/lo-----paging-----system--usr sys IDL Wai HiQ siq| Read  writ| recv  send|  In Out   | int   CSW   3   0  26|   0   156k|1526m 1526m|   0     0 |2215    28k   0   0  25|   0     0 |1482m 1482m|   0     0 |2189    26k  PID USER      PR  NI  VIRT  RES  SHR S%cpu%MEM    time+  COMMAND                                                                                                        5140 Winlin   0  157m 5932 2824 R 100.0  0.3   2:36.01 Python tcp.server.py 1990 4096                                                                                 5331 Winlin   0 11648  764 R 87.3 0.0 1:02.47   ./tcp.client 1990 4096        

When the go direct TCP packet is sent, the performance is worse than the C + + direct packet. Python directly sends TCP packets with good performance.

Web Part

Web section Reference: Https://github.com/winlinvip/srs.go/tree/master/research/web

1 Concurrent Tests

Tested with AB, 1 concurrent requests: Ab-n 100000-c 1 http://127.0.0.1:8080/api/v3/jsonopenresty:   8851.97rps, 84%,  3mb,ab66% CherryPy:     653.12rps,   98%,17mb,ab7%go-martini:  4574.10rps,  88%,  4mb,ab35%

10 Concurrent Tests

Ab-n 100000-c Http://127.0.0.1:8080/api/v3/jsonopenresty:16550.72rpscherrypy:531.28rpsgo-martini:15737.50rps

50 Concurrent Tests

50 Concurrency to open multiple AB tests, otherwise the client becomes a bottleneck: for ((i=0;i<5;i++)); Do (ab-n 100000-c http://127.0.0.1:8080/api/v3/json >req100-$i. Go.txt &); Doneopenresty:18514rpsgo-martini:30954rps

100 Concurrent Tests

Up to 5 processes, each concurrent 20 requests: <pre name= "code" class= "Plain" >for ((i=0;i<5;i++)); Do (ab-n 100000-c http://127.0.0.1:8080/api/v3/json >req100-$i. Go.txt &); Done
Openresty:29063rpsgo:43288rps

In high traffic, go behaves much better than Python and is better than openresty.

Go is less efficient than C + +, and it may be better to deploy and multi-CPU, and the server code is not as hard to write.

Go is now looking to achieve the goal of efficient python. It should be considered in the backend, especially some APIs.

Dependency Packages

Openresty's dependencies are a whole bunch of packages that are not easy to deploy:

[Winlin@dev6 web]$ ldd objs/_release/nginx/sbin/nginxlinux-vdso.so.1 = (0x00007fff6efcf000) libpthread.so.0 = /lib64/libpthread.so.0 (0x0000003218400000) libcrypt.so.1 =/lib64/libcrypt.so.1 (0x0000003221c00000) libm.so.6 = >/lib64/libm.so.6 (0x0000003217c00000) libpcre.so.0 =/lib64/libpcre.so.0 (0x000000314ca00000) libssl.so.10 = >/usr/lib64/libssl.so.10 (0x0000003ef7600000) libcrypto.so.10 =/usr/lib64/libcrypto.so.10 ( 0x0000003ef7200000) libdl.so.2 =/lib64/libdl.so.2 (0x0000003218000000) libz.so.1 =/lib64/libz.so.1 ( 0x00000032ed000000) libgcc_s.so.1 =/lib64/libgcc_s.so.1 (0x000000328f200000) libc.so.6 =/lib64/libc.so.6 ( 0x0000003217800000)/lib64/ld-linux-x86-64.so.2 (0x0000003217000000) libfreebl3.so =/lib64/libfreebl3.so ( 0x0000003221800000) libgssapi_krb5.so.2 =/lib64/libgssapi_krb5.so.2 (0x0000003223c00000) libkrb5.so.3 =/ Lib64/libkrb5.so.3 (0x0000003224c00000) libcom_err.so.2 =/lib64/libcom_err.so.2 (0x0000003222000000) libk5cRypto.so.3 =/lib64/libk5crypto.so.3 (0x0000003222800000) libkrb5support.so.0 =/lib64/libkrb5support.so.0 ( 0x0000003224800000) libkeyutils.so.1 =/lib64/libkeyutils.so.1 (0x0000003222c00000) libresolv.so.2 =/lib64/ Libresolv.so.2 (0x0000003219400000) libselinux.so.1 =/lib64/libselinux.so.1 (0x0000003219000000)

Gomartini does not have an extra dependency package, and Python is packaged like this:

[Winlin@dev6 web]$ ldd Objs/go.martini linux-vdso.so.1 =  (0x00007fffd25ff000) libpthread.so.0 =/lib64/ libpthread.so.0 (0x0000003218400000) libc.so.6 =/lib64/libc.so.6 (0x0000003217800000)/lib64/ Ld-linux-x86-64.so.2 (0x0000003217000000)

Compare the size of the package:

[Winlin@dev6 web]$ ls-lh objs/go.martini-rwxrwxr-x 1 winlin winlin 6.4M Nov  3 14:35 objs/go.martini[winlin@dev6 web] $ ls-lh objs/_release/nginx/sbin/nginx-rwxrwxr-x 1 winlin winlin 14M Nov  3 12:05 Objs/_release/nginx/sbin/nginx

Go is doing well in this area.
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.