drupal_100
asked on
Run PHP script as daemon and auto scale
Run PHP script as daemon and auto scale
Have a PHP program to process events stored in database,
event table
id description
1 event 1
2 event 2
3 event 3
...
process_event.php
<?php
do loop {
get an event from table
process the event
remove the event from table
}
?>
Want to run PHP program as daemon.
process_event.sh
#!/bin/bash
nice php process_event.php
Here it only runs a single worker.
Want to auto scale additional workers when needed.
For example, when table has 10 events, run 1 worker,
when table has 20 events, run 2 workers,
and automatically scale to run more or less workers according to number of events.
Have a PHP program to process events stored in database,
event table
id description
1 event 1
2 event 2
3 event 3
...
process_event.php
<?php
do loop {
get an event from table
process the event
remove the event from table
}
?>
Want to run PHP program as daemon.
process_event.sh
#!/bin/bash
nice php process_event.php
Here it only runs a single worker.
Want to auto scale additional workers when needed.
For example, when table has 10 events, run 1 worker,
when table has 20 events, run 2 workers,
and automatically scale to run more or less workers according to number of events.
So what is the question?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$pid = pcntl_fork();
fork process to scale up.
fork process to scale up.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for drupal_100's comment #a40483418
for the following reason:
Get answer
Accepted answer: 0 points for drupal_100's comment #a40483418
for the following reason:
Get answer
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your request does not concern programming, or manually forking process where you should be using a thread.
Both PHP-FPM and apache mod_fcgi exactly scales dynamically (untill 1024 parallel requests without tuning, that yields 20x that in users of site using it)
Both PHP-FPM and apache mod_fcgi exactly scales dynamically (untill 1024 parallel requests without tuning, that yields 20x that in users of site using it)
You need to explain better.
My recommendation: Split points:
http:#a40435577 (gheist) - 400 points
http:#a40483528 (gr8gonzo) - 100 points
http:#a40435577 (gheist) - 400 points
http:#a40483528 (gr8gonzo) - 100 points
I think both ways is acceptable like 50/50 I move threads out of process while you emphasize on hardships of thread programming.