Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

film42
Copy link
Collaborator

@film42 film42 commented Jul 24, 2019

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 👍 I'll cut a pre-release and test it in production for a few days.

cc @abrandoned @minond @liveh2o

@liveh2o
Copy link

liveh2o commented Aug 6, 2019

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

@film42
Copy link
Collaborator Author

film42 commented Aug 12, 2019

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

This happens when we attempt to use nats during a restart state. It will
tell us we cannot queue messages (this is good), but does so via illegal
state exception. So we need to be able to handle it.
Example:

W, [2019-08-20T15:58:37.262665 #32493]  WARN -- : An Java::JavaLang::IllegalStateException was raised. We are going to sleep for 5 seconds.
@film42
Copy link
Collaborator Author

film42 commented Aug 21, 2019

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

@film42
Copy link
Collaborator Author

film42 commented Jul 7, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants