Skip to content

Bypass observation in MessageProducerSupport when NOOP registry is configured #10379

@Nephery

Description

@Nephery

In what version(s) of Spring Integration are you seeing this issue?

6.5.1

Describe the bug

We've been looking into ways to improve our app's messaging throughput in high throughput messaging scenarios.

One thing we've tested out and noticed was that MessageProducerSupport.sendMessage() always creates observability overhead (calling IntegrationObservation.HANDLER) even when ObservationRegistry.NOOP is configured. This seems to result in a performance impact of roughly 15-25% or so in very high throughput messaging scenarios.

To Reproduce

Just run messages as fast as possible through MessageProducerSupport with NOOP observability configured (the default), and watch the throughput.

Expected behavior

When ObservationRegistry.NOOP is configured, observability overhead should be eliminated entirely. The method should detect NOOP registry and bypass observability infrastructure for optimal performance.

One potential solution to this is to add a simple check in MessageProducerSupport.sendMessage():

if (this.observationRegistry.isNoop()) {
    this.messagingTemplate.send(getRequiredOutputChannel(), trackMessageIfAny(message));  // Direct send
} else {
    // existing observability path
}

See this commit for an actual example fix: Nephery@fbb541a

Sample

  1. Clone repository: https://github.com/Nephery/spring-integration-noop-observability-perf
  2. Follow the setup instructions to install the spring integration fork.
  3. Follow these instructions to run the test twice; once with the current spring integration version, and once more with the bypass solution.
  4. Compare the test results between the regular and optimized runs, and notice that the optimized run is a bit better.

Note: When using this NOOP observability bypass in one of our actual apps, we see similar relative performance gains in these very high throughput scenarios.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions