PHP CLI多后台进程限制
服务器信息:PHP CLI多后台进程限制,php,linux,perl,parallel-processing,Php,Linux,Perl,Parallel Processing,服务器信息: CentOS 6.5 12GB内存 英特尔(R)至强(R)CPU E5-2430@6 CPU x 2.20GHz PHP CLI 5.5.7 我目前正在尝试使用Perl并行启动1000个PHP CLI进程。但是,对于等效的Perl脚本,这需要9.9秒,而不是2.3秒。当我使用Perl脚本测试时,所有1000个进程都是并行启动的(ps-eLf | grep-ic'test.pl')。当我使用/opt/testphp.php,使用ps-eLf | grep-ic'testphp.p
- CentOS 6.5
- 12GB内存
- 英特尔(R)至强(R)CPU E5-2430@6 CPU x 2.20GHz
- PHP CLI 5.5.7
ps-eLf | grep-ic'test.pl'
)。当我使用/opt/testphp.php
,使用ps-eLf | grep-ic'testphp.php'
进行测试时,我看到计数为250,然后上升到580,然后下降到0(脚本执行1000次,只是不是并行执行)
- 是否存在阻止并行启动大量PHP CLI进程的限制
- 有没有人经历过这个问题
Perl启动程序脚本:
use Time::HiRes qw/ time sleep /;
my $command = '';
my $start = time;
my $filename = '/tmp/report.txt';
# open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
for $i(1 .. 1000) {
# $command = $command . "(perl /opt/test.pl &);"; // takes 2.3 seconds
$command = $command . "(php -q /opt/testphp.php &);"; // takes 9.9 seconds
}
system($command);
my $end = time;
print 'Total time taken: ', ( $end - $start ) , "\n";
sleep(5);
$time = microtime(true);
file_put_contents('/tmp/report_20140804_php.log', "This is the record: $time\n", FILE_APPEND);
#! /usr/bin/perl
use Time::HiRes qw/ time sleep /;
sleep(5);
my $command = '';
my $start = time;
my $filename = '/tmp/report_20140804.log';
open(my $fh, '>>', $filename) or die "Could not open file '$filename' $!";
print $fh "Successfully saved entry $start\n";
close $fh;
PHP文件(testphp.PHP):
use Time::HiRes qw/ time sleep /;
my $command = '';
my $start = time;
my $filename = '/tmp/report.txt';
# open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
for $i(1 .. 1000) {
# $command = $command . "(perl /opt/test.pl &);"; // takes 2.3 seconds
$command = $command . "(php -q /opt/testphp.php &);"; // takes 9.9 seconds
}
system($command);
my $end = time;
print 'Total time taken: ', ( $end - $start ) , "\n";
sleep(5);
$time = microtime(true);
file_put_contents('/tmp/report_20140804_php.log', "This is the record: $time\n", FILE_APPEND);
#! /usr/bin/perl
use Time::HiRes qw/ time sleep /;
sleep(5);
my $command = '';
my $start = time;
my $filename = '/tmp/report_20140804.log';
open(my $fh, '>>', $filename) or die "Could not open file '$filename' $!";
print $fh "Successfully saved entry $start\n";
close $fh;
Perl文件(test.pl):
use Time::HiRes qw/ time sleep /;
my $command = '';
my $start = time;
my $filename = '/tmp/report.txt';
# open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
for $i(1 .. 1000) {
# $command = $command . "(perl /opt/test.pl &);"; // takes 2.3 seconds
$command = $command . "(php -q /opt/testphp.php &);"; // takes 9.9 seconds
}
system($command);
my $end = time;
print 'Total time taken: ', ( $end - $start ) , "\n";
sleep(5);
$time = microtime(true);
file_put_contents('/tmp/report_20140804_php.log', "This is the record: $time\n", FILE_APPEND);
#! /usr/bin/perl
use Time::HiRes qw/ time sleep /;
sleep(5);
my $command = '';
my $start = time;
my $filename = '/tmp/report_20140804.log';
open(my $fh, '>>', $filename) or die "Could not open file '$filename' $!";
print $fh "Successfully saved entry $start\n";
close $fh;