MATIH Platform is in active MVP development. Documentation reflects current implementation status.
8. Platform Services
Quotas

Quotas

The QuotaController and QuotaManagementService enforce resource quotas for tenants. Quotas define upper limits for compute, storage, API, ML/AI, and other resource categories. Quotas can be enforced as hard limits (rejecting requests when exceeded) or soft limits (warning only).


Resource Types

Compute

Resource TypeDescription
CPU_CORESCPU core allocation
MEMORY_GBMemory allocation in GB
GPU_UNITSGPU unit allocation

Storage

Resource TypeDescription
STORAGE_GBPrimary data storage
OBJECT_STORAGE_GBObject/blob storage

Data

Resource TypeDescription
DATA_TRANSFER_GBNetwork data transfer
QUERY_EXECUTIONSQuery execution count
ROWS_SCANNEDNumber of rows scanned

API

Resource TypeDescription
API_CALLSTotal API call count
CONCURRENT_CONNECTIONSSimultaneous connections

ML/AI

Resource TypeDescription
ML_TRAINING_HOURSML model training time
ML_INFERENCE_REQUESTSML inference request count
AI_TOKENSAI/LLM token consumption

Pipeline and BI

Resource TypeDescription
PIPELINE_RUNSData pipeline execution count
CONNECTOR_SYNCSData connector sync count
DASHBOARD_COUNTNumber of dashboards
REPORT_EXECUTIONSReport generation count
ACTIVE_USERSConcurrent active users

ResourceQuota Entity

FieldTypeDescription
idUUIDQuota identifier
tenantIdUUIDOwning tenant
resourceTypeResourceTypeType of resource being limited
resourceNameStringHuman-readable resource name
quotaLimitBigDecimalMaximum allowed usage
currentUsageBigDecimalCurrent usage level
unitStringUnit of measurement
warningThresholdPercentBigDecimalWarning at this utilization percentage (default: 80%)
enforceHardLimitbooleanReject requests when over quota (default: true)
alertRecipientsJSONList of email addresses for alerts
isActivebooleanWhether the quota is enforced

Quota Endpoints

Create Quota

Endpoint: POST /api/v1/billing/quotas

curl -X POST http://localhost:8087/api/v1/billing/quotas \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "tenantId": "550e8400-e29b-41d4-a716-446655440000",
    "resourceType": "API_CALLS",
    "resourceName": "Monthly API Call Limit",
    "quotaLimit": 1000000,
    "unit": "count",
    "warningThresholdPercent": 80,
    "enforceHardLimit": true,
    "alertRecipients": ["admin@acme.com"]
  }'

Check Quota

Endpoint: GET /api/v1/billing/quotas/tenants/:tenantId/check

Returns the utilization status for all quotas:

  • getUtilizationPercent() -- current usage as a percentage of the limit
  • isOverQuota() -- whether current usage exceeds the limit
  • isWarningThresholdExceeded() -- whether the warning threshold has been reached

List Tenant Quotas

Endpoint: GET /api/v1/billing/quotas/tenants/:tenantId

Update Quota

Endpoint: PUT /api/v1/billing/quotas/:quotaId

Delete Quota

Endpoint: DELETE /api/v1/billing/quotas/:quotaId


Enforcement Behavior

ModeBehavior
Hard limit (enforceHardLimit: true)Requests that would exceed the quota are rejected with 429 Too Many Requests
Soft limit (enforceHardLimit: false)Requests are allowed but alerts are generated when thresholds are exceeded

When utilization reaches the warningThresholdPercent, alert notifications are sent to the configured recipients. Default warning threshold is 80%.