Published 5 months ago by araeuchle
Hello guys. My first post here! We have started creating a new web application using Laravel 5.5. We are expecting to have several thousands of users so we will host this application on AWS using a Load Balancer and two application servers for the start.
To my question: I have given the following task to create a Job that runs daily at 00:00. Check if a user have birthday, if he has birthday, sent him an email. Also check for his age and depending on his new age he gets a new user role.
I realised that Laravel's build Task Scheduler should be perfect for it, but it wants me to a cronjob every one minute. So i am looking for some solution were i can build something that is really reliable to call long running tasks.
Any help is really appreciated!
My understanding problem atm is the following:
The command is called at the same time. so Laravel will have two instances trying to execute the jobs. How is decided which app is executing the job AND is the job really blocked when hit by the other instance first? :)
@araeuchle Well as per my answer and the PR linked, it stores a lock in a cache both application servers use. So it’ll be a case of first come, first served. The first server to attempt the job will create a lock and then process the job, and when the second server attempts the job it’ll check if there’s a lock, see it, and not process it.