ASP. NET core VS Goang web[correction Article]

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

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

Package Mainimport ("FMT" "Net/http" "Time") Func main () {FMT. Println ("This is webserver base!") The first parameter is the interface name when the client initiates an HTTP request, and the second parameter is a func that is responsible for processing the request. http. Handlefunc ("/login", Logintask)//server to listen on the host address and port number err: = http. Listenandserve ("192.168.199.236:8081", nil) if err! = Nil {fmt. PRINTLN ("Listenandserve error:", err.) Error ())}}func Logintask (w http. Responsewriter, req *http. Request) {//Gets the parameter Time.sleep (time.millisecond*300) req that the client passed by Get/post. Parseform () fmt. Fprint (W, "Hello word!")}

C#

 public class Myhandlermiddleware {//must has constructor with this  Signature, otherwise exception at run time public myhandlermiddleware (requestdelegate next) {//            This is a HTTP Handler, so no need to store next} public async Task Invoke (HttpContext context) {            Await Task.delay (1*300); Await the context.        Response.writeasync ("Hello world!");    }        // ...    } public class Startup {public void configureservices (Iservicecollection services) {}//Th Is method gets called by the runtime.        Use this method to configure the HTTP request pipeline. public void Configure (Iapplicationbuilder app) {app. Mapwhen (context = {return context. 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.

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.