简体   繁体   中英

Using pthreads in PHP Cron scripts running parallel

Am new to pthreads and having some confusion over using this in Cron Jobs.

I have Cron Job that will run every 15 mins. Each time I will call index.php with certain params. Also this may run 50 times parallel with different params. From index.php currently an requiring 2 classes in different php files, general.php and db.php. And creating objects each time(here 50 times at a time for 50 Cron Jobs).

Is there any way to apply pthreads effectively here?

I heard about serialize() and storing in separate file or DB. Is that a good solution here?

This question is not very clear. So you want to have a Cron Job that runs every 15 minutes and on each run to execute index.php on 50 different threads in parallel, each thread with its own parameters? Now going one step further, you'd like those 50 threads to share a copy of each of general.php and db.php objects?

If the 50 executions of index.php are truly independent of each other, you may want to create 50 different Cron Jobs, each with its own schedule and own parameters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM