BehaviR: Mobile‑Side Real‑Time Stream Processing Framework
BehaviR is a mobile‑side real‑time stream processing framework that gathers page actions, network requests, and storage events via JSON configuration, runs stateful computations on a lightweight Python‑based engine using a DSL, and instantly triggers decisions and routes results with millisecond latency and no server load.
Background: With increasingly powerful mobile networks, users spend only seconds in an app, making it hard to provide valuable services. Xianyu built a flow‑control system and this article introduces the client‑side real‑time processing framework.
What the framework does: It handles user‑behavior streams, supplies high‑quality data, performs stateful real‑time computation, makes decisions and triggers user outreach. The overall architecture is illustrated in the original diagram.
Data supply: BehaviR’s data module collects page actions, network requests, storage operations, and persists them according to a JSON configuration, e.g.:
{
"actionTypeIn":["leave"],
"sceneIn":[
"https://market.m.taobao.com/app/idleFish-F2e/idlefish-renting/home",
"https://market.wapa.taobao.com/app/idleFish-F2e/idlefish-renting/home"
],
"taskArray":[
{
"taskType":"py_backtrace",
"pythonName":"test_cep_rent_rule2",
"filter":[
{"alias":"e1","actionType":"leave"},
{"alias":"e2","actionType":"pv"}
]
}
]
}Computation: The client adopts a lightweight, Python‑based engine (Walle) to execute stateful stream calculations. Triggers are defined by "actionType" values; when a trigger matches, data is fed to the engine.
Implementation choice: Python was selected for rapid prototyping and because the internal Walle runtime is stable. Developers describe logic via a Python DSL, which is compiled into a computation graph.
Pattern('e1') \
.where(KVCondition('actionType','pv')) \
.and(KVCondition('scene','item_detail')) \
.followby('e2') \
.where(KVCondition('actionType','leave')) \
.and(KVCondition('scene','item_detail'))The same logic can be expressed in the standard DSL:
EVENT: e1->e2
WHERE e1.extra_info.actionType = 'pv'
AND e1.extra_info.scene = 'item_detail'
AND e2.extra_info.actionType = 'leave'
AND e2.extra_info.scene = 'item_detail'Output: After computation, results are routed to three channels – business rights delivery, model input, and downstream computation – using a unified protocol and a decision‑distribution module.
Effect and outlook: The first version runs on Xianyu with millisecond latency and zero server load. Future work includes handling process termination, out‑of‑order events, and more complex aggregations.
Xianyu Technology
Official account of the Xianyu technology team
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.