Queries per second (QPS) is a core performance metric that measures how many requests an interface can handle each second. QPS affects the real-time response of your service. This topic explains what QPS is, how to increase your QPS limit, and how QPS relates to different billing methods.
What is QPS?
Queries per second (QPS) is the number of requests or tasks per second. Concurrency is the number of requests or tasks that a system can process at the same time. QPS = Concurrency / Average response time.
For example, the average response time for the 1:1 face comparison feature is 500 ms (0.5 s). If you have a concurrency of 4, the required QPS is 4 / 0.5 = 8. You can adjust the concurrency value in the formula as needed.
QPS limit logic
QPS is the number of calls per second. If you exceed your QPS limit, the excess calls fail and return a throttling error. The error message is similar to the following:
{
"RequestId": "15C865AD-8C45-512F-B4E5-8963DB190181",
"HostId": "facebody.cn-shanghai.aliyuncs.com",
"Code": "Throttling",
"Message": "The call is being throttled. Try again later, or purchase more QPS to increase your call limit",
"Recommend": "https://next.api.aliyun.com/troubleshoot?q=Throttling&product=facebody"
}For example, your QPS limit for a feature is 2, which you can find in the billing rules or on the console. If you make three calls in one second, the first two calls succeed. The third call is throttled and returns the error message shown above. The third call is not billed. Visual Intelligence API bills only for successful calls. The QPS limit applies only to the number of calls within a single second. It does not accumulate from the previous second. If you make two calls in the next second, both calls succeed.
Process to increase your QPS limit
After you activate a Visual Intelligence API feature, a default QPS limit is applied:
If your actual call frequency does not exceed the default QPS limit, your calls are processed normally.
If your actual call frequency exceeds the default QPS limit, calls are throttled and return an error. You can increase your QPS limit by either purchasing a prepaid resource plan or purchasing prepaid QPS.
If the QPS limit provided by your prepaid resource plan is still insufficient, refer to Billing methods to check if the feature supports prepaid QPS:
If it is supported, you can purchase prepaid QPS to further increase your QPS limit.
If it is not supported, contact technical support by joining the Visual Intelligence API consultation group. The DingTalk group ID is 23109592.
If the QPS limit is still insufficient for your business needs after you purchase a subscription plan, you can upgrade your QPS. The current maximum QPS that you can purchase or upgrade to is 50 for Face and Body services, 30 for Image Segmentation, and 100 for Object Detection and Video Production. If the upgraded QPS limit is still insufficient, contact technical support by joining the Visual Intelligence API consultation group. The DingTalk group ID is 23109592.
Relationship between QPS and billing methods
When you use Visual Intelligence API services, most features have a QPS limit. The specific limit depends on the billing method of each feature.
Billing method | QPS details | Billing dimension | QPS limit effective time | Priority |
Pay-as-you-go | If you only activate the service, you can view the default QPS limits for each feature in the pay-as-you-go price list in Billing Details. | Billing is based on dimensions such as the number of calls or the duration of the output video. | Takes effect immediately after you activate the service. Note For the Fingerprint Extraction feature in the Face & Body category, you must purchase QPS after activating the service and passing the review before you can make calls. | If you purchase both a resource plan and prepaid QPS, the deduction order is: Prepaid QPS > Prepaid resource plan > Pay-as-you-go Therefore, when your prepaid QPS expires, the QPS limit automatically changes to the limit of the prepaid resource plan. When the points in your resource plan are depleted or the plan expires, the QPS limit automatically reverts to the pay-as-you-go limit, which is the default QPS limit. You can view the current QPS threshold for each feature on the Visual Intelligence API console. |
Prepaid resource plan | After you purchase a resource plan, you can view the corresponding QPS limits for each feature in the subscription resource plan price list in Billing Details. | After you purchase a resource plan, usage is deducted from the points in your plan. | The QPS limit is increased after 8:00 AM the next day. | |
Prepaid QPS | After you purchase QPS, you can view the corresponding QPS limits for each feature in the subscription QPS price list in Billing Details. | After you purchase prepaid QPS, you are not charged for the number of calls. | Takes effect immediately after you purchase the QPS. |
Case Study
For example, you want to use the 1:1 face comparison (CompareFace) feature. You activated the Face & Body category features on February 18, 2023. You purchased a general-purpose image resource plan on February 20, 2023. You purchased prepaid QPS for 1:1 face comparison at 10 QPS for two days on February 22, 2023. Your QPS limit changes as follows:
Time period | QPS | Description |
February 18, 2023 to 8:00 AM on February 21, 2023 | 2 | This service is billed on a pay-as-you-go basis after activation. |
8:00 AM on February 21, 2023 to February 22, 2023 | 5 | After you purchase the resource plan, the new QPS limit takes effect at 8:00 AM the next day. |
February 22, 2023 to February 24, 2023 | 10 | After you purchase prepaid QPS, the new QPS limit takes effect immediately and is valid for two days. |
From February 25, 2023, until the resource plan is depleted or expires | 5 | When the prepaid QPS expires, the QPS limit automatically reverts to the limit of the resource plan. |
After the resource plan is depleted or expires | 2 | When the resource plan is depleted or expires, the QPS limit automatically reverts to the pay-as-you-go limit. |
References
For answers to frequently asked questions about QPS, see Billing and pricing.