8000 Optimise webhook events by christyjacob4 · Pull Request #9168 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Optimise webhook events #9168

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

Merged
merged 6 commits into from
Jan 17, 2025
Merged

Optimise webhook events #9168

merged 6 commits into from
Jan 17, 2025

Conversation

christyjacob4
Copy link
Member

What does this PR do?

Perviously all endpoints with an event, triggered webhooks events which resulted in the a lot of spurious events in the webhooks queue and causing redis memory usage to increase.

In this PR we check if the project has webhooks enabled and only then trigger the event.

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Copy link
github-actions bot commented Jan 4, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
pyc 3.12.7-r0 CVE-2024-12254 HIGH
python3 3.12.7-r0 CVE-2024-12254 HIGH
python3-pyc 3.12.7-r0 CVE-2024-12254 HIGH
python3-pycache-pyc0 3.12.7-r0 CVE-2024-12254 HIGH
rsync 3.3.0-r0 CVE-2024-12084 CRITICAL
rsync 3.3.0-r0 CVE-2024-12085 HIGH
golang.org/x/crypto v0.26.0 CVE-2024-45337 CRITICAL
golang.org/x/net v0.28.0 CVE-2024-45338 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
github-actions bot commented Jan 4, 2025

✨ Benchmark results

  • Requests per second: 1,096
  • Requests with 200 status code: 197,282
  • P99 latency: 0.168057495

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,096 1,770
200 197,282 318,571
P99 0.168057495 0.06670679

$queueForRealtime
->from($queueForEvents)
->trigger();
/** Trigger realtime events only for non console events */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the console also uses realtime events, or those are all associated with a specific project?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't fire realtime events for DOCUMENT_CREATE events fired from the console. This is the existing behaviour. I have not changed it.

https://github.com/appwrite/appwrite/blob/1.6.x/app/controllers/shared/api.php#L81-L88

https://github.com/appwrite/appwrite/blob/1.6.x/app/controllers/shared/api.php#L529-L536

if ($queueForEvents->getProject()->getId() === 'console') {
return;
/** Trigger webhooks events only if a project has them enabled */
if ($project->getAttribute('webhooks', []) !== []) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to go deeper and check if the specific even is listened by the webhooks? we should have the list of affected events in this context.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-01-07 at 10 27 53 AM

I have added a todo here, for additional optimisation. As it needs some benchmarks etc to understand the added latency in a request.

@christyjacob4 christyjacob4 merged commit b81e15f into 1.6.x Jan 17, 2025
63 checks passed
@christyjacob4 christyjacob4 deleted the optimise-webhook-events branch January 17, 2025 14:21
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

Successfully merging this pull request may close these issues.

3 participants
0