limitador icon indicating copy to clipboard operation
limitador copied to clipboard

Multi thread check & update

Open didierofrivia opened this issue 2 years ago • 1 comments

This PR is yet another step closer to proper multi thread Limitador.

However, the changes introduced makes de check_and_update "racy", since different requests will check and update at the same time:

  1. It could/will happen that one thread will load a counter value at the "check" phase and at the same time, a different thread will store a value at the "update" phase to the same counter.
  2. Some counters will end up being updated while others won't if one ends up being limited in the update phase.
  3. Those competing threads might end limiting a bit late (overshooting).

Regarding the bench, there's a regression of 3% but it's kind of a lie, since we are not benching for multi-threading requests.

didierofrivia avatar Aug 24 '23 11:08 didierofrivia

Codecov Report

Merging #203 (5d94409) into main (490826c) will increase coverage by 0.51%. Report is 6 commits behind head on main. The diff coverage is 98.98%.

@@            Coverage Diff             @@
##             main     #203      +/-   ##
==========================================
+ Coverage   73.46%   73.98%   +0.51%     
==========================================
  Files          30       30              
  Lines        5058     5124      +66     
==========================================
+ Hits         3716     3791      +75     
+ Misses       1342     1333       -9     
Files Changed Coverage Δ
limitador/src/storage/in_memory.rs 89.60% <98.98%> (+7.29%) :arrow_up:

... and 5 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Aug 24 '23 11:08 codecov-commenter