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

Refresh projects cron function is taking too long #275

Open
samtstern opened this issue Dec 15, 2021 · 1 comment
Open

Refresh projects cron function is taking too long #275

samtstern opened this issue Dec 15, 2021 · 1 comment
Labels

Comments

@samtstern
Copy link
Contributor

The function refreshProjectsCron takes too long to run.
The timeout is 540s and right now it's taking over 200s, which is way too long given the fan-out architecture. It should be very fast, leaving most of the work to the other functions.

Screen Shot 2021-12-15 at 11 50 43 AM

@drraghavendra
Copy link

There are a few possible reasons why a refresh projects cron function might be taking too long:

The function is simply performing a lot of work. For example, if the function is responsible for refreshing a large number of projects, or if the projects are complex, it will naturally take longer to run.
The function is running on a resource-constrained server. If the server is not powerful enough to handle the workload, the function will take longer to run.
The function is waiting on external resources. For example, if the function needs to access a database or API, it will have to wait for those resources to respond.
The function is poorly written. If the function is poorly coded, it may be inefficient and take longer to run than necessary.
To troubleshoot the issue, you can try the following:

Check the cron logs to see how long the function is taking to run. This will give you a good idea of where the bottleneck is.
Try running the function manually to see if it takes the same amount of time as it does in the cron job. If it doesn't, then the problem is likely related to the cron job itself.
Check the resources available to the server that the function is running on. If the server is underpowered, you may need to upgrade it or move the function to a different server.
If the function is waiting on external resources, try to optimize the code to reduce the amount of time it needs to wait.
If the function is poorly written, try to refactor the code to make it more efficient.
Here are some additional tips for optimizing your refresh projects cron function:

Use caching to store the results of frequently accessed queries.
Use asynchronous programming techniques to avoid blocking the main thread.
Use a batching strategy to process multiple projects at the same time.
Use a load balancer to distribute the workload across multiple servers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants