News for hackers. Stuff that matters.
Re:High-Throughput Game Message Server with Python WebSockets by gameswithgo on Saturday December 05, 2020 @06:37PM (#25319484)
Author contemplating an eventual C++ rewrite, but this is a perfect use case for Rust. When you want performance and where memory mistakes can be a serious security problem.
Re:High-Throughput Game Message Server with Python WebSockets by pensatoio on Saturday December 05, 2020 @08:23PM (#25320081)
Or anything that isn’t a scripting language
Re:High-Throughput Game Message Server with Python WebSockets by gameswithgo on Sunday December 06, 2020 @08:17AM (#25323309)
indeed, C#/Go/Java etc would all be a big boon without the mental overhead of Rust. Data races being caught at compile time is also nice though when doing a multithreaded server.
Re:High-Throughput Game Message Server with Python WebSockets by gnusty_gnurc on Saturday December 05, 2020 @08:15PM (#25320027)
> but this is a perfect use case for Rust

Idk it seems like for someone prototyping things alone, Python is the perfect langauge

Re:High-Throughput Game Message Server with Python WebSockets by kroltan on Sunday December 06, 2020 @06:30AM (#25322818)
I don't think the parent is disagreeing with that, but the article mentions graduating from Python to something else, which is where the recommendation fits. Parent isn't saying the article's original version should be in Rust.
Re:High-Throughput Game Message Server with Python WebSockets by gnusty_gnurc on Sunday December 06, 2020 @12:51PM (#25325148)
got it thx
Re:High-Throughput Game Message Server with Python WebSockets by Yoric on Sunday December 06, 2020 @03:30AM (#25322039)
Just wrote a websocket server in Rust. Turned out really easy.
Re:High-Throughput Game Message Server with Python WebSockets by skeeks on Saturday December 05, 2020 @07:52PM (#25319913)
Or java
Re:High-Throughput Game Message Server with Python WebSockets by mathgladiator on Sunday December 06, 2020 @03:33AM (#25322053)
I used to be on the java hate train, but honestly the JVM is magic for infra. I worked at AWS, and I groaned so hard when I started. Then, I came to appreciate it because of the tooling and the types of issues that actually cropped up.

This may also be stockholm syndrome.

Re:High-Throughput Game Message Server with Python WebSockets by gameswithgo on Sunday December 06, 2020 @08:19AM (#25323320)
the nice thing about Java is you get pretty good performance even while pretending the hardware concerns don't exist. This takes a lot of things to think about off your brain. The downside is you can't choose to think about them even if you want to.
Re:High-Throughput Game Message Server with Python WebSockets by nick_ on Saturday December 05, 2020 @08:16PM (#25320033)
Or F#/C#. Rust will have memory fragmentation over time.
Re:High-Throughput Game Message Server with Python WebSockets by catlifeonmars on Saturday December 05, 2020 @09:47PM (#25320582)
Memory fragmentation is generally a problem for pets, not cattle. In 90% of use cases it’s nothing that frequently reaping processes won’t fix. This works regardless of language, as it pushes the job of garbage collection onto the os. Another nice feature of treating your processes like dirt is that you tend to get high fault tolerance and scalability as emergent properties.
Re:High-Throughput Game Message Server with Python WebSockets by zamalek on Sunday December 06, 2020 @12:10AM (#25321228)
Right. Just like the story of a memory leak in a missile.[1]

[1]: https://devblogs.microsoft.com/oldnewthing/20180228-00/?p=98...

Re:High-Throughput Game Message Server with Python WebSockets by Yoric on Sunday December 06, 2020 @03:34AM (#25322055)
I really think it's a good solution for many cases but I haven't seen any server-side web framework that implements a kill-the-process-often strategy.

Do you know of any? If so, when do they decide to kill the process and how do they handle client disconnect?

Re:High-Throughput Game Message Server with Python WebSockets by jlokier on Sunday December 06, 2020 @03:44PM (#25326451)
Some pre-forking web servers will shut down a child process after it has processed a configured number of requests.

E.g. Apache in mpm_prefork mode, MaxRequestsPerChild configuration.

Re:High-Throughput Game Message Server with Python WebSockets by zamalek on Sunday December 06, 2020 @12:06AM (#25321200)
C# suffers from that too. I've personally seen a prod instance experience OOM with something like 40% free virtual memory. There's a reason why ArrayPool is part of mscorlib.

All of that said, x64 greatly reduces the effects of memory fragmentation: there's always more virtual memory.

Re:High-Throughput Game Message Server with Python WebSockets by cube00 on Saturday December 05, 2020 @08:58PM (#25320302)
Re:High-Throughput Game Message Server with Python WebSockets by gitweb on Saturday December 05, 2020 @07:05PM (#25319647)
I prefer C or Go
Re:High-Throughput Game Message Server with Python WebSockets by lwansbrough on Saturday December 05, 2020 @08:07PM (#25319977)
Ah yes, C, well known for its memory safety!
Re:High-Throughput Game Message Server with Python WebSockets by 1024core on Saturday December 05, 2020 @08:58PM (#25320306)
As with any tool, if you don't use it properly it can hurt you.
Re:High-Throughput Game Message Server with Python WebSockets by rowanG077 on Saturday December 05, 2020 @09:23PM (#25320460)
That's quite a ridiculous statement in this context. Even highly-trained, extremely smart developers are proven to not be able to use C without introducing gaping security holes. That's not "it can hurt you". That's "it hurts you and everyone that is exposed to your RCE machine".
Re:High-Throughput Game Message Server with Python WebSockets by 1024core on Sunday December 06, 2020 @02:34PM (#25325994)
Have you looked at code by AntiRez, the author of Redis? Redis is written in plain C.

What about QMail and DJBDNS, from Dan Bernstein? Again, all C.

And the mother of all: the Linux kernel. Again, in C.

Re:High-Throughput Game Message Server with Python WebSockets by rowanG077 on Sunday December 06, 2020 @07:45PM (#25328190)
Redis has RCE exploits which would not exist in a memory safe language [1]. QMail had an RCE as well[2] and DJBDNS has had a security bug which would not have occurred in a memory safe languages [3]. The linux kernel has had an incredible amount of memory bugs over the years. The software you mentioned does much, much better then the average C written code. But it still has had issues with memory. So in fact all your examples prove my point.

[1] https://github.com/jas502n/Redis-RCE

[2] https://www.qualys.com/2020/05/19/cve-2005-1513/remote-code-...

[3] https://web.archive.org/web/20190126114638/http://article.gm...

Re:High-Throughput Game Message Server with Python WebSockets by gitweb on Saturday December 05, 2020 @11:46PM (#25321113)
C is not C++. There is a reason core services for DHCP, DNS, etc are built in C and not Rust. If you're a careless developer you can have security vulnerabilities in any language.
Re:High-Throughput Game Message Server with Python WebSockets by weakfish on Sunday December 06, 2020 @12:39AM (#25321385)
The reason they're built in C is legacy and the fact that Rust hasn't been around all that long.
Re:High-Throughput Game Message Server with Python WebSockets by 1024core on Sunday December 06, 2020 @02:38PM (#25326017)
Well, what's stopping you from rewriting it in Rust?
Re:High-Throughput Game Message Server with Python WebSockets by imtringued on Sunday December 06, 2020 @08:00AM (#25323228)
That's only true on Linux and other systems where the kernel has been written in C. On some platforms the kernel provides no backwards compatibility guarantees and that means backwards compatibility is handled by libc. This means C is enshrined into the platform and often the path of least resistance.

There was also a pure Rust Wayland binding that failed because Wayland assumes that you are using C semantics which made it hard to provide a safe interface for Rust that was also convenient.

Re:High-Throughput Game Message Server with Python WebSockets by rowanG077 on Sunday December 06, 2020 @07:01AM (#25322965)
Yes, and that good reason was that Rust did not exist.
Re:High-Throughput Game Message Server with Python WebSockets by malka on Saturday December 05, 2020 @09:32PM (#25320513)
I'd rather be hurt by my safety razor than by my chainsaw though.