Notes Laravel Scheduler Function onOneServer()

I once worked with devops that did a lot of settings on the server. And he doesn’t have basic PHP. Then he asks about the function scheduler to run on only one server / one instance.

He said if we not setup to be run in one server, the scheduler will run in many instances of our app, for example we will send data to the customer’s email and if there are 3 instances, it will be sent 3 times mailer. So we have to make sure that if we have many instances, the scheduler process only runs on one instance.

I have never used it and have never had a case handle scheduler on many servers. Because our application now uses a docker and as we know, with the docker we can create multiple servers / instances to run our application.

Then my friend sent me the laravel documentation link, spesifically the onOneServer() function section here:

https://laravel.com/docs/5.8/scheduling#running-tasks-on-one-server

Very interesting, I read and tried the implementation in the cache that we did because to run the onOneServer () function we must to run it in the memcache or redis cache.

After that, he try to setup some config in docker then we try to sent task in scheduler. Woow..Great, we success set only 1 task come instead our docker set in 3 instance.

What i learn from my friend is, we need setting docker for handle scheduler part. And i have learn how docker handle that task in scheduler.

Later i try to write article how we setup docker to handle scheduler task in laravel.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.