mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #10740 from overleaf/jpa-auto-compile-rate-limit-two-buckets
[web] split rate-limit tracking for auto-compiles into two buckets GitOrigin-RevId: dcc743343010afe7d877fe5d37f020f10a8fd412
This commit is contained in:
parent
974f16a4f4
commit
5c06b29e77
2 changed files with 6 additions and 5 deletions
|
@ -228,12 +228,13 @@ module.exports = CompileManager = {
|
|||
if (!isAutoCompile) {
|
||||
return callback(null, true)
|
||||
}
|
||||
Metrics.inc(`auto-compile-${compileGroup}`)
|
||||
const bucket = Math.random() > 0.5 ? 'b-one' : 'b-two'
|
||||
Metrics.inc(`auto-compile-${compileGroup}`, 1, { method: bucket })
|
||||
const opts = {
|
||||
endpointName: 'auto_compile',
|
||||
timeInterval: 20,
|
||||
subjectName: compileGroup,
|
||||
throttle: Settings.rateLimit.autoCompile[compileGroup] || 25,
|
||||
subjectName: `${compileGroup}-${bucket}`,
|
||||
throttle: (Settings.rateLimit.autoCompile[compileGroup] || 25) / 2,
|
||||
}
|
||||
rateLimiter.addCount(opts, function (err, canCompile) {
|
||||
if (err) {
|
||||
|
|
|
@ -443,8 +443,8 @@ describe('CompileManager', function () {
|
|||
return done(err)
|
||||
}
|
||||
const args = this.ratelimiter.addCount.args[0][0]
|
||||
args.throttle.should.equal(25)
|
||||
args.subjectName.should.equal('everyone')
|
||||
args.throttle.should.equal(12.5)
|
||||
args.subjectName.should.be.oneOf(['everyone-b-one', 'everyone-b-two'])
|
||||
args.timeInterval.should.equal(20)
|
||||
args.endpointName.should.equal('auto_compile')
|
||||
canCompile.should.equal(true)
|
||||
|
|
Loading…
Reference in a new issue