nats-io / nats.go

Golang client for NATS, the cloud native messaging system.
https://nats.io
Apache License 2.0
5.3k stars 671 forks source link

Request Reply for JetStream for autoscaling and scaling to zero (similar to Knative) #1627

Open tamis-laan opened 2 months ago

tamis-laan commented 2 months ago

Proposed change

We can use Request Reply from NATS core but it would be awesome to have the same for JetStream. The reason being is that we can use the number of requests for autoscaling and scaling to zero similar to Knative.

The same idea holds for the services API.

Use case

Microservices autoscaling including scaling to zero. Combined with cluster autoscaling this would allow for reduced cloud costs. Particularly useful for running heavy batch jobs that run once in a blue moon.

Contribution

No response

derekcollison commented 2 months ago

Since there is usage of reply subjects for both stream ingest and consumer ack for a message flowing through jetstream, you would need to use a header to signify the service reply subject and the responding ack would need to look for that header and use that if present when replying.

There also may be a different approach to this problem that does not involve jetstream.