Skip to content

Commit 529271f

Browse files
fix: make stats interval and batch connection events configurable (#13)
* fix: make stats interval and batch connection events configurable DEFAULT_INTERVAL was hardcoded to 10s (10000ms), causing all connected clients to send POST /v1/stats every 10 seconds. Changed default to 30s and made it configurable via STATS_INTERVAL_MS env var. This reduces API load by 3x immediately. Also changed BATCH_CONNECTION_REQUESTS default to True so the SDK bundles multiple connection events per request instead of one request per event. Both values are returned to the SDK via the /v1/initialize response. * fix: keep default stats interval at 10s, use env var to override Keep DEFAULT_INTERVAL at 10000ms (original value) to avoid changing existing behavior. DevOps can set STATS_INTERVAL_MS to increase it (e.g. 30000 for 30s) when needed.
1 parent 5aee081 commit 529271f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

api/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@
147147
STATIC_ROOT = '/app/static'
148148

149149
# Other App defaults
150-
DEFAULT_INTERVAL = 10000
150+
DEFAULT_INTERVAL = int(os.getenv('STATS_INTERVAL_MS', 10000))
151151

152-
BATCH_CONNECTION_REQUESTS = False
152+
BATCH_CONNECTION_REQUESTS = os.getenv('BATCH_CONNECTION_REQUESTS', 'True').lower() == 'true'
153153

154154
INIT_TOKEN_SECRET = os.getenv('INIT_TOKEN_SECRET')
155155
SESSION_TOKEN_SECRET = os.getenv('SESSION_TOKEN_SECRET')

0 commit comments

Comments
 (0)