0

I have a mobile app (native Android & iOS) which requires client's data to be updated (to renew the recurring items) daily at midnight. I'm using cron-jobs in nodejs using node-cron library and its working perfectly fine as it should. BUT the main problem I'm facing with this is of timezones i.e. data should be updated when clock struck midnight at "Client side" (wherever they are) but cron runs according to "Server time". So it works for some clients but fails for many...

I want to know is there any way I can achieve this at client side (by hitting a web service at specific time) or directly from server? My developer suggested me to save client's timezone in database and run cron separately for each client according to their timezone but I don't agree with this idea as I think it would be too much heavier for server to handle so many jobs simultaneously.

I need professional & expert opinions for this. Should I go for latter or any other way?

TalESid
  • 2,304
  • 1
  • 20
  • 41

1 Answers1

1

You could save the client timezone and make your cron run hourly, on each run it selects only the clients where it's midnight on their timezone.

Felipe Zavan
  • 1,654
  • 1
  • 14
  • 33
  • Nice option. This means we'll have maximum of 35-40 jobs (total UTC offsets) per day, which definitely isn't too much... Am I right? – TalESid Jun 21 '20 at 20:34
  • 1
    Looks totally fine to me as long as they're the jobs are not too computationally heavy and take too long to complete. – Felipe Zavan Jun 21 '20 at 20:36
  • 1
    Really appreciate your valuable opinion. Thanks! – TalESid Jun 21 '20 at 20:41
  • Can you tell me the way to handle Daylight Saving? i.e. What to do if there is DST applied in the user's timezone? – TalESid Jun 30 '20 at 07:56