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

chore(api): Increase rate limit window duration to 5 seconds #6759

Merged

Conversation

rifont
Copy link
Collaborator

@rifont rifont commented Oct 23, 2024

What changed? Why was the change needed?

  • Increase rate limit window duration to 5 seconds, allowing for the token bucket to refill to 300 tokens to permit POST /v1/events/bulk endpoint requests
  • Increase the configuration token bucket RPS limit by 33% across all service tiers to permit POST /v1/subscribers/bulk endpoint requests

Screenshots

Before - inability to trigger any bulk request

> curl -X POST http://localhost:3000/v1/events/trigger/bulk \
  -H "Authorization: ApiKey 45354321e95aa33ee424b06d02ee13b6" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "name": "comment-on-post",
        "to": {
          "subscriberId": "66b13c94238f8cf6c4a24770"
        },
        "payload": {
          "customKey": "customValue",
          "customKey1": {
            "nestedkey1": "nestedValue1"
          }
        }
      }
    ]
  }'



{"statusCode":429,"timestamp":"2024-10-23T14:00:45.495Z","path":"/v1/events/trigger/bulk","message":"API rate limit exceeded"}%

After - able to trigger 3 bulk requests in quick succession before being rate limited

> curl -X POST http://localhost:3000/v1/events/trigger/bulk \
  -H "Authorization: ApiKey 45354321e95aa33ee424b06d02ee13b6" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "name": "comment-on-post",
        "to": {
          "subscriberId": "66b13c94238f8cf6c4a24770"
        },
        "payload": {}
      }
    ]
  }'
{"data":[{"acknowledged":true,"status":"processed","transactionId":"9109127c-0b9e-44e8-92e7-a4f899145090"}]}%
rifont at Richards-MacBook-Pro in ~/git/novu on nv-4531-increase-rate-limit-window-duration-to-5-seconds ✗                                                                                                                       [7c9743eef4]  16:05
> curl -X POST http://localhost:3000/v1/events/trigger/bulk \
  -H "Authorization: ApiKey 45354321e95aa33ee424b06d02ee13b6" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "name": "comment-on-post",
        "to": {
          "subscriberId": "66b13c94238f8cf6c4a24770"
        },
        "payload": {}
      }
    ]
  }'
{"data":[{"acknowledged":true,"status":"processed","transactionId":"b7230e35-4982-482c-b2f9-728a3b56fd5c"}]}%
rifont at Richards-MacBook-Pro in ~/git/novu on nv-4531-increase-rate-limit-window-duration-to-5-seconds ✗                                                                                                                       [7c9743eef4]  16:05
> curl -X POST http://localhost:3000/v1/events/trigger/bulk \
  -H "Authorization: ApiKey 45354321e95aa33ee424b06d02ee13b6" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "name": "comment-on-post",
        "to": {
          "subscriberId": "66b13c94238f8cf6c4a24770"
        },
        "payload": {}
      }
    ]
  }'
{"data":[{"acknowledged":true,"status":"processed","transactionId":"3d21a8db-13d2-4b2b-8948-1c249b68f056"}]}%
rifont at Richards-MacBook-Pro in ~/git/novu on nv-4531-increase-rate-limit-window-duration-to-5-seconds ✗                                                                                                                       [7c9743eef4]  16:05
> curl -X POST http://localhost:3000/v1/events/trigger/bulk \
  -H "Authorization: ApiKey 45354321e95aa33ee424b06d02ee13b6" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "name": "comment-on-post",
        "to": {
          "subscriberId": "66b13c94238f8cf6c4a24770"
        },
        "payload": {}
      }
    ]
  }'
{"statusCode":429,"timestamp":"2024-10-23T14:05:59.796Z","path":"/v1/events/trigger/bulk","message":"API rate limit exceeded"}%
Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

linear bot commented Oct 23, 2024

@SokratisVidros SokratisVidros merged commit 6c8a47d into next Oct 23, 2024
35 checks passed
@SokratisVidros SokratisVidros deleted the nv-4531-increase-rate-limit-window-duration-to-5-seconds branch October 23, 2024 14:12
Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for novu-stg-vite-dashboard-poc ready!

Name Link
🔨 Latest commit 961bf0b
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/671903d48d0c1300085032c7
😎 Deploy Preview https://deploy-preview-6759--novu-stg-vite-dashboard-poc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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

Successfully merging this pull request may close these issues.

2 participants