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 from the successful accept
to the socket close in a goroutine.
Regards
Steve
On 08/06/2019 14:56, 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
thanks to Axel Wagner, who replaced the net/http.Server layer with direct
translation of Perl code, the code is now reading and writing directly to a
socket, just as what the Perl code is doing.
@Budi, links to my Go code are available in both of my posts.
On Fri, Jun 7, 2019 at 8:08 PM Ivan Bertona wrote:
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 script in
production, even if it was for a simple project. My bet is that if you actually
port the Perl script to a Go program that does more or less the same thing
you'll see more or less the same performance (because the example is
fundamentally I/O-bound).
Best,
Ivan
On Friday, June 7, 2019 at 9:36:49 AM UTC-4, Tong Sun wrote:
I had always believed that the web projects build with Go should be much faster
than Perl, since Go is a compiled language.
However that belief was crushed brutally last night, when I did a comparison --
the Go implementation is 8 times worse than the Perl! -- the mean response time
jumped from 6ms to 48ms.
I know this is the simplest possible web server, but still, when it comes to
simple web servers like this, I have to say that Perl performs much better than
Go.
I don't think there is much I can twist on the Go side, since it can't be more
simpler than that. However, I also believe it won't hurt to ask and confirm. So,
Have I missed anything? Is it possible for me to make my Go implementation
anywhere near the Perl's performance?
Thanks
--
You received this message because you are subscribed to a topic in the Google Groups
"golang-nuts" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/golang-nuts/iH2Ck_hpCpI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/12e7666a-385f-47ef-b061-9738802e7a88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/933ab3e8-5a79-0542-2f9d-bd82a54d8514%40multiplay.co.uk.
For more options, visit https://groups.google.com/d/optout.