Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: rate limiting #59

Merged
merged 3 commits into from
Jan 18, 2024
Merged

feat: rate limiting #59

merged 3 commits into from
Jan 18, 2024

Conversation

Jaszkowic
Copy link
Contributor

@Jaszkowic Jaszkowic commented Jan 17, 2024

let's discuss what values to use for rate limiting. we want to avoid that the Parla API can be used to send too many requests to OpenAI.

@Jaszkowic Jaszkowic requested a review from ff6347 as a code owner January 17, 2024 14:28
Copy link

render bot commented Jan 17, 2024

@Jaszkowic
Copy link
Contributor Author

This plugin will add an onRequest hook to check if a client (based on their IP address) has made too many requests in the given timeWindow.

https://github.com/fastify/fastify-rate-limit

@Jaszkowic
Copy link
Contributor Author

Why 30 requests / min / IP ?

  • 2 request per page load (document count)
  • 2 requests per question (document_search and generate_answer)
  • total 4 requests per question
  • answer takes ~20s to load

in total: (2+2)*3 = 16 requests / min

adding some free bonus requests to account for unusual behavior:

total 30 requests / min should be enough

@ff6347
Copy link
Collaborator

ff6347 commented Jan 17, 2024

30/min is already under attack. Maybe 10?

@ff6347
Copy link
Collaborator

ff6347 commented Jan 17, 2024

30 Sounds good. 👌🏾

@Jaszkowic Jaszkowic merged commit af5c77c into main Jan 18, 2024
4 checks passed
@Jaszkowic Jaszkowic deleted the feat/rate-limit branch January 18, 2024 08:28
tsboter pushed a commit that referenced this pull request Jan 18, 2024
# [1.18.0](v1.17.0...v1.18.0) (2024-01-18)

### Features

* rate limiting ([#59](#59)) ([af5c77c](af5c77c))
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants