2

I am making an application in which once a week will have to perform multiple operations (calculations) based on all users of the system. Initially estimated about 300 users.

My question is, is there a method to perform this type of operation? like batch processing? At this moment, I test the script with only an user and on my localhost, I use a foreach cycle to cycle users and made ​​all queries, calculations and insert the results ..

I have the doubt if more users saturate the script or hosting or similar things.. How can i handle such situations?

Cheers ;)

2

1 Answer 1

1

This kind of situation is usually done with Cron (or something similiar on Windows). So if your script is run only by cron in off-peak hours (e.g. 3am on Sunday if all your users are in one timezone), you are almost certain that it neither run twice in the same time nor does affect your users.

Since MySQL supports transaction and stored procedures and functions, I would recommend you to use stored procedure in database rather than PHP script for looping through data. You can then store logic in db functions and do something like insert-select in a transaction. It should be faster, safer and more convenient way than plain loop.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.