Request rate limiting

MetaDefender Core has not limited the number of GET requests it serves per second thus far. Consequently, requests fetching results by data_id or batch_id can easily drain MetaDefender Core resources and directly impact the performance of scanning and processing files. OWASP considers the lack of rate limiting a type of vulnerability.

Since MetaDefender Core 5.13.0, request rate limiting is officially supported. Users can follow the steps here to set the request limits for APIs they concern.

To investigate the impact of the rate limit on system performance, the same dataset is tested against MetaDefender Core 5.13.0 on the same environment for several scenarios.

Environment

Hardware8vCPU, 24GB RAM, 150GB SSD
Operating systemWindows Server 2022

MetaDefender Core

Version5.13.0
Max scan queue4000
EnginesFile type, Archive, AhnLab, Avira, Bitdefender, ESET, K7, Quick Heal, and Vir.IT Explorer

Data set

Total file800
Total size762 MB
File size952 KB on average a minimum of 50KB a maximum of 27MB
File typeDOCX, XLSX, PPTX, XLTX

Scenarios

CaseScenario
No-limitNo limit on fetching scan result
Rate-50Only accept 50 fetching requests per second
Rate-20Only accept 20 fetching requests per second
Rate-10Only accept 10 fetching requests per second
Rate-1Only accept 1 single fetching request per second
WebhookApply webhook for fetching result, no limit set

The Webhook case includes header callbackurl in each submission request to MetaDefender Core. MetaDefender Core will respond with the full scan result to the server hosted at the location pointed to by callbackurl once the scan is complete, so no fetching mechanism is needed in this scenario.

Reference here for more details about header callbackurl.

Test steps

  • Install MetaDefender Core and its engines on a clean environment.
  • Setup max scan queue and settings according to test scenario.
  • Submit turns of 1 second apart separately to MetaDefender Core until 2000 files are submitted. Each turn includes 10 files submitted asynchronously to MetaDefender Core using API POST /file.
  • For every 5 seconds, fetch results for all responded data_id asynchronously using GET /file/{data_id} until the scan completes or 503 code responded (except the webhook scenario).

Performance per scenario

CaseDuration (min)Number of processed files per hourAmount of fetching requests per secondFetching error rate (%)
No-limit45.2173,89551.0020
Rate-5041.2190,82235.89710.503
Rate-2031.2251,53611.03893.157
Rate-1028.6274,9136.14196.763
Rate-127.7283,1130.79999.84
Webhook26.9292,389

The higher the request rate limit, the better performance of MetaDefender Core. However, it causes fetching scan result to hit HTTP code 503 more frequently. MetaDefender Core archieves the best performance if callbackurl header is used.

Recommendations

  • Users should set appropriate rate limits for APIs of interest in order to balance the performance and fetching result frequencies.
  • Callback mechanism is recommended for users whom system performance is the top priority. Certainly, they need another server to listen for results responded from MetaDefender Core.
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard