Live data from Hacker News

uWebSockets: Scalable WebSocket server library for Node.js and C++11

github.com

31–40 of 87 posts

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#31
post #6

Earlier quoted context omitted.

Maybe uvloop? "Uvloop: Fast Python networking" https://news.ycombinator.com/item?id=11625585 Maybe paired with Growler: "Growler: Asyncio Micro-Framework in Python" https://news.ycombinator.com/item?id=11632181 "Simple websocket server with uvloop.": https://gist.github.com/kracekumar/daf10b3be3191a78b037c0c79...

No offence, but I don't think you fully grasp the situation here. This is an extremely optimized fully native server written with low-level CPU awareness. You can absolutely not, in any possible way, write this in Python.

I can understand that you might be a bit frustrated right now, because perhaps that level of performance in pure python may literally be difficult to impossible in this case. But, the question the person was asking was a very reasonable one -- something along the lines of "I'm using this solution in python right now, and I'd like more performance -- what are my options?"

It seems like you not only misunderstand the question, but felt the need to question their intelligence and give a rude, vague, and overall unhelpful answer. As a piece of communication, it is overall useless to everyone involved. Please be mindful of the way you come across. There's no need to insult, dismiss and disrespect others. It only takes a single moment, and saves time and energy for both you and them. You could rephrase like "No. You can approach this to a level of , but it will be hard to pass that point, due to the way the library is written." If you did that, you'd add some very valuable information to the conversation with little effort. It would be a win win for everyone.

Beyond that, assuming your benchmarks are accurate, this seems like a prime library for someone to write a python wrapper for! There's autobahn-twisted right now, but I'm not sure how well it performs in comparison.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#32

Earlier quoted context omitted.

No offence, but I don't think you fully grasp the situation here. This is an extremely optimized fully native server written with low-level CPU awareness. You can absolutely not, in any possible way, write this in Python.

I can understand that you might be a bit frustrated right now, because perhaps that level of performance in pure python may literally be difficult to impossible in this case. But, the question the person was asking was a very reasonable one -- something along the lines of "I'm using this solution in python right now, and I'd like more performance -- what are my options?" It seems like you not only misunderstand the q…

I've actually had run-ins with Alex Hultman before and his tone here seems to follow what I've seen elsewhere.

This project looks nice, but I would need to vet it pretty well before I trust it as the lead maintainer continually acts like a child on Reddit and promptly deletes all his comments shortly after. I'm surprised he is on hacker news as he won't be able to delete his juvenile and argumentative comments here.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#34

uWebSockets is bundled as part of SocketCluster http://socketcluster.io/ and we plan to make it the default in SC v5. We got a massive speedup! Highly recommended.

Yes, Socket.IO really need to step up their game if they are going to have this kind of marketing:

"FEATURING THE FASTEST AND MOST RELIABLE REAL-TIME ENGINE"

Never mind the fact that one libuv tcp stream consumes more memory than one entire WebSocket in µWS...

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#35

In https://github.com/alexhultman/uWebSockets/blob/master/src/u... What's the deal with delete [] (char *) head; where `head` is of type `struct Message` ? Is this some kind of performance trick ?... Otherwise it looks kind of suspicious..

Not sure if that's wrong, but it seems that the program would crash if you call pop() on an empty Queue? I guess it never happens in this particular program, which I assume was the reason to squeeze even more performance.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#36
post #24

In https://github.com/alexhultman/uWebSockets/blob/master/src/u... What's the deal with delete [] (char *) head; where `head` is of type `struct Message` ? Is this some kind of performance trick ?... Otherwise it looks kind of suspicious..

yeah - the C++ bits were clearly written by someone who doesn't know the language well. I'd be careful about using this code in production. EDIT: Specifically I'm referring to the usage of raw pointers, unchecked pointer arithmetic, goto for flow control and raw new/delete calls. The author says they have run tests under valgrind, but that doesn't say anything unless the inputs were malicious. Ideally it should be co…

1. It has been compiled with ASAN. 2. What you suggest would blow the memory footprint 16x.

Thanks for giving your infinite enlightenment, after looking at my code for 10 minutes. I guess your 10 minutes of reading the code is infinitely much more valuable than my 3 months work on it?

Get over yourself.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#37
post #24

In https://github.com/alexhultman/uWebSockets/blob/master/src/u... What's the deal with delete [] (char *) head; where `head` is of type `struct Message` ? Is this some kind of performance trick ?... Otherwise it looks kind of suspicious..

yeah - the C++ bits were clearly written by someone who doesn't know the language well. I'd be careful about using this code in production. EDIT: Specifically I'm referring to the usage of raw pointers, unchecked pointer arithmetic, goto for flow control and raw new/delete calls. The author says they have run tests under valgrind, but that doesn't say anything unless the inputs were malicious. Ideally it should be co…

> usage of raw pointers, unchecked pointer arithmetic, goto for flow control and raw new/delete calls

But without all that you would lose performance which seems to be the main goal of this project.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#38
post #24

Earlier quoted context omitted.

yeah - the C++ bits were clearly written by someone who doesn't know the language well. I'd be careful about using this code in production. EDIT: Specifically I'm referring to the usage of raw pointers, unchecked pointer arithmetic, goto for flow control and raw new/delete calls. The author says they have run tests under valgrind, but that doesn't say anything unless the inputs were malicious. Ideally it should be co…

> usage of raw pointers, unchecked pointer arithmetic, goto for flow control and raw new/delete calls But without all that you would lose performance which seems to be the main goal of this project.

Yes, I use uv_poll_t instead of uv_tcp_t because of massive memory and performance differences.

Every decision made, has been made from a performance perspective.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#39
post #26

Earlier quoted context omitted.

No offence, but I don't think you fully grasp the situation here. This is an extremely optimized fully native server written with low-level CPU awareness. You can absolutely not, in any possible way, write this in Python.

"TL;DR asyncio is an asynchronous I/O framework shipping with the Python Standard Library. In this blog post, we introduce uvloop: a full, drop-in replacement for the asyncio event loop. uvloop is written in Cython and built on top of libuv. uvloop makes asyncio fast. In fact, it is at least 2x faster than nodejs, gevent, as well as any other Python asynchronous framework. The performance of uvloop-based asyncio is c…

Although, thinking a bit more on this (and your more helpful reply to another poster), it might very well be that for web sockets, a better performing solution for python might be to write a wrapper for uWebSockets (the c++ implementation) in python.

I'm guessing that the scaffolding code for the websocket-part in python when working with uvloop might indeed give a meaningful performance and/or memory hit (I'm leaning towards memory probably being the most significant difference here).

I'd be interesting to compare a python+uvloop websocket implementation and uWS (both using nodejs and c++) -- and at some point see if wrapping uWS for python would make a meaningful difference.

Post reply on HN