#14 Cache active user count for performance #32

Merged
henry merged 4 commits from cache-active-user-count into main 2025-07-06 00:55:59 +00:00
1 changed files with 15 additions and 8 deletions
Showing only changes of commit 9865e722fd - Show all commits

View File

@ -78,13 +78,19 @@ It is possible for the number of users with access to temporarily exceed the `Ca
Configuration is set in `appsettings.json` or via environment variables. The main configuration section is `AccessQueue`: Configuration is set in `appsettings.json` or via environment variables. The main configuration section is `AccessQueue`:
- **CapacityLimit**: The maximum number of users that can have access at the same time (default: 100). **Required variables:**
- **ActivitySeconds**: How long (in seconds) a user can remain active before being considered inactive (default: 900).
- **ExpirationSeconds**: How long (in seconds) before an access ticket expires (default: 43200). - **CapacityLimit**: The maximum number of users that can have access at the same time.
- **RollingExpiration**: If true, the expiration timer resets on activity (default: true). - **ActivitySeconds**: How long (in seconds) a user can remain active before being considered inactive.
- **CleanupIntervalSeconds**: How often (in seconds) the background cleanup runs to remove expired/inactive users (default: 60). - **ExpirationSeconds**: How long (in seconds) before an access ticket expires.
- **BackupFilePath**: The file path where the access queue state will be periodically saved (no default; optional). - **RollingExpiration**: If true, the expiration timer resets on activity.
- **BackupIntervalSeconds**: How often (in seconds) the state is backed up to disk (no default; optional). - **CleanupIntervalSeconds**: How often (in seconds) the background cleanup runs to remove expired/inactive users.
**Optional variables:**
- **BackupFilePath**: The file path where the access queue state will be periodically saved.
- **BackupIntervalSeconds**: How often (in seconds) the state is backed up to disk.
- **CacheMilliseconds**: How long (in milliseconds) to cache the active user count before recalculating. Lower values mean more frequent recalculation (more accurate, higher CPU usage). Higher values improve performance but may cause a slight delay in recognizing open spots.
Example `appsettings.json`: Example `appsettings.json`:
```json ```json
@ -94,7 +100,8 @@ Example `appsettings.json`:
"ActivitySeconds": 900, "ActivitySeconds": 900,
"ExpirationSeconds": 43200, "ExpirationSeconds": 43200,
"RollingExpiration": true, "RollingExpiration": true,
"CleanupIntervalSeconds": 60 "CleanupIntervalSeconds": 60,
"CacheMilliseconds": 1000
} }
} }
``` ```