The recommendation system is an information filtering system that is used to predict user preferences and filter out content that the user may be interested in from a large amount of information to make personalized recommendations. A complete recommendation system process mainly includes processing nodes such as multi-channel recall -> material completion -> fine sorting and filtering -> mixed sorting -> adaptation output. As the last layer of processing before result output, shuffling is mainly used to normalize and sort the recommendation results from different sources. On the one hand, it is to obtain the sorting sequence with the best recommendation effect for users, and on the other hand, it can also improve Diversity, personalization and reach of recommendations.

▐Existing link
Taobao information flow is a typical recommendation system. In the information flow, there are many types of business cards, such as products, advertisements, cloud themes, short videos, live broadcasts, etc. We will divide business cards into two categories: advertising results and natural recommendation results. In the sorting stage, two serial processing modules will be divided into two different types of results to mix and sort.

-
Advertising results : Advertising mainly adopts a dynamic pit display strategy. By calling the dynamic display service provided by advertising, it decides which pits to display advertisements, which advertising results are specifically displayed and the corresponding advertising billing. The decision-making goal is optimal commercialization. value. When making decisions, all recommended candidate sets will be input as contextual features, but the order of natural results will not be decided. -
Natural results : The process of rearranging natural results does not use the advertising candidate set as contextual features to make decisions. Similarly, it does not make additional decisions on the ranking of advertising candidate sets. It only rearranges within the natural results. , to obtain the sorting sequence of optimal user value.
▐There is a problem
-
The algorithm strategies have inconsistent goals and cannot obtain the global optimal results : the advertising display strategy is more based on commercial value, and less consideration is given to the user value of natural results, although the replacement of indicators can be achieved by adjusting the tradeoff coefficient between the two. , but obviously it cannot obtain a globally optimal sequence result. -
There is a high coupling between algorithm strategy iteration and business logic iteration : in the current link, algorithm students need to jointly develop the same set of code with engineering students. At the same time, the various policy modules involved are scattered in different stages of the pipeline, such as The advertising ecpm value service that the advertising dynamic targeting service relies on will be called during the completion phase, while the actual dynamic targeting results will be processed during mixed scheduling, resulting in higher complexity of the overall system and higher stability maintenance costs.
▐Solution _
-
Adjustment of the shuffle strategy goal : The shuffle service must comprehensively consider user value and commercial value, and maximize the overall value of the page as the shuffle strategy goal. Decoupling strategy and business : extracting the mixing strategy logic from the server-side business link and connecting it as an independent service. Later iterative upgrades will be maintained by algorithm colleagues in the new service, and the algorithm’s strategy will be iterated It is independent from the business iteration of the engineering link, making the division of labor in development clearer and reducing corresponding maintenance costs.
Specific implementation plan
▐Technical selection
This new hybrid fusion service chooses xrec as the code framework. xrec is a business framework based on tpp graphical engine. The framework mainly includes the following advantages:
Recommended componentization of business processes : The xrec framework can abstract the business nodes of the link into components. Developers only need to implement the business of each node according to the component implementation specifications agreed by the framework, and pass a fixed format json file When arranging processes, there is no need to consider the orchestration of business processes at the code level.
Fully asynchronous concurrency performance optimization : Different from the streamlined execution process of the TPE framework used in the original engineering link, the xrec framework improves scene performance by automating multi-channel concurrency and encapsulating data operations, and uses a graphical structure to describe the business process, so that users do not need to By learning concurrent programming, you can achieve large-scale and safe concurrency. At the same time, data serialization/deserialization, data conversion, and common external service calls are encapsulated into operator operations for use, and performance-optimized platform modules are used to replace unused Performance-polished user code.
The xrec framework saves algorithm developers a lot of work, but it also imposes more constraints on coding rules. The development process needs to be carried out strictly in accordance with the rules of the framework.
▐Link scheme
Mixed service link solution
Based on the xrec framework, we built an independent TPP service (xhuffle) to undertake the integrated shuffling strategy logic of all advertising & natural results. The overall link of the service is as follows. The xhuffle service internally calls the advertising ecpm value estimation service and the recommended unified value model in parallel to obtain the value information of advertising & natural results. The fusion mixing mechanism module will summarize the advertising & natural results value information and make decisions on the sorting results of all cards. , given the pit position of the card or reordering the cards, and finally calling the advertising billing service to obtain advertising billing information for the advertising results.
-
In the original engineering link, the service modules that are mixed and dependent are scattered in different stages of the pipeline. After creating a new service, the relevant logic of mixing and sorting is integrated into an independent service, and it can be iterated separately in the new service, greatly reducing development and maintenance costs. -
The recommendation unified value model and advertising ecpm estimation service are maintained by recommendation and advertising respectively, and each is responsible for obtaining recommendation value points and advertising value points. -
The integrated mixing mechanism module is jointly maintained and iterated by the advertising and recommendation sides. -
The advertising billing service is maintained by the advertising side. By calling the advertising EADS service, the generation of advertising billing strings is converged within the advertising service to ensure information security.

In addition, since there are still some business targeting strategies in the post-acquisition information flow, such as cloud themes, short video targeting, etc., this part of the strategy was not considered in the original mixed arrangement strategy. As for the share of business targeting, The shuffling strategy may still determine the pit positions, which will cause these business pit cards to interfere with the shuffling results, directly affecting business data indicators. In the xhuffle service, we provide this part of the business pit information as a service input to the shuffling module, and proactively avoid this part of the pit, ensuring that the mixing results and the business pit results do not interfere with each other.
Engineering link service calling plan
Option 1: Split the sorting phase and call services in parallel
-
Pre-sorting stage : This stage mainly performs some pre-sorting card filtering. After obtaining the pre-filtered card sequence, initiate parallel calls to the shuffle service and other external services of the engineering link. -
Post-sorting stage : In this stage, the card sequence will be sorted and truncated based on the shuffling results to determine the final card sequence that needs to be adapted for output.

方案二:串行调用服务

这种调用方式对链路的RT压力会更大,由于是串行执行,服务调用的耗时会直接体现到整体链路耗时上。为了缓解RT的压力,我们采取了以下两个方面的措施:
xhuffle服务本身的链路优化。混排服务中耗时占比最大的是推荐统一价值模型的调用,在最初的方案中是通过调用外部tpp服务进行处理,目前已优化为在服务中直接进行RTP调用来处理,同时调用所需的qinfo数据直接使用商品召回的缓存数据,不用重新生成。
购后工程链路在不影响用户体验的前提下,适当放宽超时限制,以此降低端上的超时率。目前,各场景均将场景超时限制放宽50ms。
两种方案对比
优点 |
缺点 |
并行调用对链路整体的RT影响较小 |
将工程链路其他处理前置,会带来下游服务承接的卡片数量增长三至四倍,带来冗余的资源消耗 |
链路改造成本小,无冗余资源消耗 |
服务耗时会直接体现在链路整体耗时上,对系统稳定性的压力更大 |
经过综合考虑后,我们认为方案一带来的冗余资源消耗是不可接受的,最终选择了方案二作为正式的链路改造方案。

▐ 链路稳定性结果
-
混排服务场景指标:入口场景的服务调用平均RT保持在30ms以内,P99保持在70ms以内。服务调用超时率稳定在0.5%以内。 -
入口场景整体的系统稳定性指标:链路整体耗时可控,整体超时率保持在0.3%以内。 -
端上用户体验指标:由于各场景均扩了超时RT限制,我们通过端上接口的耗时变化来反映对用户体感上的影响。从扩RT前后分端接口耗时来看,用户体感上没有明显的变化。
▐ 未来展望
-
短视频、直播等业务的混排策略升级,减少业务定坑对混排的约束。 -
类目打散等规则化策略的融入。 -
建设通用化的混排服务链路接入方案,以同一套方案为更多场景提供混排策略服务。

这里有巨大的流量,可以满足你对高并发大规模分布式系统练手的畅想;
这里有前沿的算法应用场景,可以玩转各种智能创新;
这里有严苛的系统指标要求,可以让你感受到优化复杂系统化的快感~
本文分享自微信公众号 - 大淘宝技术(AlibabaMTT)。
如有侵权,请联系 [email protected] 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。