Home
Tech
Architecture
Frontend Logics
Variables
Max concurrent processes per concurrency partition (Frontend-Logics)
Variable name : max_concurrent_processes_per_concurrency_partition
Purpose : Limits how many tasks can run in parallel within a concurrency partition. Frontend-Logics computes/updates this when users edit rate limits and when persisting scheduler rows.
Where it comes from
Frontend-Logics should always derive the value using the shared helper from stacksync_utils:
calculate_max_concurrent_processes_per_concurrency_partition_from_app_schema(app_schema)
Implementation lives in: python-utils-3/stacksync_utils/configurations/max_concurrent_processes_per_concurrency_partition.py
Formula inside helper: max(1, rate_limit // (2 * frequency))
Where it is used/updated in Frontend-Logics
When updating an app’s rate limit, Frontend-Logics recomputes and updates existing scheduler rows for that app’s partition.
Reference: frontend-logics/endpoints/common/bases.py
Note: At persistence time we often ensure a minimum of 2 processes (GREATEST(2, ...)) to avoid starvation, but the helper itself returns >=1.
How to use it (DO this)
Always call the helper with app_schema:
calculate_max_concurrent_processes_per_concurrency_partition_from_app_schema(app_schema)
Do not reimplement the formula or use ad-hoc rate/2 logic.
max_concurrent_processes_per_connection: separate connection-scoped cap enforced by the scheduler.