nats-io / stan.net

The official NATS .NET C# Streaming Client
Apache License 2.0
138 stars 41 forks source link

Use a soft flush to reduce latency #167

Closed ColinSullivan1 closed 4 years ago

ColinSullivan1 commented 4 years ago

Use Connection.FlushBuffer() over Connection.Flush() to reduce overhead and latency.

Signed-off-by: Colin Sullivan colin@synadia.com

ColinSullivan1 commented 4 years ago

I had only flushed in blocking calls (they have no handler), because the full flush (PING/PONG) was expensive, but with the soft flush I suppose it makes sense to always call it.

ColinSullivan1 commented 4 years ago

On second thought, with async publishing users are more interested in performance rather than latency. Later, I'll do some benchmarks but for now want to the leave the async as is.