make the cap of `activeRateLimitRequests` match the rate limit
It's trivial to have more than 128 requests in flight: open a busy timeline, scroll a bit down, wait for many notes to arrive, scroll to the top. The frontend will send "subscribe to note" messages for each new note that it accumulated, all at once. We don't want to shut down the connection in those common cases!
This commit is contained in:
parent
d03c9f4b62
commit
77144b058c
|
@ -151,7 +151,7 @@ export class StreamingApiServerService {
|
||||||
return this.rateLimitThis(user, requestIp, {
|
return this.rateLimitThis(user, requestIp, {
|
||||||
key: 'wsmessage',
|
key: 'wsmessage',
|
||||||
duration: ms('2sec'),
|
duration: ms('2sec'),
|
||||||
max: 4090,
|
max: 4096,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,9 @@ export default class Connection {
|
||||||
if (this.closingConnection) return;
|
if (this.closingConnection) return;
|
||||||
|
|
||||||
if (this.rateLimiter) {
|
if (this.rateLimiter) {
|
||||||
if (this.activeRateLimitRequests <= 128) {
|
// this 4096 should match the `max` of the `rateLimiter`, see
|
||||||
|
// StreamingApiServerService
|
||||||
|
if (this.activeRateLimitRequests <= 4096) {
|
||||||
this.activeRateLimitRequests++;
|
this.activeRateLimitRequests++;
|
||||||
const shouldRateLimit = await this.rateLimiter();
|
const shouldRateLimit = await this.rateLimiter();
|
||||||
this.activeRateLimitRequests--;
|
this.activeRateLimitRequests--;
|
||||||
|
|
Loading…
Reference in New Issue