Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-15 Thread Amnon Baron Cohen
I would add that engineering is the art of tradeoffs. The language authors decided to route all network scheduling through netpoll, and launch a new goroutine for every incoming http request. These decisions carry a significant overhead. But they mean that users of the language can effortlessly

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-14 Thread 'Axel Wagner' via golang-nuts
So, I *did* invest a little more time, and ISTM that the data you're getting are mostly a result of Go handling requests in parallel and perl not doing that. The statistics on top of the ab-output average over all requests by total time taken. Whereas the data you dumped and plotted contains the ti

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-14 Thread 'Axel Wagner' via golang-nuts
I just want to re-emphasize one specific thing: Neither I, nor anyone else, actually owes you any of their time. I don't know you and I don't feel like it is a good investment of my time to convince strangers on the internet. So yes. You asked me to blog about things. I won't and I also won't spend

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-13 Thread Jan Mercl
On Thu, Jun 13, 2019 at 4:47 PM Tong Sun wrote: If you want or need to discuss personal feelings, please do it off-list. Thank you. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from i

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-13 Thread Tong Sun
Hi Damian & all. I think I need to set the record straight, as most of the technical discussions has been taken place elsewhere, so I feel that I was treated unfairly because of that. If you only see one site of the story, then it is very easy to do that, I get it and understand it however. So fi

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-12 Thread Tong Sun
Yeah, no doubt, I totally agree with that as well. But now, I can proudly say ... My Go beats C :-) On Thu, Jun 13, 2019 at 12:09 AM Justin Israel wrote: > > > > On Thu, Jun 13, 2019 at 4:05 PM Tong Sun wrote: >> >> Yep, thanks Justin, both your points really made the difference, >> because I

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-12 Thread Justin Israel
On Thu, Jun 13, 2019 at 4:05 PM Tong Sun wrote: > Yep, thanks Justin, both your points really made the difference, > because I do believe that the buffered socket write is the key > component for the 3-time improvement that I'm getting (from using > FastHTTP), IMHO. And FastHTTP recommends GOMAXP

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-12 Thread Tong Sun
Yep, thanks Justin, both your points really made the difference, because I do believe that the buffered socket write is the key component for the 3-time improvement that I'm getting (from using FastHTTP), IMHO. And FastHTTP recommends GOMAXPROCS=1 too, which I used this time as well. So thanks aga

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-12 Thread Tong Sun
On Mon, Jun 10, 2019 at 5:27 PM Tong Sun wrote: > > IMO this is just not a meaningful test. Or its results are totally > > unsurprising. > > Again, I was trying to improve Perl performs with Go. That > "ridiculously simple" Perl code is the foundation of the Debian dbab > package, and I was tryin

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-11 Thread Tong Sun
Thanks Amnon for the insight, which confirmed my guessing when answering the following question against ab in my blog: > I'm unclear how to interpret the results from ab. From the top chunk of the > results (time taken for tests, requests per second, time per request, etc.), > it would appear th

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-11 Thread Amnon Baron Cohen
For those interested, you can find some web benchmarks here https://www.techempower.com/benchmarks/ For the trivial http ping type server, you would expect latency to be dominated by system time. strace'ing your code will give you an idea what it is doing. Go allows you to have multiple gorouti

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Tong Sun
Thanks a lot for all your help Marcin! Your expertise makes a total difference here! Double-thumbs up! On Mon, Jun 10, 2019 at 7:46 PM Marcin Romaszewicz wrote: > > In my example in the previous email, I accidentally used a very old version > of echo. If you use the latest ("github.com/labstac

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Tong Sun
On Mon, Jun 10, 2019 at 7:50 PM Axel Wagner wrote: > > > > On Mon, Jun 10, 2019 at 11:28 PM Tong Sun wrote: >> >> There is a second test well before your this post, which is a direct >> translation of Perl code, that is now reading and writing directly to >> a socket. Hanging on to the first test

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread 'Axel Wagner' via golang-nuts
On Mon, Jun 10, 2019 at 11:28 PM Tong Sun wrote: > There is a second test well before your this post, which is a direct > translation of Perl code, that is now reading and writing directly to > a socket. Hanging on to the first test method and not referring to the > second test is not a very cons

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Marcin Romaszewicz
In my example in the previous email, I accidentally used a very old version of echo. If you use the latest ("github.com/labstack/echo/v4"), then it's a lot faster than using simple string splitting, resulting in about 22,000 requests per second. Concurrency Level: 100 Time taken for tests:

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Marcin Romaszewicz
One more followup. Here's an example using an HTTP router named Echo, which I use in production. With proper HTTP parsing and validation, and no regular expressions involved in routing, it still does about 14,000 requests per second. I stubbed some of your stuff which doesn't affect the result. Th

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Marcin Romaszewicz
I think the others were correct in pointing the finger at the RegEx engine in Go. It is quite slow. I hacked your inside loop which checks the request not to use regular expressions, and it's tons faster. You can't say that something can't be responsible for too much slowdown because it "1 line", s

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Tong Sun
Just to clarify some facts. On Sun, Jun 9, 2019 at 11:09 AM 'Axel Wagner' wrote: > > As I've also mentioned: I don't think this test is meaningful. > > First, as it has been pointed out, your Perl program isn't actually a web > server. It only understands ridiculously simple requests and as such

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-09 Thread 'Axel Wagner' via golang-nuts
As I've also mentioned: I don't think this test is meaningful. First, as it has been pointed out, your Perl program isn't actually a web server. It only understands ridiculously simple requests and as such violates the spec left and right. It's also super naive in how it treats malformed input or

[go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-08 Thread Justin Israel
I'm wondering about a couple factors in this comparison that seem to make a difference in my local test: 1. I think perl sockets are write buffered. So would the equivalent be to wrap the net.Conn in bufio.NewWriter(c) and flush before the Close? 2. Since this is a straigh-line test whe

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-08 Thread Tong Sun
On Sat, Jun 8, 2019 at 3:01 PM Wojciech S. Czarnecki wrote: > > On Sat, 8 Jun 2019 09:56:05 -0400 > Tong Sun wrote: > > > Agree that it was not an apples to apples comparison. So please check > > out my 2nd blog: > > > > https://dev.to/suntong/simple-web-server-in-perl-and-go-revisit-5d82 > > > >

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-08 Thread Wojciech S. Czarnecki
On Sat, 8 Jun 2019 09:56:05 -0400 Tong Sun wrote: > Agree that it was not an apples to apples comparison. So please check > out my 2nd blog: > > https://dev.to/suntong/simple-web-server-in-perl-and-go-revisit-5d82 > Trying to make sense of your measures... ...Still apples to oranges due to te

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-08 Thread Steven Hartland
Couple of things that you might want to investigate: 1. Is SetReadDeadline the same as SO_RCVTIMEO (vm vs socket)? 2. Is c.Close()  the same as shutdown (flushes vs doesn't)? 3. Is print is the same as fmt.Fprintf / c.Write (buffered vs unbuffered)? With the go I'd be tempted to put everything fr

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-08 Thread Tong Sun
Agree that it was not an apples to apples comparison. So please check out my 2nd blog: https://dev.to/suntong/simple-web-server-in-perl-and-go-revisit-5d82 > thanks to Axel Wagner, who replaced the net/http.Server layer with direct > translation of Perl code, the code is now reading and writing

[go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-07 Thread Ivan Bertona
Looking a the two code samples I wouldn't say this is an apples to apples comparison... The Perl script seems to be a simple single-threaded loop that understands a tiny subset of HTTP vs. a fully-fledged (and secure) web server from the Go standard library. I would definitely not run that Perl

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-07 Thread Anger
Yeah, you probably want to avoid fasthttp. Chi https://github.com/go-chi/chi and Gin https://github.com/gin-gonic/gin Are both better than the base httpserver and I've using them in large scale adtech deployments without issue. Also you can get BETTER performance out of the base http client (over

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-07 Thread Burak Serdar
On Fri, Jun 7, 2019 at 9:01 AM Ronny Bangsund wrote: > > Yes, the built-in is pretty awful in many ways. There are fortunately lots of > alternatives, all with roughly an order of magnitude better performance. I > inspected this list yesterday to finally make a choice of packages to use: > http

[go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-07 Thread Ronny Bangsund
Yes, the built-in is pretty awful in many ways. There are fortunately lots of alternatives, all with roughly an order of magnitude better performance. I inspected this list yesterday to finally make a choice of packages to use: https://github.com/smallnest/go-web-framework-benchmark I ended up