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

InvokeCallbackAsync latency #9144

Open
meisamhasani opened this issue Sep 22, 2024 · 8 comments
Open

InvokeCallbackAsync latency #9144

meisamhasani opened this issue Sep 22, 2024 · 8 comments

Comments

@meisamhasani
Copy link

Hello, good time
I have a problem , when i call a third-party in timer of Grain
I recive latency a lot is created to fix this latency
What way do you suggest?

image

@ReubenBond
Copy link
Member

Are you able to provide more information? What do your callbacks do, which version of Orleans, etc

@meisamhasani
Copy link
Author

meisamhasani commented Sep 22, 2024

my version is 8.2.0.
my timer is :
this.RegisterGrainTimer(SendMessage, this.State, new()
{
DueTime = TimeSpan.FromSeconds(2),
Period = TimeSpan.FromSeconds(9),
Interleave = true,
KeepAlive = true
});
and SendMessage method call this :
var t = await telegramBot.SendTextMessage("", "text message");

@ReubenBond
Copy link
Member

What is the latency of the Telegram API call?

@meisamhasani
Copy link
Author

Telegram delay is as much as the picture shows
However, I am looking for a solution to remove this delay from the cluster
Do we have a solution?
If the number of these timers and delays is thousands, won't these delays cause problems for my cluster?

@ReubenBond
Copy link
Member

These delays shouldn't cause any issues for your application or Orleans as long as the call is asynchronous (which it appears to be). Anything we do here to reduce the API latency displayed on the graph would just be hiding it, which is likely not useful.

Your system appears to be working well :)

@ReubenBond
Copy link
Member

ReubenBond commented Sep 22, 2024

@meisamhasani I want to clarify: if you have thousands of timers on one grain, that might end up causing some issue for that particular grain. Your timers are interleaved, so they will run concurrently - which is good for end-to-end latency and allows a single grain to scale further. Each grain is single-threaded, they never use more than one CPU core at a time. If you have a very large number of timers, it's possible to have more timers firing concurrently than a single thread can keep up with.

I doubt this will be an issue for you: you would likely need thousands of timers on a single grain to encounter an issue here, assuming your CPU's single-threaded performance is decent. Still, I recommend not having thousands of timers on a single grain. Instead, use more grains. You are likely doing this already, but I want to be explicit.

@meisamhasani
Copy link
Author

I only have one timer per grain.
I did not see any problem.
orleans dashboard showd me latency.
I wanted to make sure that this delay does not cause a disturbance to the cluster or grain.
thank you @ReubenBond

@ReubenBond
Copy link
Member

Happy to help any time, @meisamhasani

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