Skip to main content

Background work

A write to Vox commits the entity together with the work it causes. When an editor changes a product's price, the save returns at once, and the processing hosts then recalculate what depends on the price, publish the results, raise events for subscribers, update the search index and publish the changed projections. This page explains how that work runs, so you can size the processing hosts, read their health and know what a failure costs.

What runs​

Two kinds of background work run on the processing hosts of the active deployment:

  • Vox's own loops: the processing of changes (calculations, memberships and cached references, and publishing the entities that settle), the model migrations, change events and subscription deliveries, side effects, assessments, search indexing, scheduled publications, retention and cleanups. They aren't Nexus jobs.
  • Nexus jobs: imports and projection publications, the integrations that operators watch and control in the Nexus admin.

The model migrations are the one exception to "active deployment only": they start as soon as a processing host starts, also on a new deployment in standby, see model evolution.

How fast work starts​

After a commit, the host that wrote wakes the loops that have new work on every processing host, over instance events. A loop starts its next round at once while it has work, so a change travels through calculations that depend on each other, and on to events and the search index, without waiting for any schedule.

A wakeup is best effort, eg it's lost if every processing host is down when it's sent, and a save that committed is reported as committed even if waking the loops failed: the committed work is the durable record. So each loop also checks for work every 30 seconds when nothing woke it (Processing.IdleCheckInterval), and work that's due at a time, eg a scheduled publication, wakes its loop when it's due.

An import's job starts when the import is committed to its queue. A projection publication's incremental job is requested when there are sources to publish, and also runs every 30 seconds as a fallback (OutboxJobSchedule), since Nexus doesn't guarantee an immediate start.

How the work spreads over hosts​

Adding processing hosts makes broad work faster. When a pricing policy changes for a million products, every processing host takes a share:

  • Shared work. The processing of changes, change events, side effects, assessments, search indexing and subscription deliveries run on every processing host at the same time. Each host claims a batch, eg 500 entities to recalculate or to index (Processing.EntityBatchSize), and completes it when it's done. Two hosts never work on the same entity at once, and the changes of one entity still reach a subscriber in order.
  • One host at a time. Scheduled publications, retention and cleanups, filling the storage of new query fields, subscription synchronization, the search index backfill and the context manifest publication don't need several hosts. One host holds a lease on each, and another takes it over when that host stops. Periodic work records when it last ran, so a host that starts doesn't run it again straight away.

A host that crashes loses nothing. Its claims and leases expire after 2 minutes (Processing.LeaseDuration), and the other hosts take the work over. Work is done at least once: a batch that a host was in the middle of is done again, so the application's own side effects must be idempotent.

Failures and retries​

Nothing that a loop does stops the application or the loop. A failure is taken to be temporary, eg a deadlock or a dropped connection, and is retried, unless it's known to be permanent, eg a failed validation or a version conflict.

  • When nothing works, eg the database can't be reached or the search engine is down, the loop waits with a growing delay, up to a minute, and tries a small batch. Once one succeeds it continues at full speed and catches up, without a restart. Work that waited through an outage doesn't use up any of its retries.
  • When some items fail, only those are retried later, and the rest continue. A product whose search document the search engine rejects doesn't hold back the indexing of the other products.

There's nothing to pause or resume: the loops back off on their own while a dependency is down, and continue on their own once it's back.

Where a failure that is given up on ends up depends on the work:

  • a failed calculation is one of the entity's assessments;
  • a failed assessment evaluation is the assessment's Error state;
  • a given-up subscription delivery is in the subscription's delivery log, see events;
  • a scheduled publish that can't be published is marked failed on its draft, see drafts and publishing.

Everything else, eg an entity that the search engine keeps rejecting, is retried until it succeeds and shows in the loop's health check meanwhile.

Monitoring​

The Nexus admin shows Vox's integrations as jobs, with their logs, schedules, run history, pausing and manual runs:

  • Imports: a queue and a queue job per import type. Nexus runs a queue's job on one host at a time and processes its imports in the order they arrived. Different import types run in parallel, also of the same entity type, eg a price import and a stock import of products, see importing data.
  • Projection publications: an incremental and a full job per publication, eg "Product/product-feed incremental" and "Product/product-feed full", which never overlap, also across hosts. See entity projections.

Vox's own loops can't be paused or started there, but each reports a Nexus health check, which the Nexus admin shows:

  • Healthy while the loop keeps up with its work.
  • Degraded while its rounds keep failing, items fail and wait for a retry, or it has work without making progress.
  • Unhealthy when the loop has stopped running when it should.

Its message says what's wrong, eg how many entities fail to be indexed, with the errors of a few of them in its data. A loop that the application doesn't use, eg search indexing without a search index, reports that it isn't used. The health checks are listed at the end of this page.

For the progress of large waves of work, eg a recalculation after a model change, see large catalogs.

Tuning a processing host​

Workers. Within a host, the processing evaluates independent entities on parallel workers. Processing.MaxDegreeOfParallelism bounds them across all of the host's background work together, and defaults to half the machine's cores, at least one. Raise it on a dedicated processing host. Lower it on a combined API and processing host whose requests must stay fast, or set SerialProcessing to process one entity at a time. A worker count doesn't guarantee CPU headroom: a CPU-heavy calculation still occupies a core per worker, so measure a combined host under load before raising it.

Concurrent runs. The processing of changes works in runs: dispatch the changes, claim a batch, evaluate it, publish it, then claim the next. Processing.ConcurrentRuns, 2 by default, sets how many runs a host keeps going at once, so one batch is evaluated while another is published. More runs overlap waits for the database rather than use more cores, and each uses a database connection of its own. They help broad work with many batches, eg recalculating 10,000 products, where a second run roughly halves the time; beyond 2 the database is usually the limit, especially on SQL Server. Small waves of work gain nothing.

SettingDefault
Processing.MaxDegreeOfParallelismhalf the coresThe workers of the host's background work together
Processing.ConcurrentRuns2Runs of the processing of changes that a host keeps going at once
Processing.EntityBatchSize500The most entities a host claims at once
Processing.IdleCheckInterval30 sHow often each loop checks for work when nothing woke it
Processing.LeaseDuration2 minHow long a stopped host's claims and leases are kept before others take the work over
Processing.MaxEvaluationAge10 minThe longest an evaluation may take before it's evaluated again
SerialProcessingfalseOne entity at a time, one run
OutboxJobScheduleevery 30 sThe fallback schedule of the projection publications' incremental jobs, as a cron schedule

Health checks​

Health checkRuns onWork
vox_change_processingevery processing hostCalculations, memberships and cached references, and publishing the entities that settle
vox_model_migrationsevery processing hostThe steps of applied model migrations
vox_entity_eventsevery processing hostTurning published changes into events and handing them to the subscriptions
vox_side_effect_deliveriesevery processing hostIVoxEntityUpdateSideEffect deliveries
vox_assessment_evaluationevery processing hostEvaluating assessments, also their reassessments
vox_assessment_expiriesevery processing hostAssessment results whose validity ended
vox_accumulator_expiriesevery processing hostReleasing the holds of Accumulators whose expiry has passed, see limits and reservations
vox_search_indexingevery processing hostIndexing changed entities in the search indexes
vox_subscription_deliveriesevery processing hostDelivering events to subscriptions; degraded while a subscription is paused
vox_scheduled_publicationsone hostScheduled publish, unpublish, restore and content releases
vox_query_storage_buildsone hostFilling the storage of new or changed query fields
vox_search_index_backfillone hostFilling a new search index
vox_subscription_syncone hostSubscription synchronizations and snapshot resend requests
vox_context_manifest_publicationone hostPublishing the context manifest when it changed
vox_assessment_eventsone hostThe instance events of assessment changes
vox_context_cleanupone hostCleaning up the content of deleted context members and releases
vox_relation_replacementone hostReplacing links a page at a time when there are too many for one save
vox_scheduled_assessmentsone hostScheduled assessments, eg the duplicate URLs of routing
vox_image_profile_changesone hostRecording changed image profiles once a deployment is active, with Vox.Images
vox_mcp_issuer_pruneone hostRemoving the embedded MCP issuer's expired tokens, once a day
vox_tracked_queriesone hostRemoving the tracked query definitions nothing refers to anymore, every hour
vox_retention, vox_history_retention, vox_entity_log_retention, vox_change_inventory_retentionone hostRetention and cleanups, see history and audit
vox_dependency_change_purgeone hostRemoving dispatched dependency changes once they're older than their retention
vox_entity_storage_outboxone hostMoving the changes of entities stored in Redis to the Vox database, see Redis
vox_transient_expiryone hostRemoving what expired transient entities left behind, see transient entities
vox_accumulator_maintenanceone hostRemoving finished holds of Accumulators and the balances that deleted entities left, see limits and reservations
vox_deploymentevery hostThe host's deployment mode and heartbeat, see deployments
vox_applied_model_refreshevery hostFollowing changes of the model made on other hosts
vox_redis_entity_sync, vox_rabbitmq_entity_syncevery host that receivesApplying entity snapshots from other Vox applications, see sharing entities