abrandoned / protobuf-nats

MIT License
8 stars 4 forks source link

Upgrade jnats.rb wrapper to use jnats.jar 2.6.0 #42

Open film42 opened 5 years ago

film42 commented 5 years ago

Version 2.0 of jnats was a complete rewrite. We could not upgrade before now because the Dispatcher class had a map data structure that prevented duplicate subscriptions from being created (a feature we use for slowly introducing traffic while the JVM warms up). As of 2.6.0 we can once again subscribe multiple times, so we can upgrade, yay!

Since v2 was a rewrite, you'll notice quite a bit of jnats changed. I added helper classes to satisfy java interfaces required to use the new jnats lib. Because the new Dispatcher manages the actual dispatching, we are able to our own supervisor/ conusmer methods which is really nice. I also added more specs around the jnats.rb wrapper to gain confidence that we're compatible.

The benchmarks appear to be about the same between v1 and v2 of the jnats lib.

--- JNATS 2.6.0:
protobuf-nats (gt/new_jnats) $ derp bx ruby ./bench/real_client.rb
I, [2019-07-12T13:46:38.172796 #25491]  INFO -- : Using Protobuf::Nats::JNats to connect
Warming up --------------------------------------
single threaded performance
                        31.000  i/100ms
Calculating -------------------------------------
single threaded performance
                        909.872  (±34.3%) i/s -      8.029k in   9.998293s

--- JNATS V1:
protobuf-nats (master) $ derp bx ruby ./bench/real_client.rb
I, [2019-07-12T13:45:17.016641 #25019]  INFO -- : Using Protobuf::Nats::JNats to connect
Warming up --------------------------------------
single threaded performance
                        31.000  i/100ms
Calculating -------------------------------------
single threaded performance
                        951.302  (±32.0%) i/s -      8.525k in  10.020770s

The variance is pretty high, and I can get the results to flip-flop. Benchmarking multi-threaded network code is hard, but this is a loose illustration to show that perf should be about the same.

Once I get a :+1: I'll cut a pre-release and test it in production for a few days.

cc @abrandoned @minond @liveh2o

liveh2o commented 5 years ago

Perhaps we can cut a beta release to test before making this GA?

film42 commented 5 years ago

Pre-released 0.11.0.pre0 has been pushed to rubygems.

film42 commented 5 years ago

Pre-released 0.11.0.pre1 has been pushed to rubygems.

film42 commented 4 years ago

Saw some strange errors in production. I'll need to track those down. It's been a long time since I've been able to check back in on this.