0

We are using vertx.eventBus().publish() method from APIs for GET , POST , PATCH , PUT calls. This method consumer is only pushing the data to cache [ we are using HazleCast cache ]. So this consumer is being called from all the APIs [ highly throttled ]

While running this under perf testing , this is causing thread delay issue for Vertx and we notice this as CPU is getting higher at that time as well. This happens for few seconds , then everything coming back to normal state , then it happens again after sometime.

After investigation, this method [ i.e. consumer method for vertx publish event ] is showing up as bottleneck and showing highest time taking method during this intermittent spike.

After reading much documentation, I found this as below.

Internally, Vert.x has Netty schedule another call to the consumer, which will not run until the current invocation (and any other methods scheduled ahead of it on the Netty event loop) complete.

Can you please suggest on this, it looks like vertx.eventBus().publish method should not be used for consuming it inside same application and not a good approach.

arupc
  • 356
  • 1
  • 3
  • 12
  • Is Vert.x running in clustered mode, maybe? – Alexey Soshin Aug 02 '20 at 16:29
  • No, it is not in clustered mode. This is standalone application, producer and consumer are into same application. Also the consumer method to push data to cache are synchronous calls. – arupc Aug 02 '20 at 23:30

1 Answers1

0

This turns out to be an issue with implementation of publish method. The Vertx publish method follows pub-sub pattern. The subscriber implementation needs to be a non-blocking operation. It means that the subscriber needs to be using vertx.executeBlocking handler to wrap the code inside, so it does not block the thread from publisher.

arupc
  • 356
  • 1
  • 3
  • 12