php - Make an SQS worker timezone aware
I have a cron which queues jobs to a worker. The worker sends emails to users. The jobs are queued for different countries. The emails should only be sent between 11 AM to 5 PM for each country i.e. emails to users from Australia should only be sent between 11 AM to 5 PM in Australian time and same goes for all the other countries.
What I've tried
Each of the jobs knows about it's timezone. On reading the job, if it doesn't match with the time requirement, it is deleted from the queue and added with a delay. The delay is calculated based on the difference from the next acceptable time frame to current time.
But the problem with this solution is that the delay is typically in 17-18 hours. Amazon's SQS has maximum delay of 15 minutes. One workaround can be to delay the job by 5 minutes every time but it is inefficient since the same job will be picked several times in those 17-18 hours.
Another terribly inefficient solution can be to have multiple workers for each country.
Presently, I have multiple cron entries for the same command to queue the jobs at the times which are acceptable i.e. jobs for Australia are queued at 11 AM since the cron line for Australian jobs is set to 11 AM.
I am looking for an efficient mechanism to solve this. All ideas are welcome. Can someone please help me out here? Also, what are the standard ways these kind of problems are solved?