I have a dataset containing list of users (around 50M).
Each user has an email address, name, and some more data columns.
I want to send a weekly email to those users, and the content of the email will be based on the user's data.
Each user should get the mail on a specific day of the week, based on his registration date.
How do I design a system that will allow me to query the users, and send them the custom email? How can I make that system scalable?
One approach I thought about is writing a worker that will query all the users that need to receive the email on the current day (this will be paginated), and will insert them to a queue where several workers can process them.
The problem with this approach is that I can't add workers that query the data and insert it to the queue, because I can't guarantee that each user will be queried by a single worker.
Maybe there is a specific DB or data access tool I can use? Is there a known pattern for this kind of processing?
I would appreciate your suggestions and thoughts on the subject.