Skip to content

Proposal: NatsClient Defaults and Options #1044

@mtmk

Description

@mtmk

NatsClient is designed to be the entry point for new commers with sensible defaults, like ad-hoc JSON serialization being enabled, whereas NatsConnection usage is more suitable for more advanced setups, giving applications much more control over the system.

With the fixes made in #1041 it is important to setup the connections with optimal values so the client works well under load for most scenarios when there are slow consumers . These are internal buffer (channels in our case) capacities and their overflow behavior. In addition to those, logging dropped messages by default should alert the applications of slow consumers.

When using NatsClient:

  • Set SubPendingChannelCapacity to 16384. This is roughly in line with Go (64MB) and Java (~15L Messages) clients. (please correct me if I'm wrong here)
  • Set SubPendingChannelFullMode = BoundedChannelFullMode.DropNewest
  • Deprecate SubPendingChannelFullMode and set it to DropNewest by default. This is fairly fundamental to NATS's philosophy (see Slow Consumers in docs)
  • Listen to MessageDropped evens and log: Slow consumer detected for {Subject}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions