Improve efficiency for large capacities #14

Open
opened 2025-05-16 00:00:53 +00:00 by henry · 1 comment
Owner

The service can easily handle thousands of users in the queue, but it starts to crawl when the capacity limit is high and there are many active users with access. This is because there is an expensive iteration done every time an access request is made:

var numberOfActiveUsers = _accessTickets.Count(t => t.Value.ExpiresOn > now && t.Value.LastActive > activeCutoff);

numberOfActiveUsers could either be cached so not every request iterates on the array, or it could be done periodically in the backgorund.

The service can easily handle thousands of users in the queue, but it starts to crawl when the capacity limit is high and there are many active users with access. This is because there is an expensive iteration done every time an access request is made: `var numberOfActiveUsers = _accessTickets.Count(t => t.Value.ExpiresOn > now && t.Value.LastActive > activeCutoff);` `numberOfActiveUsers` could either be cached so not every request iterates on the array, or it could be done periodically in the backgorund.
henry added the
enhancement
label 2025-05-16 00:00:53 +00:00
Author
Owner

As far as I can tell, all individual actions taken have O(1) complexity except for this step in requesting access. If this is resolved the overall complexity for requesting access with drop to O(1)

As far as I can tell, all individual actions taken have O(1) complexity except for this step in requesting access. If this is resolved the overall complexity for requesting access with drop to O(1)
Sign in to join this conversation.
No Label
bug
enhancement
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: henry/AccessQueueService#14
No description provided.