Btw, the math was off here, with 3 million vs. 5 million ops a second (and these are essentially IO ops - sending messages to the broker), the difference is 0.13 microsecs per op - or 130 nanos. Pretty insignificant for IO based tasks.
> On Oct 30, 2018, at 8:10 AM, Robert Engels <reng...@ix.netcom.com> wrote: > > I’ve written lots of network service code. I understand what’s available. > Actually, for a small number of clients threads are faster than async/nio. In > this case there is only a single active thread during the test. > > The main benefit of using nio is that you can avoid the java space to native > copying by using a direct byte buffer. This would make things considerably > faster, and put less pressure on the garbage collector. But to do this you > need to use channels, and these are a pain with SSL - not impossible but > certainly not trivial. > > I plan on reworking so of the code to use a buffer chain - which is what the > Go version does. > > One thing to keep in mind, at 3-5 million operations a second, the difference > is under 2 microsecs an op. With the GC pauses in Go being half that of Java, > it doesn’t take too many pauses to account speed difference. > > >> On Oct 30, 2018, at 7:17 AM, gerrit.jansen_van_vuu...@datastax.com wrote: >> >> Some notes on your java impl: >> >> You really want to use a framework for handling the connections and >> threading, its tricky in java. >> Your current implementation creates 2 new threads on each connection which >> is wasteful and very expensive. >> >> For threading please see: >> https://stackoverflow.com/questions/5483047/why-is-creating-a-thread-said-to-be-expensive >> >> You would either use: >> https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html >> or >> go for https://netty.io/. >> >> For TLS >> >> Java's implementation is unfortunately slow :(. >> (https://nbsoftsolutions.com/blog/the-cost-of-tls-in-java-and-solutions) >> The solution is to either use something like HAproxy or try and use native >> ssl libraries, https://netty.io/wiki/forked-tomcat-native.html. >> >> For a fairer comparison please do a rerun with the latest jre 11 and the >> threads being created in a global Executor service >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.