Live data from Hacker News

Go as an alternative to Node.js for Very Fast Servers

techblog.safaribooksonline.com

11–20 of 147 posts

Re: Go as an alternative to Node.js for Very Fast Servers

#12
I have never understood the focus on speed as a selling point for Node. It may well be very fast, but it seems to me that the primary selling points would be the ability to share code between client and server and that you can start coding server side without learning a new language if all you know is JavaScript.

Re: Go as an alternative to Node.js for Very Fast Servers

#13
post #9

I played around with a go server to do some simple scaling numbers - looking at possibly using go to implement a large-number-of-idle-connections notification server. I found the (good) result that I could spawn a new goroutine for each incoming connection with minimal (~4k) overhead. This is pretty much what you'd expect since a goro just needs a page for it's stack if it's doing no real work. I had something like 4…

> I think this is due to the go runtime allocating an OS thread for each goro as it goes through the socket close() blocking call. I think it has to do this to maintain concurrency

I highly doubt that it is creating a thread per goro on client disconnect. If you have a minimalish example of this, the golang mailing list would be very interested in working with you to identify what went wrong and create a patch if it is an issue with the Go implementation.

Re: Go as an alternative to Node.js for Very Fast Servers

#14
post #9

I played around with a go server to do some simple scaling numbers - looking at possibly using go to implement a large-number-of-idle-connections notification server. I found the (good) result that I could spawn a new goroutine for each incoming connection with minimal (~4k) overhead. This is pretty much what you'd expect since a goro just needs a page for it's stack if it's doing no real work. I had something like 4…

It seems so.

https://code.google.com/p/go/issues/detail?id=4056

An interesting point raised there is that if they instead used a limited thread pool for all goroutines to share when making OS calls you could produce deadlocks.

Re: Go as an alternative to Node.js for Very Fast Servers

#15

Node: Everyone knows JavaScript, there's a massive community, there are tons of libraries, and you get very good performance Go: No one knows this language, there's a small-but-growing community, there are enough libraries to get a lot done, and you get even better performance Java: They are paying me (money!) to write in this language

The mainstream always lags behind significantly in every aspect of life. If everyone's using it, then you have little competitive advantage using the technology.

Go would be one of the first things I'd reach for if there's any chance server-side concurrency would be involved. The language is minimalistic and unsurprising to the extreme. A joy to program in and use.

Re: Go as an alternative to Node.js for Very Fast Servers

#16
post #11

I run node/express for most of my web servers and each takes up about 10-15mb RAM. They're very basic no fluff. Anyone know what comparable mem footprint in Go?

Here's a quick paste from a server of mine:

    ps aux | grep api
    ubuntu   15720  0.0  0.1 107024  6136 pts/0    Sl   15:13   0:00 bin/api_server

Re: Go as an alternative to Node.js for Very Fast Servers

#17
post #5

While JavaScript drags the scars of its hasty standardization around with it, Go was designed very thoughtfully from the beginning, and as a result I find that it’s a pleasure to write. This is very true. Go is a pleasure to write. In fact, it's such a pleasure then when you hit something that wasn't really well designed it's horrid.

Can I ask what language you are used to? I hear how nice go is as a language a lot, but coming from haskell, go is hideous in comparison.

Re: Go as an alternative to Node.js for Very Fast Servers

#18
post #6

The fact that Node.js is being used in this equation says a lot about how much impact and penetration it has achieved in a rather short while. Personally I hope that Go does just as well, if not a lot better. I am a bit of a fan of both.

I think it says more about the bias of the writer, he seems to assume that Node would be the default choice and that something like erlang/scala/clojure/go would be alternatives. That may be true for someones sideline project.

Re: Go as an alternative to Node.js for Very Fast Servers

#19
post #14
post #9

I played around with a go server to do some simple scaling numbers - looking at possibly using go to implement a large-number-of-idle-connections notification server. I found the (good) result that I could spawn a new goroutine for each incoming connection with minimal (~4k) overhead. This is pretty much what you'd expect since a goro just needs a page for it's stack if it's doing no real work. I had something like 4…

It seems so. https://code.google.com/p/go/issues/detail?id=4056 An interesting point raised there is that if they instead used a limited thread pool for all goroutines to share when making OS calls you could produce deadlocks.

I'm curious what calls could induce deadlock. I figured everything used a nonblocking API internally and the runtime conferred blocking semantics.

Re: Go as an alternative to Node.js for Very Fast Servers

#20
post #4

I've been using Go a lot lately. It's difficult to overstate just how much simpler it makes writing highly-concurrent server-type programs. Entire classes of bugs, issues, and puzzles just vanish.

I have exactly the same experience. Very pleasant to write programs that are going to be used by more than 10k users at once.
Post reply on HN