Hi folks, currently I'm working on a mini e-wallet system. the customer wants to choose some of his transactions and do them automatically every week. The way I had done that is by storing the information inside the DB and making a cron job that runs every two minutes to check if there is a record that had to run. the questions are :
Is there any best practice for doing that ! .
is it ok to make query to the database every two minits !
@alnouirah My consideration of the best practice for scheduling tasks in a web application is to use a task scheduler, such as Laravel's task scheduler or a similar library, rather than relying on cron jobs. This allows for better management and monitoring of scheduled tasks.
It is not recommended to make a query to the database every two minutes as it can lead to performance issues. Instead, you should consider using a queue system to handle the scheduled tasks. This allows you to process the tasks asynchronously and reduces the load on the database.
First, thanks for your response.
Secondly, I apologize for the delay in replying, due to some reasons beyond my control.
The way I implemented it is by using the Laravel task scheduler. first, save the task detail in the database. Then I made a Laravel scheduler, where every two minutes it fetches all data from the tasks table to insure that there is a task that should be executed.
Is this the best way to implement it? Or are there better ways?