Quota Usage

Quota Usage is the mechanism our platform uses to measure and enforce resource limits across brand and users. It ensures fair usage, prevents abuse, and provides transparency for both system administrators and clients.

A quota represents a limit on a specific resource (such as API requests, storage, or number of users). The usage represents how much of that quota has already been consumed in the current period.


Key Concepts

  • Quota The maximum amount of a resource that a tenant or user is allowed to consume during a period (e.g., 50,000 API requests per month).

  • Usage The amount of resource already consumed by a tenant or user in the current period.

  • Period The timeframe in which the quota is measured (e.g., daily, monthly, yearly, or lifetime). Periods automatically reset according to the subscription plan.

  • Reset Policy Defines how often a quota resets. For example:

    • Daily

    • Monthly

    • Yearly

    • Lifetime (never resets)

    • Custom (e.g., every 45 days)


Example Scenarios

  1. API Requests

    • Plan: Essentials

    • Limit: 50,000 requests / month

    • If a brand makes 40,000 requests in September, they have 10,000 remaining until their quota resets in October.

  2. Active Users

    • Plan: Pro

    • Limit: 1,000 users / month

    • If the brand creates 900 users in the current month, they can still add 100 more before reaching the limit.

  3. Storage

    • Plan: Free

    • Limit: 10 GB / month

    • If the brand uploads files totaling 9 GB, only 1 GB remains available until reset.


How It Works

  1. Every time a resource is consumed (e.g., an API request is made or a file is uploaded), the platform records a tracking event.

  2. This event increments the usage count for the corresponding quota.

  3. Before consuming resources, the system checks the quota to ensure the action does not exceed the allowed limit.

  4. If the quota is exceeded, the system blocks the request and returns a Quota Exceeded error.


Error Handling

If a tenant exceeds their quota, the API will return a standard error response:

{
  "error": {
    "code": "QuotaExceeded",
    "message": "Action cannot be completed because the quota has been exceeded."
  }
}

For Developers

  • Quota Service A centralized service (IQuotaService) provides APIs to:

    • Check quota availability

    • Consume quota when an action succeeds

    • Retrieve current usage for dashboards

  • Storage Quotas are cached in Redis for fast checks. A nightly job reconciles data with SQL Server for long-term accuracy and reporting.

  • Extensibility New resources (e.g., custom_brands, projects) can be added easily by extending the quota definitions in the database and configuration.


For Clients

  • Transparency: You can always see how much of your quota has been used via the dashboard.

  • Fairness: Quotas reset according to your subscription period, ensuring you get what you pay for.

  • Scalability: If your business grows and you need more resources, simply upgrade to a higher plan.

References

Reset Policy

Last updated

Was this helpful?