Skip to content

Conversation

@mtmk
Copy link
Member

@mtmk mtmk commented Apr 14, 2025

With this PR we make the request-reply more efficient by skipping inbox queues, hopefully eliminating of the timeout issues some applications have been experiencing.

Opts.RequestReplyMode Feature flag

Using this flag applications can opt-in to this feature minimizing the risk of experiencing issues where somehow they rely on the existing behavior.

var opts = new NatsOpts
{
    RequestReplyMode = NatsRequestReplyMode.Direct,
};
await using var connection = new NatsConnection(opts);

Benchmark

RequestReplyBench:

Method Mean Error StdDev Ratio Gen0 Gen1 Allocated Alloc Ratio
RequestReplyAsync 160.9 us 26.41 us 1.45 us 1.00 0.2441 0.2441 4.57 KB 1.00
RequestReplyDirectAsync 147.4 us 19.57 us 1.07 us 0.92 - - 2.61 KB 0.57

Copy link
Collaborator

@caleblloyd caleblloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement! LGTM

@mtmk mtmk merged commit ee39fe7 into main Apr 15, 2025
20 checks passed
@mtmk mtmk deleted the direct-request-reply-mode branch April 15, 2025 15:20
mtmk added a commit that referenced this pull request Apr 16, 2025
* Stopped testing with net6.0 (#821)
* Update JetStream models (#832)
* Add direct request-reply (#829)
* Socket Connection Factory (#828)
* Fix proxy with TLS scenario with SocketConnectionFactory (#826)
* Make NatsJSConstants public (#825)
* Use Stopwatch in PingCommand for more precise timing (#827)
* Fix netstandard bugs and tidy up tests (#817)
@mtmk mtmk mentioned this pull request Apr 16, 2025
mtmk added a commit that referenced this pull request Apr 16, 2025
* Stopped testing with net6.0 (#821)
* Update JetStream models (#832)
* Add direct request-reply (#829)
* Socket Connection Factory (#828)
* Fix proxy with TLS scenario with SocketConnectionFactory (#826)
* Make NatsJSConstants public (#825)
* Use Stopwatch in PingCommand for more precise timing (#827)
* Fix netstandard bugs and tidy up tests (#817)
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.

3 participants