Configure a fallback policy
The PAI-Rec fallback feature automatically activates a fallback policy if the main recommendation pipeline times out or returns an insufficient number of results. This ensures high service availability and prevents empty recommendation results.
Alibaba Cloud PAI-Rec whitebox recommendation product — Fallback feature
1. Overview
To ensure high service availability and a stable user experience, PAI-Rec includes a built-in fallback mechanism.
If the main recommendation pipeline fails to return valid recommendations due to a timeout or an insufficient number of results, the system automatically activates a preset fallback policy. This policy quickly generates alternative results, ensuring that requests always return the expected number of recommendations and preventing empty results or service interruptions.
Note: The fallback feature is deployed in the same service instance as the main recommendation pipeline. It does not rely on external fallback services and has low response latency. This makes it suitable for online recommendation scenarios with strict Service-Level Agreement (SLA) requirements.
2. Scenarios
The fallback feature handles the following two types of exceptions in the main pipeline:
-
Main pipeline execution timeout
For example, during sales promotions, traffic peaks, or sudden increases in model complexity, the time required for the retrieval, filtering, or sorting stages can exceed the configured threshold. This increases the overall response latency. -
Insufficient results from the main pipeline
The main pipeline completes its execution, but the number of items it returns is less than the required amount. For example, if the target is 50 items but only 10 are returned, the user experience is negatively affected.
3. Fallback policy types
PAI-Rec supports two fallback policies. These policies are executed in order of priority until the target number of results is met.
|
Policy type |
Description |
|
Contextual recall |
You can upload a static list of IDs in advance, such as a list of operator-specified products. When a fallback is triggered, the system prioritizes returning content from this list. |
|
Global hot pool |
This policy uses popular items based on site-wide behavior statistics, such as the top-N items by clicks or conversions in the last 7 days. It is used to supplement the results if contextual recall is insufficient. The system randomly samples from a candidate item pool as a final fallback method to ensure the target number of results is met. |
4. Configuration method
You can configure the fallback policy in the Engine Configuration section of the PAI-Rec console. The configuration is in JSON format and supports hot reloading, which allows changes to take effect without restarting the service.
4.1 Configure trigger conditions and data sources
In the engine configuration, you can add the following fields to the scenario configuration to set the fallback trigger conditions and data sources:
{
"SceneConfs": {
"home_feed": {
"default": {
"FallbackConfig": {
"Timeout": 50,
"FeatureStoreName": "fs_pairec",
"FeatureStoreViewName": "global_hot_v1",
"CacheTime": 7200,
"CompleteItemsIfNeed": false
}
}
}
}
}
|
Field name |
Type |
Required |
Description |
|
Timeout |
int |
Yes |
The timeout period in milliseconds. |
|
FeatureStoreName |
string |
Yes |
The name of the FeatureStore data source. |
|
FeatureStoreViewName |
string |
Yes |
The name of the FeatureStore feature view. |
|
CacheTime |
int |
No |
The cache duration for fallback data, in seconds. |
|
CompleteItemsIfNeed |
bool |
No |
Specifies whether to supplement items if the number of results is insufficient. |
4.2 Fallback data sources
-
Contextual recall list: You can upload an item list using the PAI-Rec API and configure ContextItemRecall in the engine configuration. For more information, see Contextual Recall (ContextItemRecall).
-
Global hot data:
-
This data can be automatically generated using the "Customize Recommendation Solution" feature in PAI-Rec.
-
Alternatively, you can build the data and write it to PAI FeatureStore.
-
For more information about configuring a FeatureStore data source, see FeatureStore.
-
5. How it works
PAI-Rec uses a fallback architecture based on parallel execution and result replacement:
-
When a request is received, the main recommendation pipeline and the fallback monitoring logic start at the same time.
-
The system continuously checks if the fallback conditions (timeout or insufficient results) are met.
-
If a condition is met, the system immediately executes the fallback policy to generate a complete set of recommendation results.
-
The main pipeline continues to run until completion for log analysis, but its results are discarded.
-
The final response returned to the client consists of 100% of the results from the fallback pipeline.
6. Monitoring and logging
6.1 Monitoring metrics
PAI-Rec can be integrated with the following monitoring systems:
-
Prometheus
-
Alibaba Cloud ARMS
It provides the following core metric:
-
Number of fallback triggers (pairec_fallback_total)
You can calculate the fallback trigger rate from the number of triggers and the total number of recommendations. PAI-Rec provides a Grafana dashboard configuration to view this rate. For more information, see Configure Prometheus for observability monitoring.
You can configure alerting rules in ARMS to promptly investigate main pipeline exceptions when the trigger rate suddenly increases.
6.2 Service logs
Fallback-related logs contain key fields to facilitate tracking:
requestId=abc123 module=fallback useCache=true cost=1
-
requestId: Associates the main pipeline log with the corresponding fallback log. -
module=fallback: Specifies the fallback module. -
useCache: Indicates whether a cache was hit, such as the hot data cache. -
cost: The execution duration of the fallback logic, in ms.
7. Limits and best practices
Limits
-
The number of fallback results is limited by the size of the underlying item pool. For example, if the hot data pool contains only 1,000 items, a maximum of 1,000 items can be returned.
-
Global hot data must be stored in PAI FeatureStore. Other data sources are not currently supported.
-
Lightweight model fallbacks or complex policy combinations are not supported.
Best practices
-
Regularly update the hot data in FeatureStore to ensure it is current.
-
Before sales promotions, run stress tests on the fallback pipeline to verify its performance and capacity.
-
Use ARMS to monitor the fallback trigger rate and use it as a key indicator of the main pipeline's health.