4 ms·
Jeez web sockets really aren't that hard. We've used them for a long time on our production site for a live attack map: https://www.wordfence.com/ https://www.w
by mmaunder 11y ago
Jeez web sockets really aren't that hard. We've used them for a long time on our production site for a live attack map: https://www.wordfence.com/ https://www.wordfence.com/ and we regularly have over 1000 concurrent visitors on the site when we promote a blog post or do something similar.
I can't think of any reason why I wouldn't use node.js on the server-side for web sockets. It obviously uses epoll() and you really need an event language to be comfortable writing an application that manages a large number of concurrent connections. Ruby for this makes me shudder - sorry it just feels like a square peg forced into a round hole that's late to the party.
- icebraining 11y agoI'm hardly a Ruby fan - nothing against it, I just prefer Python - but what makes it such a bad choice vis-a-vis JavaScript? Sure, Rails isn't built with this in mind, but why would Ruby with some kind of libuv-based framework be such a terrible choice?
- cdelsolar 11y agoIt's not meant for it. Python is similar, there are hacks (such as eventlet) that have their own downsides. Use the right tool for the job. We are currently rewriting an eventlet-based part of our stack in Go with much better results.
- rubiquity 11y agoYou might want to read or watch this presentation before doing that: https://docs.google.com/presentation/d/1LO_WI3N-3p2Wp9PDWyv5B6EGFZ8XTOTNJ7Hd40WOUHo https://docs.google.com/presentation/d/1LO_WI3N-3p2Wp9PDWyv5... Mozilla went from Python to Go and then back again for reasons I think you would also run into.
- icebraining 11y agoYeah, I can see how Go has some built-in advantages over Ruby and Python in this regard, but I was really looking to understand why mmaunder considers JavaScript a much better choice than Ruby.
- mmaunder 11y agoSorry, just read this now. JS's core DNA is as an event language because it was designed for the browser UI which is all about events. Through a wonderful turn of events someone slapped V8 on the server and people started dabbling with JS on the server at the same time as epoll() and/or kqueue emerged and started being used to amazing effect by nginx and other projects. And so we ended up with this sweet spot of a fast event platform with a super accessible language and a way to handle hundreds of thousands of connections with almost no CPU load. So it's not really about the deficiencies of Ruby (which is awesome for what it's good at) but it's about how incredibly strong node.js and epoll() is for doing anything that would normally be designed with multiple threads and blocking architecture. So with regards to my square peg/round hole comment. I didn't mean sarcasm - what I mean is that node.js is just so incredibly great at any task where you're waiting on stuff that would block in old-school multi-threaded architecture - both in terms of performance (no load when nothings happening), architecture (a single thread and event loop does it all) and programmability (event handlers, callbacks closures and the syntax are so great for this kind of coding).
- icebraining 11y agoThe thing is, Ruby can use epoll/libuv as well, so how is that an advantage of Node.js? So the only difference is in the languages themselves, and I don't see where Ruby lacks - after all, the callback pattern is pretty embedded in the language with blocks, and arguably more pleasant to use than JS functions.
- mmaunder 11y agoThen by all means, use Ruby. Most langs have epoll.
- icebraining 11y agoI'll use Python anyway :) I just wanted to understand why people advocated for Node.js over Ruby.