Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Balancing on custom metric #1234

Open
sysrun opened this issue Aug 7, 2023 · 4 comments
Open

Load Balancing on custom metric #1234

sysrun opened this issue Aug 7, 2023 · 4 comments

Comments

@sysrun
Copy link

sysrun commented Aug 7, 2023

Is your feature request related to a problem? Please describe.

I want to use custom metrics like the cpu strategy

Additional context

I have multiple instances of one service. Every service can handle a limited amount of "slots". If no slot is available the load balancer should not try to send the request to the service which has no slots available.

@icebob
Copy link
Member

icebob commented Aug 7, 2023

What is the question or problem?

@sysrun
Copy link
Author

sysrun commented Aug 7, 2023

I am not sure how to make a service aware of a "dynamic" value (like the cpu in the CpuStrategy) which i could use in a custom LB-Strategy.

Example:

i have 3 instances/nodes of 1 service. This service is exposing an action called "assign". The service also has a "assigncounter" which is incremented if a "service.assign" is called at the specific instance.

Now i want to Loadbalance - so i have to know which instance has the lowest "assigncounter".

So: How could a LB-Strategy access such dynamic service variables? :)

@icebob
Copy link
Member

icebob commented Aug 11, 2023

It can be only complicated way. The CPU strategy can work because CPU usage is shared between nodes, the INFO packet contains it. But a custom value is not shared and synchronized between the nodes. For this purpose, I recommend to use Redis to store and increment the value of your variable and get this value from the Redis in your Strategy.

@sysrun
Copy link
Author

sysrun commented Aug 11, 2023

Ah, ok. Thanks :)

Redis is already my "plan b".

Would be nice if there would be an option to register custom stats in the future.

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

No branches or pull requests

2 participants