This is a distributed integration and production reference architecture, not a production-ready HA deployment. The default topology exposes development credentials and includes single points of failure; isolate it from untrusted networks and review the security, persistence, backup, and capacity requirements of every dependency before using real data.
This example is the composition root for the complete distributed OpenRec recommendation chain.
It combines infrastructure from bigdata-platform, service-owned containers from rec-server,
rank-engine, rec-algorithm, and rec-console, the Spark data-processor, OpenRec Airflow DAGs,
sample data, and the Web Demo.
flowchart TB
Client[User · Web Demo · SDK] --> RecServer[rec-server<br/>cluster profile]
subgraph Online[Online recommendation path]
direction TB
RecallDAG[Serving DAG<br/>recall · filter · combine]
RecallDAG --> Rank[rank-engine<br/>model inference]
Rank --> Result[Ranked recommendations]
Result --> Response[Response to caller]
end
subgraph Streaming[Real-time ingestion path]
direction TB
Kafka[(Kafka)]
Kafka --> Processor[Spark data-processor]
end
subgraph Storage[Shared serving and analytical storage]
direction TB
Redis[(Redis<br/>features · behavior · filters)]
Hive[(Hive entity and event tables)]
ES[(Elasticsearch<br/>versioned recall indexes)]
end
subgraph Offline[Daily offline recall path]
direction TB
Airflow[Airflow<br/>bootstrap and daily DAGs] --> Runner[rec-algorithm runner]
Runner -->|spark-submit| Spark[Spark cluster<br/>item and user recall jobs]
Spark -->|prepare and activate| Console[rec-console]
end
RecServer -->|recommend request| RecallDAG
RecServer -->|push API| Kafka
RecallDAG -->|online state| Redis
RecallDAG -->|active recall aliases| ES
Processor -->|online features| Redis
Processor -->|entity and event data| Hive
Hive <-->|read daily partitions · write result tables| Spark
Spark -->|bulk-write staging index| ES
Console -->|create · validate · switch · retain · rollback| ES
The release protocol keeps online serving independent from physical index versions:
sequenceDiagram
participant A as Airflow
participant R as rec-algorithm runner
participant S as Spark recall job
participant C as rec-console
participant E as Elasticsearch
participant O as rec-server
A->>R: Submit one configured daily recall job
R->>S: spark-submit with business date and revision
S->>C: Prepare versioned staging index
C->>E: Create mapping and physical index
S->>E: Bulk-write recall documents
S->>C: Activate with expected document count
C->>E: Refresh and validate count
C->>E: Atomically switch active alias
O->>E: Continue querying the stable active alias
C->>E: Retain active and rollback versions
Each layer has one responsibility:
| Layer | Owner | Responsibility |
|---|---|---|
| Infrastructure | bigdata-platform |
Kafka, HDFS, Hive, Spark, Flink, Redis, Elasticsearch, Airflow |
| Online services | rec-server, rank-engine |
Recommendation and ranking service containers |
| Recall control | rec-console |
Recall index preparation, activation, retention, switching, and rollback |
| Offline jobs | rec-algorithm |
Spark recall computation and staging-index writes |
| Streaming pipeline | data-processor |
Kafka to Redis and Hive-backed storage processing job |
| Business workflow | cluster/airflow |
Bootstrap verification, daily recall publishing, and rollback orchestration |
| Composition | cluster |
Build, initialize, start, verify, and stop the complete example |
The example Compose file uses include; it does not duplicate service build or runtime settings.
Airflow communicates through normal service protocols on openrec-bigdata. It has no Docker socket
and does not manage containers.
Install JDK 21 and set JAVA_HOME or OPENREC_JAVA21_HOME to its installation directory.
All Java source builds and the Web Demo use this JDK; a second JDK is not required.
From the workspace root:
./openrec/cluster/start.shFor a mainland-China development host that cannot reliably reach Docker Hub or PyPI, select the local mirror defaults without exporting variables manually:
./openrec/cluster/start.sh --local--local uses the official pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime serving base
and the Tsinghua PyPI mirror. Offline training retains its separate Aliyun PyTorch 2.8
base because the Spark runner copies /opt/conda, which is absent from the new serving image.
Explicit
RANK_BASE_IMAGE or RANK_PIP_INDEX_URL environment values still take precedence when a different
local registry or package mirror is required.
If the workspace Maven cache contains inaccessible files or directories, startup automatically
uses .cache/maven-repository-<uid>. Set OPENREC_MAVEN_REPO to select another writable cache;
an inaccessible explicit path fails the prerequisite check. On failure, startup preserves application, Airflow scheduler and streaming-job
logs under .runtime/logs/ before removing containers; GitHub CI uploads these logs.
The cluster CI runs functional acceptance with RECOMMEND_DEADLINE_MS=10000 and
OPENREC_GRAPH_NODE_TIMEOUT_MS=1000, because all infrastructure shares the hosted runner.
The latter raises shorter item/user graph node deadlines through the serving-graph API;
it preserves larger deadlines, graph edges, recall configuration and failure policies.
The checks require nonempty recommendations and rank scores. Required recall channels are verified
using successful, nonempty pre-selection recallDiagnostics, not membership in the final top-N.
Normal startup retains the online graph deadlines and the 1000 ms request budget. To reproduce
the CI budgets locally, pass both variables when invoking start.sh --local. --local changes
image/package-source defaults; both modes build workspace source and execute the same DAG. It
does not isolate data, regenerate a valid cached model, or apply CI resource limits. See
CI/local differences for the full comparison.
The bootstrap DAG requests authenticated server-side recommendation warmup, then waits for
/ready before its recommendation smoke task. Warmup has independent request/node budgets and
must be followed by three successful rounds with the deployment's normal budgets. Probes do not
write synthetic exposures. /health remains a liveness check so data import, graph activation and
model preparation can complete while recommendation traffic is blocked with 503. The configured
fixture user also enables automatic warmup after a rec-server container restart.
The command performs the complete cold-start path:
- Builds and starts the
bigdata-platformcluster preset, then runs its infrastructure smoke tests. - Builds the SDK, Spark feature processor, sample loader, and Web Demo in
.runtime/build. - Installs the OpenRec Hive entity tables and submits the Spark streaming processor.
- Loads bootstrap entities and behavior into Redis, plus sample recall aliases and vectors into Elasticsearch.
- Builds and starts
rec-server,rank-engine, the recall runner, andrec-consolecontainers. - Triggers the
openrec_cluster_bootstrapAirflow DAG and waits for success. - Starts the Web Demo only after the complete recommendation chain passes.
The startup-triggered openrec_cluster_bootstrap DAG verifies:
- Kafka, HDFS, Hive, Spark workers, Redis, and Elasticsearch are reachable and ready.
rank-engine, cluster-moderec-server, the recall runner, andrec-consoleare healthy.- Warmup reaches
/ready; a real recommendation has healthy recall-node diagnostics and ranked candidates. - A uniquely named user pushed to
rec-serverreaches Redis through Kafka and the Sparkdata-processor; unique data prevents a previous run from producing a false-positive result.
Run the feature golden comparison after the streaming processor is healthy:
bash openrec/cluster/verify_feature_parity_e2e.shThis publishes the shared fixture directly to the Kafka event topic with deterministic mutation
envelopes and one ordering key per user, then compares Redis user and item snapshots with the
Python golden output. Direct Kafka publication deliberately preserves occurredAt, including the
fixture's out-of-order DELETE/INSERT pair; going through the Push API would replace it with request
arrival time and would not exercise mutation ordering.
The same DAG directory defines openrec_daily_recall for 02:00 UTC,
openrec_daily_user_recall for 02:30 UTC, and the manual openrec_recall_rollback DAG. New DAGs
are paused by default, so enable the required daily DAGs in Airflow when publication should begin.
Bootstrap does not run them: the item DAG submits hot/new/item_cf_i2i/content_i2i/
user_cf_u2i/item_seq_emb/text_search, while the user DAG submits user_cf_u2u/content_u2u and the
internally named user_als_u2u ALS job, which publishes the user-als-u2u serving table consumed
as user_als_u2u, plus text_search with target_type=user publishing user-search.
Item text_search publishes item-search. Both read cumulative partitioned Hive data through rec-algorithm-runner, publish
versioned Elasticsearch indexes, ask rec-console to atomically activate their aliases, and finish
with an online recommendation check.
The ODS entity tables remain immutable daily partitions, while a daily recall run reads every partition through its business date. Events are de-duplicated by trace/event id and retained as cumulative behavior; repeated user and item records are collapsed to their latest as-of snapshot. This preserves cheap partitioned ingestion without incorrectly training recall on only one day.
After the cluster is running, execute the dedicated end-to-end acceptance without lengthening every normal startup:
./openrec/cluster/verify_daily_recall.sh
# Optional reproducible backfill/re-run:
./openrec/cluster/verify_daily_recall.sh 2026-08-21 r002It writes deterministic item/event data through the real Push API, waits for the Hive ODS
partitions, triggers Airflow with an explicit business date and revision, and requires non-empty
hot/item_cf_i2i indexes, exact active aliases, and an online recommendation containing the required recall
channels. The check does not require new; applications own the online supply of newly published
items.
The rec-console DAG module provides the operational UI for Airflow DAG status, pause/enable,
manual triggers, DagRun and TaskInstance state, and task logs. Its item/user tabs maintain separate
version histories and publish cron, ordered algorithm dependencies, default revision, retention,
and retry settings through the shared openrec-dag-config volume. Airflow mounts that
configuration read-only; the Python DAG source remains read-only and arbitrary Python editing is
not exposed in the browser.
The rec-console Serving Graph module reads the active online graph from rec-server, renders its node and edge topology, edits individual node settings, and publishes a complete graph snapshot. rec-server performs the final structural and Java-class validation before atomically applying it; accepted versions are retained by rec-console for rollback.
The manual openrec_rank_model DAG reads cumulative Hive partitions through the requested business
date, removes events for deleted items, prepares samples with a four-core Spark submission, trains
an LR, FM, or LightGBM artifact with the selected global features in rec-algorithm's offline CPU
subprocess, evaluates its held-out AUC gate,
and retains the immutable version. Publication is a separate action in rec-console; the DAG
never changes the online model. scene=global trains from all scenes. openrec_rank_model_rollback reactivates a retained version without retraining.
Run the deterministic two-version acceptance after the cluster is healthy:
bash openrec/cluster/verify_rank_model.sh 2026-08-21The script submits LR and FM training through the console API using distinct feature subsets
and a global scope over two fixture scenes. It stops rank-engine before catalog access and training,
verifies both models finish while inference remains stopped and the active release is unchanged,
then restores inference and explicitly publishes versions and checks fitted sidecars, release metadata and checksums, FM scores returned through the
rec-server online DAG, and rollback to the LR version. Model releases are also visible under the
rec-console Rank Model page. The script also verifies the retired /model/train endpoint
returns 404 and that the rolled-back version survives a rank-engine restart.
Deploy the updated rec-algorithm runner, rec-console and rank-engine together. Catalog endpoints
/features and /features/validate now belong to the runner. Runtime releases live in the shared
model volume, independently of the model/ repository's default artifacts. Compose runs
rank-artifact-init to give Spark ownership of existing release/training directories; it leaves
online activation records unchanged. When using --no-deps, run that init service explicitly.
start.sh --local supplies separate serving and training bases plus the local pip mirror.
Changing RANK_BASE_IMAGE no longer implicitly changes the training base.
Override training builds with RANK_TRAINING_BASE_IMAGE and RANK_TRAINING_PIP_INDEX_URL.
RANK_RUNNER_CPUS=4, RANK_RUNNER_MEMORY=8g and RANK_TRAINING_THREADS=2 bound the offline
runner. Spark distributes sample preparation; current model parameter training remains on the
driver and must fit its memory budget.
Validate the rec-console business-analysis dashboard with isolated deterministic events:
bash openrec/cluster/verify_data_analytics.sh 2026-08-21This checks the real Push → Kafka → Spark → Hive → rec-console path for PV/UV CTR, PV/UV CVR,
active-item count, and GMV (quantity × price).
Startup aborts and cleans up if any phase fails. On success, the main endpoints are:
| Service | URL |
|---|---|
| Web Demo | http://127.0.0.1:12345 |
| rec-server | http://127.0.0.1:13579 |
| rank-engine | http://127.0.0.1:8123 |
| rec-console | http://<host>:8095 |
| rec-console API | http://<host>:8095/docs |
| Airflow | http://127.0.0.1:8091 |
| Spark | http://127.0.0.1:8083 |
| Flink | http://127.0.0.1:8087 |
Stop everything owned by this cluster example while retaining Docker volumes:
./openrec/cluster/stop.shStop the business applications and streaming job while keeping the infrastructure running for a faster restart:
./openrec/cluster/stop.sh --keep-platformOnly an explicit platform volume deletion removes persisted data:
./bigdata-platform/platform.sh down -vThe cluster stop command does not touch standalone processes or containers.
| Concern | standalone | cluster |
|---|---|---|
| Infrastructure preset | Redis and Elasticsearch | Complete distributed platform |
| Push path | rec-server writes Redis directly | rec-server publishes to Kafka |
| Processing | Not required | Spark data-processor writes Redis and Hive-backed storage |
| Ranking service | Disabled | rank-engine container |
| Airflow workflow | Not required | Bootstrap, daily recall, model release, and rollback DAGs |
| Default artifact bootstrap | Hash-validated model/ reuse or rebuild |
Same validated bootstrap bundle; runtime releases are separate and do not overwrite repository defaults |
| Recall publishing | model/recall import |
Spark staging writes with rec-console version control |
| rec-server profile | standalone |
cluster |
| Exposure collection | Synthetic exposure enabled | Synthetic exposure disabled; browser reports cards visible at least 50% through Push API |
Both examples use the same rec-server image, serving DAG, Redis/Elasticsearch schema, sample loader, and Web Demo. Runtime configuration selects the deployment behavior.
Inspect each ownership layer independently:
./bigdata-platform/platform.sh ps
./bigdata-platform/platform.sh logs airflow-api-server spark-master kafka-1
docker compose -f openrec/cluster/docker-compose.yml ps
docker compose -f openrec/cluster/docker-compose.yml logs rec-server rank-engine rec-algorithm-runner rec-console
docker exec spark-master cat /tmp/openrec-data-processor.logApplication build output, Web Demo logs, and PID state are isolated under
openrec/cluster/.runtime/. Airflow DAG source remains under
openrec/cluster/airflow/dags/ and is mounted read-only by the platform.
See the distribution architecture for feature/model ownership and publication boundaries, and CI for acceptance coverage.
Optional semantic recall: configure the local model mount and GPU as described in
the vLLM infrastructure guide, then export
EMBEDDING_ENABLED=true before starting this profile. Startup verifies online/offline
embedding compatibility and initializes item_title_emb.csv into the Qwen aliases.
Default startup does not require vLLM or GPU. Graph overrides from previous deployments
need the new query timeout/configuration. Direct component Compose deployments must
initialize candidate vectors separately before enabling online query embeddings.
openrec_daily_recall (02:00 UTC) excludes query_title_emb by default and builds
the CPU recall tables. openrec_daily_user_recall (02:30 UTC) covers all four user-graph tables.
Title generation uses the cumulative item snapshot and the shared vLLM service; deploy
with EMBEDDING_ENABLED=true and the model mount/GPU settings documented in
the vLLM component. The runner, rec-server and
rec-console must use the same embedding model/dimensions.
Cluster and GitHub CI disable online query encoding and scheduled title generation by
default because vLLM requires GPU resources and Qwen model weights, which are costly
to provision on GitHub runners. BM25 item_search / user_search remains available.
On a local GPU host, configure the vLLM model mount, provide matching title vectors,
set EMBEDDING_ENABLED=true, and start cluster. To also refresh title vectors daily,
add query_title_emb to openrec_daily_recall in rec-console and publish that config.
Previously published configs are preserved; remove query_title_emb from those lists
when migrating an existing installation to CPU-only operation.
The title index is global: query-title-emb-index. rec-console manages its versioned
staging indexes, activation and rollback (algorithm=query-title-emb). Scheduled releases
and optional CSV bootstrap share this alias; bootstrap detaches the actual prior index
before adding its replacement. Airflow checks the active release and positive successful
recall diagnostics, rather than demanding that every channel appear in final Top-N.
Rebuild rec-algorithm and rec-console with these companion changes and load the updated
DAG templates. Existing custom/published DAG configs retain their explicit algorithm lists;
add query_title_emb through the console and publish a new configuration version to enable
it there. A disabled embedding provider or failed generation is a task failure, not a
successful empty release. No changes to user-event ingestion are included in these jobs.
Default artifact initialization uses the CPU bundle (v19) and requires no Qwen
weights or transformers. Existing verified item_title_emb.csv is preserved during
rebuilds. To enable query embedding, provide matching precomputed title vectors
and the inference service; the default bootstrap does not generate language vectors.
Both modes accept OPENREC_DATA_DIR and OPENREC_MODEL_ROOT. Missing or stale
model bundles are rebuilt from raw CSVs before import. Mode-specific initialization
lives in each mode’s init.sh, with a shared Java storage loader. See
initialization inputs, reuse rules, and existing-data behavior.