You have found one of the main concern for designing relationship in MongoDB where if you have many collections to update/query you will endup in not optimized and reliably harder schema to maintain.
One of the rules is try to use as less collections as possible and data that will be queried updated should be stored together.
Therefore, I am not sure why do you need a relationship document. I am not seeing how a relationship will be queried without a user context (either follower or following) . For this reason I think there are 2 documents to update :
- User document of the one who followed another user.
- User document of the one who is being followed/subscribed.
Now doing those 2 documents can be done with ACID transaction if you have to ensure data consistency across documents. However, it could also be done in an async way where one of your services (or atlas trigger) is listening to follow requests and update the followed user together with other application logic like sending a push notifications to that user.
Now the problem of keeping all followers in one array as you will have unbounded arrays which is a known mongo antipattern. Therefore you should look into the outlier pattern design for heavy users.
Of course I recommend using all the baked in mechanisms like retrayble writes and causal consistency to improve failure writes. Perhaps also add a retry logic of your own and use $addToSet to push relationship to have no impact if operations are done multiple times to the data logic.