Building message delivery model with channels

Hello,

we have couchbase server running behind sync gateway and hundreds of thousands couchbase lite clients (mobile applications with authenticated users). We’re going to send text messages to clients using various filters and this messages must be visible only to their recipients. Clients will receive messages by their own channels. The question is what options do we have to specify the recipients for each message with less overhead. For now we’re thinking of two variants:

  1. Add channel “messages_{client_id}” for each client, put each new message into all its recipients channels. But having a lot of recipients makes _channels property of the message document really huge and we don’t want this property to be replicated to the client. AFAIK, we can’t avoid replicating _channels property to clients?

  2. Add channel “messages_{client_id}” for each client, make a copy of message document for each recipient. This leads to having tons of almost identical documents with differrent channels property only, but it solves the replication problem (each client will receive its own message copy without unwanted metadata). I don’t know if couchbase storage has data deduplication. If it has than this variant looks good to me.

Any other thoughts?

 {
    "_id":"12345",
    "message":"some text",
    "channels":["message_{client 1}","message_{client 2}","message_{client 3}",""message_{client 4}""]
    }

if you think that the "channels" array is going to get to big i.e. main hundreds or thousands can you put people in groups? like below. Then during the Pull from CBL you get only the channels you want

 {
    "_id":"12345",
    "message":"some text",
    "channels":["message_group1","message_group5"]
    }

Don’t do that it will get messy