NET core VS Goang Web

Source: Internet
Author: User

ASP. NET core VS Goang web[correction Article]

Previously wrote an article: Http://www.cnblogs.com/gengzhe/p/5557789.html, is also the ASP. NET core and Golang Web comparison, enthusiastic friends raised a few questions, as follows:

1, need to join sleep to simulate the actual business, so as to test the co-scheduling ability.

2, Golang is good at multi-core environment.

So I fixed it today and tested it again.

Cpu:e1230-v2

Memory: 16GB

Operating system: CentOS 7 (3 core 2GB memory)

Here's the code:

Go

1234567891011121314151617181920212223242526272829 packagemainimport(    "fmt"    "net/http"    "time")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方式传递的参数    time.Sleep(time.Millisecond*300)    req.ParseForm()    fmt.Fprint(w, "Hello Word!")}

C#

1234567891011121314151617181920212223242526272829303132 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 Task.Delay(1*300);        await context.Response.WriteAsync("Hello World!");    }    // ...}publicclassStartup{    publicvoid ConfigureServices(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>();        });    }}

Test results (1000 user concurrency)

Go

C#

The test results are really golang a little bit better.

Personal summary of the gap has 2 points

1, Go is static compilation, running speed should be faster.

2.. NET MVC is better packaged, and requests require a lot of processing before entering the business logic.

These are only personal points of view.

NET core VS Goang 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.