6 ms·
Indeed, I'm reading this wondering how 400 connections could even crash a JVM on an OSX machine. It's surprising. I suspect it's not a threading issue in the s
by KirinDave 16y ago
Indeed, I'm reading this wondering how 400 connections could even crash a JVM on an OSX machine. It's surprising.
I suspect it's not a threading issue in the sense he's describing. 400 threads probably shouldn't give you an OOM unless your heap size is set perilously low (in which case just about everything will give you that error).
It's also painful to then see him argue that epoll/select/NIO is the magical path to freedom. Erlang and Akka developers are trying to to cry and laugh at the same time when they see this.
- caf 16y ago400 threads with a thread stack size of 8M means that 3.2GB of virtual address space needs to be committed, which suspiciously close to the usual limit on a 32 bit system. If you want to create that many threads, you need to start by severely tuning down the stack size.
- MostAwesomeDude 16y agoThe thrust of my argument is merely that one thread for every connection is bad. (Minecraft happens to use two per connection, but that doesn't change the fundamental argument.) You are correct that the problem is not directly due to thread resource usage, but to the additional resources attached to each thread. I was able to raise the heap size, but not able to get past around 600 connections on my 32-bit x86 machine. NIO/MINA is the right answer on Java. If you are using Erlang, well, I would suppose you would not need a Java-based solution. :3
- KirinDave 16y ago"NIO/MINA is the right answer on Java." I think my point, which admittedly is only informed by the work of some brilliant people, is that your point is not supported by data gathered on modern hardware with modern operating systems running a modern JVM. At least, not in all cases. With care and some tuning, people can get extremely good performance out of the thread-per-connection approach. Please check the document linked in the parent to this thread (http://paultyma.blogspot.com/2008/03/writing-java-multithreaded-servers.html http://paultyma.blogspot.com/2008/03/writing-java-multithrea...) What's more, even the systems that are very good at this do not use something like NIO, epoll, or select (as anything other than a very buried implementation detail). Erlang, for example, doesn't restrict you to the kind of model that raw NIO does. NIO is a fine thing for what it is, and a potential building block for many things, but it's not a very compelling as a server framework. MINA is a better suggestion, but still not a universal catch all for these sorts of problems. I'm not trying to say, "NIO is never right, tpp is never wrong." I'm just saying your categorical statement is not always correct. Making that statement is wrong, and it's misleading, and I don't think the problem you found was really due to the unavoidable overhead of the threading.
- MostAwesomeDude 16y agoOkay. I concede.
- KirinDave 16y agoI didn't even know a person COULD enter these words into an internet text box. I thought the internet itself would reject them. ;) I salute you, sir.