Skip to main content

Workers Architecture

Background workers for asynchronous processing in the self-hosted social network stack.
Scheduled (cron) jobs: Scheduled Jobs.

Bus summary (current)​

Bus / modeWorkers
KafkaInteractionWorker, ScoringWorker, TrendingWorker, GraphWorker, HashtagWorker, ElasticsearchSyncWorker
RabbitMQWebSocketWorker, ChatWorker (also hosts SignalR), WebPushNotificationWorker, ExpoPushNotificationWorker, BlogAutoGenerationWorker, ContentModerationWorker
Polling (PostgreSQL)MediaProcessingWorker (pending MediaFile rows — not Kafka)
Common mistake

Do not list MediaProcessingWorker or WebSocketWorker as Kafka consumers. Media polls Postgres; WebSocketWorker consumes RabbitMQ and hosts SignalR notification hubs.

Kafka workers​

Consume topics such as user_interacted, content_created, content_updated, content_deleted:

WorkerPurpose
InteractionWorkerInteraction summaries + Redis counts
ScoringWorkerPersonalized content scores (feed ranking)
TrendingWorkerGlobal trends + Redis cache
GraphWorkerNeo4j relationship weights / suggestions
HashtagWorkerHashtag extract, counts, trends
ElasticsearchSyncWorkerKeep search indexes in sync

Flow: API publishes event → Kafka topic → worker → PostgreSQL / Neo4j / Elasticsearch / Redis.

RabbitMQ workers​

WorkerPurpose
ChatWorkerSignalR /hubs/chat, /hubs/chat-online; chat delivery; publishes call push messages
WebSocketWorkerSignalR /hubs/notification, /hubs/onlineusers; friendship/notification consumers
WebPushNotificationWorkerBrowser Web Push (VAPID)
ExpoPushNotificationWorkerMobile Expo Push
BlogAutoGenerationWorkerAI blog generation (+ Quartz schedule)
ContentModerationWorkerOpenAI GPT text + vision → hide/reject harmful posts & stories; Content Alerts

MediaProcessingWorker​

  1. API creates MediaFile with status Pending and stores original in temp object storage
  2. Worker polls pending rows
  3. Processes with ImageSharp / FFmpeg
  4. Writes public assets to MinIO/R2, updates DB, caches URLs

See Media.

SignalR hosting​

Hub pathsHost process
/hubs/chat, /hubs/chat-onlineChatWorker
/hubs/notification, /hubs/onlineusersWebSocketWorker

The main API does not host these hubs. Traefik (or Nginx) must route hub paths to the correct worker. See Deployment and Traefik checklist.

Shared foundation​

Workers reuse SharedWorker (config, health, Kafka helpers, JWT for worker→API calls).