kedacore / keda

KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes
https://keda.sh
Apache License 2.0
8.43k stars 1.06k forks source link

Proposal to change Google pub/sub scaler #6193

Open IanMoroney opened 3 weeks ago

IanMoroney commented 3 weeks ago

Proposal

Now that it's possible to pull messages directly from pub/sub without acknowledging them, a more direct integration with Google pub/sub should be possible. https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull

Use-Case

With the current num_undelivered_messages metric implementation, it takes 2-3 minutes between when a message is dropped on the queue and when the metric is updated. This is unacceptable in terms of lag for near real-time operations when keda is meant to scale based on a message appearing in the queue.

Is this a feature you are interested in implementing yourself?

No

Anything else?

No response

JorTurFer commented 3 weeks ago

Hello Are you sure that you can get the queue length directly? The link you sent pulls the messages from the queue directly

IanMoroney commented 2 weeks ago

By pulling the messages, you can count the queue length. Pulling without acking leaves the messages on the queue

IanMoroney commented 2 weeks ago

Thinking about it, that could present a problem for a lot of messages, so wouldn't necessarily scale well.

rickbrouwer commented 2 weeks ago

Yeah, if there are a significant number of messages on it, this can become an issue.

JorTurFer commented 2 weeks ago

I see multiple issues on that approach:

I agree with you in the point of current approach doesn't work for real time scenarios due to the consolidation lag in monitoring APIs, but we prefer to keep KEDA "agnostic" of the data plane to prevent potential data leaks. All the scalers work at control plane level

IanMoroney commented 1 week ago

In case they actually look at implementing something like this, i've formally requested it in the Google issue tracker for pub/sub. If you'd like to comment on it to see if it gets any traction: https://issuetracker.google.com/issues/372044259