Live data from Hacker News

Handling 1M websocket connections in Go

github.com

51–60 of 68 posts

Re: Handling 1M websocket connections in Go

#51

Can someone make a comparison between this and the Elixir Phoenix 2m websocket conmections example. I want to sleep.

I remember seeing a talk on the 2m websocket Elixir example and one of the keys to it was that the sockets were actually being used and processing messages intermittently during the test. Important thing to keep in mind vs simply opening. The other thing I'd be interested to see Elixir demonstrate would be doing a hot deployment to avoid triggering all 2m connections to try reconnect at the same time. The other impor…

With Elixir/OTP there would be no disconnection/reconnection. The way hot code push works with OTP is that each "channel" (OTP "process"/websocket connection) has a GenServer, which is basically a state machine, and when there is a new version of the function available in the VM, the current state is passed into a function (supplied by you) to mutate it into a shape compatible with your new change, then next time the data is passed around the loop to the state management function, it goes to the new one instead. Because the state data is stored quite separately to the actual functions who mutate it, there is no need to disconnect or do any mass purging of memory when there's a hot code deployment.

Re: Handling 1M websocket connections in Go

#52

1 million tcp connections with vertx / kotlin https://github.com/lfmunoz/vertx-kt-rocket Nothing special other than having to tune Linux

Jvm is very optimized, so it's actually something not that non-special.

> "so it's actually something not that non-special."

That is not totally true, This is a mix of 2 things, using the JVM (which like you said is being tuned and optimized for heavy loads) + using a true asynchronous and reactive programming (and IO) model built on great technologies such as (in this specific case: Kotlin, Eclipse Vert.x and Netty).

As an experiment if you would pick another random set of libraries (imagine a servlet container) achieving the same results would not be so trivial, see for example:

https://www.techempower.com/benchmarks/#section=data-r17&hw=...

And observe that Eclipse Vert.x is on the top for these reasons while other JVM frameworks are far behind.

Re: Handling 1M websocket connections in Go

#53
post #19

I'd like to see this kind of story combined with the "how to build a business" threads to discuss what kinds of business models and sizes require a million websocket connections to one process. 1M simultaneous users of a React (or other) app, is that a decently simple case? What are some sites that have this level of activity? I found a 5yr old article that says Spotify had 20MM simultaneous users then, but spread ov…

I like to think of projects like this when a team of "engineers" have trouble scaling their cloud service to support more then one simultaneous user.

Re: Handling 1M websocket connections in Go

#56
post #36
post #32

Earlier quoted context omitted.

When people rewrite system from X where X in (Python, Ruby, Node, Clojure) to Go they usually see at least 10x improvement. This is just one recent example: https://www.infoq.com/articles/api-gateway-clojure-golang The money quote: "The end result enabled us to reduce 25 instances (c4 xlarge) running Clojure code - able to process 60 concurrent requests, to two instances (c3.2xlarge) running Go code able to support ~…

"When people rewrite system from X where X in (Python, Ruby, Node, Clojure) to Go they usually see at least 10x improvement." Sure but how much of the performance gains come from Go and how much come from just having a better understanding of the problem the second time around?

Go is strongly typed and compiled, it literally does 10x less work than dynamic languages for most things.

Pypy leads to a near 10x speed up over cPython as well.

Re: Handling 1M websocket connections in Go

#57
post #27
post #19

I'd like to see this kind of story combined with the "how to build a business" threads to discuss what kinds of business models and sizes require a million websocket connections to one process. 1M simultaneous users of a React (or other) app, is that a decently simple case? What are some sites that have this level of activity? I found a 5yr old article that says Spotify had 20MM simultaneous users then, but spread ov…

I have written a 1mm+ simultaneous user websocket server for a second screen app for a well known talent TV show in Node. It was running on a single server (with failovers and redundancies of course) just fine, but 99% of the server was just broadcasting. The hard part is sending single messages to users with user-specific content.

Agree on the hard part. Fan out models like this with the same content is "easy". Getting unique content to specific users in an efficient way, in scale of 100.000 users plus, that's hard.

Re: Handling 1M websocket connections in Go

#58

Earlier quoted context omitted.

Or Java or C# or basically any non-interpreted language.

In this case, Clojure is already running on the JVM

The Clojure compiler does not generally produce the same byte code as the Java one.

Idiomatic clojure is routinely slower than idiomatic Java and that’s a well known and expected outcome.

Re: Handling 1M websocket connections in Go

#59
post #53
post #19

I'd like to see this kind of story combined with the "how to build a business" threads to discuss what kinds of business models and sizes require a million websocket connections to one process. 1M simultaneous users of a React (or other) app, is that a decently simple case? What are some sites that have this level of activity? I found a 5yr old article that says Spotify had 20MM simultaneous users then, but spread ov…

I like to think of projects like this when a team of "engineers" have trouble scaling their cloud service to support more then one simultaneous user.

[deleted]

Re: Handling 1M websocket connections in Go

#60
post #32

These kinds of benchmarks are not very meaningful. I think that pretty much any modern framework/language can handle at least 1 million idle WebSockets. It's much more interesting to measure performance when you start sending messages through them at regular intervals.

When people rewrite system from X where X in (Python, Ruby, Node, Clojure) to Go they usually see at least 10x improvement. This is just one recent example: https://www.infoq.com/articles/api-gateway-clojure-golang The money quote: "The end result enabled us to reduce 25 instances (c4 xlarge) running Clojure code - able to process 60 concurrent requests, to two instances (c3.2xlarge) running Go code able to support ~…

I didn't think Go rewrites were common anymore since the results were mediocre.
Post reply on HN