Stream Distribution & Routing
Overview
The Stream Distribution & Routing (SDR) consists of two components: Workload Distribution Agent and Workload Routing Agent.
Workload Distribution Agent
It receives stream events initiated by Video Storage Toolkit (VST)
It compiles the workloads and evenly distributes them to underlying microservices by invoking their webhooks
It writes the distribution mapping into a cache
Workload Routing Agent
It intercepts a HTTP or GPRC call from an upstream caller and extract the stream identifier from the request header
It looks up the distribution mapping with the stream identifier
it routes requests to the specific processing replica of a microservice
The rule of thumb is that a microservice should be integrated with SDR if it satisfy both of following criteria:
It needs to notified when a stream event occurs at VST
It is a stateful service that requires the incoming request to be consistently routed to the same processing replica.
Currently the following services are integrated with SDR: Perception (DeepStream).
Configuration
Parameters to the agent can be passed at install time if necessary. Default parameters are sufficient for functioning of the application on a single node.
Parameters |
Description |
---|---|
WDM_WL_SPEC |
Data cache file used for state management |
WDM_WL_THRESHOLD |
Max number of sensor stream a pod can manage |
WDM_CONSUMER_GRP_ID |
Unique consumer group ID used to listen for messages from Redis |
WDM_WL_OBJECT_NAME |
Name of the work load object managed by the agent (statefulset name). |
WDM_MAX_REPLICAS |
Maximum number of replicas that the agent scale the pods horizontally. |
WDM_KFK_BOOTSTRAP_URL |
Kafka Server Endpoint, deployed as part of MDX app chart. |
WDM_MSG_TOPIC |
Topic or key where Redis is publishing the event messages. |
WDM_WL_REDIS_SERVER |
Address of the Redis server |
WDM_WL_REDIS_PORT |
Redis server port number |
WDM_WL_CONFIG_PORT |
REST API Port to send the event message received from VST. |
WDM_WL_ADD_URL |
REST URL end-point to route the “add” event messages |
WDM_WL_DELETE_URL |
REST URL end-point to route the “delete” event messages |
WDM_TARGET_PORT_MAPPING |
A JSON string describing the port mapping to send requests. Eg: {“default”: 8011, “grpc”: 50064} |
ENVOY_ROUTE_URL_PREFIX |
Prefix for the incoming API request for Envoy to do routing |
ENVOY_ROUTE_URL_PREFIX_REWRITE |
Proxy rewrite prefix for envoy to send to target pod in the cluster of pods |
Configure In Helm Chart
The command options configurable by including the following entries in a helm command values file. However this is not mandatory.
# Command.values.yaml
metropolis-wdm:
applicationSpecs:
agent-deployment:
containers:
agent-container:
resources: {}
image:
pullPolicy: IfNotPresent
repository: nvcr.io/nfgnkvuikvjm/mdx-v1_0/wdm-mdx
tag: 0.16.0
workloadSpecs:
workload:
wl_data: |
[
{
"alert_type": "camera_status_change",
"created_at": "2023-05-16T21:50:36Z",
"event": {
"camera_id": "Test_Cam_1",
"camera_name": "<sensor-name>",
"camera_url": "rtsp://<URL_Path:Port>/", #### RTSP URL for the sensor
"change": "camera_streaming"
},
"source": "preload"
}
]
wl_env:
- name: WDM_WL_SPEC
value: /wdm/data/data.yaml
- name: WDM_WL_THRESHOLD
value: "10"
- name: WDM_CONSUMER_GRP_ID
value: wdm-group-1
- name: WDM_KFK_BOOTSTRAP_URL
value: mdx-kafka-cluster-kafka-brokers:9092
- name: WDM_WL_OBJECT_NAME
value: mdx-ds-app ##### Stateful set app name to control using SDR.
- name: WDM_WL_CONFIG_PORT
value: "9000"
- name: WDM_MSG_TOPIC
value: mdx-notification
- name: WDM_WL_PROXY_URL
value: /
- name: WDM_WL_ROUTER
value: ucf-svc-metropolis-wdm-ds-nginx
- name: WDM_WL_ROUTER_CONFIG_MAP
value: wdm-default-nginx
- name: WDM_WL_REDIS_SERVER
value: redis-redis-svc
- name: WDM_WL_REDIS_PORT
value: "6379"
- name: ENVOYROUTEHEADER
value: id
- name: ENVOY_ROUTE_URL_PREFIX_REWRITE
value: /
- name: ENVOY_ROUTE_URL_PREFIX
value: /
- name: WDM_WL_ADD_URL
value: /stream/add
- name: WDM_WL_ID_FIELD
value: camera_id
- name: WDM_WL_DELETE_URL
value: /stream/remove
- name: WDM_EVENT_OBJECT_FIELD
value: event
- name: WDM_MAX_REPLICAS
value: "3"
- name: WDM_TARGET_PORT_MAPPING
value: '{"default": 9000}'
- name: WDM_PRELOAD_WORKLOAD
value: /opt/workload-config/workload
- name: WDM_MSG_KEY
value: sensor
- name: WDM_WL_CHANGE_ID_ADD
value: camera_streaming
- name: WDM_MAP_ADD_FIELD
value: '{"camera_streaming": "camera_add"}'
- name: WDM_REMAP_EVENT_OBJECT
value: '{"event": "value"}'
wl_resources:
limits: {}
requests: {}
wl_units: 1
xds_cluster_address: metropolis-wdm-agent-deployment-agent-xds-service
xds_cluster_port: '4000'