NET Core and Golang Web

Source: Internet
Author: User

ASP. NET Core vs. Golang Web simple contrast test

Recently, because the job needs to touch the go language, and just like ASP. NET core release RC2, want to do a simple contrast test.

Here is the test environment:

CPU:E3-1230 v2

Memory: 16G

The computer is a bit of a force

Operating system: Centos7.0 (Virtual machine single core 2G memory)

ASP. NET Core RC2

Golang v1.7beta1

Here are the respective codes:

Go

123456789101112131415161718192021222324252627 packagemainimport(    "fmt"    "net/http")funcmain() {    fmt.Println("This is webserver base!")    //第一个参数为客户端发起http请求时的接口名,第二个参数是一个func,负责处理这个请求。    http.HandleFunc("/login", loginTask)    //服务器要监听的主机地址和端口号    err := http.ListenAndServe("192.168.199.236:8081", nil)    iferr != nil {        fmt.Println("ListenAndServe error: ", err.Error())    }}funcloginTask(w http.ResponseWriter, req *http.Request) {    //获取客户端通过GET/POST方式传递的参数    req.ParseForm()    fmt.Fprint(w, "Hello World!")}

C#

12345678910111213141516171819202122232425262728293031 publicclassMyHandlerMiddleware{    // Must have constructor with this signature, otherwise exception at run time    publicMyHandlerMiddleware(RequestDelegate next)    {        // This is an HTTP Handler, so no need to store next    }    publicasync Task Invoke(HttpContext context)    {        await context.Response.WriteAsync("Hello World!");    }    // ...}publicclassStartup{    publicvoidConfigureServices(IServiceCollection services)    {    }    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.    publicvoidConfigure(IApplicationBuilder app)    {        app.MapWhen(context => { returncontext.Request.Path.ToString().EndsWith("jjj.go"); }, ap =>        {            ap.UseMiddleware<MyHandlerMiddleware>();        });    }}

are simple routes and simple return strings

Here are the test results

Go

ASP. NET Core

From the test results, ASP. NET core is better, including response time and number of concurrency. Supposedly go should be faster than. NET Core. I hope you will do more contrast test to refute me, I test n times is the result

However, in a Windows environment, Golang can be around 6000 concurrent, while. NET core is still more than 4,600, but the response speed. NET core is still faster than Golang, which I am a little puzzled. It's supposed to be. NET The world is right, haha

Recently, we have tested ASP. NET core, and found that it is really very, welcome to try

Fix test: http://www.cnblogs.com/gengzhe/p/5561718.html

NET Core and Golang Web

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.