Snd-R / komf

Komga and Kavita metadata fetcher
MIT License
324 stars 19 forks source link

Rate Limit on Kavita APIs #172

Closed majora2007 closed 1 month ago

majora2007 commented 1 month ago

Komf can sometimes call series update apis quite fast and uncontrolled when reacting to new media added. However this API is quite heavy due to the scope of all the tables needing to be updated or new entities created. Users have reported that komf can spike their CPU to 100% for an extended time.

It would be great if komf could rate limit itself on calling the API to give Kavita time to properly perform the actions. Let me know your thoughts @Snd-R, I'd be happy to reach a middle ground.

Snd-R commented 1 month ago

What do you think would be a good wait interval? Would 2 requests per second be good?

majora2007 commented 1 month ago

I think that would be great.

ElryGH commented 1 month ago

Let me chime in and say that i would like this to be configurable in the application.yml.

kavita:
  baseUri: "http://localhost:5000" #or env:KOMF_KAVITA_BASE_URI
  apiKey: "ft34tg5uzredu4tz5e34qwz5eqw5" #or env:KOMF_KAVITA_API_KEY
  ratelimit: 2 #Max calls to Kavita API per Second (Keep between 2-5)
majora2007 commented 1 month ago

Thanks Snd-R, I think this is going to be great for a lot of users with large libraries. @DieselTech :)