Changing Audiences
A campaign audience describes a list of contacts that are being targeted by the campaign and may receive the message. See Serving Messages for more details.
Workflow
So how does a contact end up in the audience? Since there are multiple sources of the contacts there are multiple ways a contact can enter an audience.
There is a big difference how the processing is done depending on if we’re dealing with a batch of contacts or a transactional change containing only one or a few contacts.
Batches of Contacts
Batches of contacts can come from a few different places.
-
segment
-
snapshot of segment via SDS
-
changes to segment via SDS
-
contact list from AC
And since different parts of the workflow needs to be scaled in different ways there are multiple workers involved in the process of adding a contact to an audience.
Both segments and snapshots of a segment coming from SDS starts the processing in the init-audience-worker which fetches the contact-ids either from the segmentation service or the SDS. Changes to a segment a handled by the update_audience_worker which fetches the changes since last update from SDS. The contact-lists coming from automation center starts in resolve-contact-list-worker.
All of these workers output contact-ids, but in order to handle requests quickly when serving messages we need to store the contact-reference in the audience and not the contact-id. So all of these workers queue their contact-ids to resolve the ids to their corresponding contact-reference.
The resolving of the contact-reference which involves looking up the contact-id in DynamoDB is done by two workers. To avoid big campaigns blocking smaller ones and tests the first batch of contacts is processed by resolve-contact-ids-first-batch-worker and the remaining batches are then processed by the resolve-contact-ids-worker.
Transactional Changes
The workflow for transactional changes is a lot simpler than for batches. The contacts are coming from either RTI (Integrations) or AC (Automation Center) and the contact-ids are already contained in the request so there is no need to fetch the contact-ids from somewhere. We still need to look up the contact-reference for each contact-id but since each request only contains one or at least a small number of contact-ids everything can be handled by the same worker, the add-contacts-tx.