php-general Digest 11 May 2012 23:11:33 -0000 Issue 7810
Topics (messages 317843 through 317846):
Re: Performance / AB issue?
317843 by: Matijn Woudt
317844 by: Mike Mackintosh
317845 by: Lars Nielsen
Converting date string to unix timestamp
317846 by: Karl DeSaulniers
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Fri, May 11, 2012 at 9:53 AM, Camilo Sperberg <unrea...@gmail.com> wrote:
>
>
> Sent from my iPhone 5 Beta [Confidential use only]
>
> On 11 mei 2012, at 07:09, "Lars Nielsen" <l...@lfweb.dk> wrote:
>
>>
>>>
>>> On 10 mei 2012, at 23:26, Lars Nielsen wrote:
>>>
>>>>
>>>>>
>>>>>
>>>>> Sent from my iPhone 5 Beta [Confidential use only]
>>>>>
>>>>> On 10 mei 2012, at 17:40, Matijn Woudt <tijn...@gmail.com> wrote:
>>>>>
>>>>>> On Thu, May 10, 2012 at 9:04 AM, Lars Nielsen <l...@lfweb.dk> wrote:
>>>>>>> Hi there,
>>>>>>>
>>>>>>> I have apache-2.22/php 5.3.10 set up on a dedicated server but I have
>>>>>>> a
>>>>>>> strange issue.
>>>>>>>
>>>>>>> I have made a Drupal 7 site with a mysql db.
>>>>>>>
>>>>>>> If I stress-test the site with : ab -c 1 -n 150 http://sitename/ it
>>>>>>> works
>>>>>>> fine.
>>>>>>> If I stress-test the site with : ab -c 2 -n 20 http://sitename/ it
>>>>>>> kills
>>>>>>> apache.
>>>>>>> If I stress-test the site with : ab -c 50 -n 1500
>>>>>>> http://sitename/static.html it works fine.
>>>>>>>
>>>>>>> I have set apache's errorlog to debug. But it writes nothing, either
>>>>>>> in
>>>>>>> the virtualhost or in the server-file.
>>>>>>>
>>>>>>> Can anyone give a hint about what can be wrong?
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> What do you mean with 'kills apache', does it terminate apache or does
>>>>>> apache hang (eg. 100% cpu), and respond normal after the stress test
>>>>>> is over?
>>>>>> And what is the index of your site? A php script, or..? Do you have
>>>>>> ModRewrite redirects etc?
>>>>>>
>>>>>> - Matijn
>>>>>>
>>>>>> --
>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>
>>>>>
>>>>> Can you visit the site normally? Try less verbosing in apache, that is
>>>>> pretty intensive, but as you can benchmark a static file well (with
>>>>> moderate high settings), i assume it is some configuration problem in
>>>>> drupal.
>>>>>
>>>>> Greeting.
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>
>>>> Hi,
>>>>
>>>> I can visit the site normaly, but with 2-3 concurrent ab test it fails.
>>>> seen from 'ps' and 'htop' it seems that both apache and mysql continues
>>>> to
>>>> run normaly but it doesnt respond.
>>>>
>>>> If i run netstat -an after the test it shows this :
>>>> Active Internet connections (servers and established)
>>>> Proto Recv-Q Send-Q Local Address Foreign Address State
>>>> tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
>>>> tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
>>>> tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
>>>> tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
>>>> tcp 1 0 x.x.x.x:80 x.x.x.x:39237 CLOSE_WAIT
>>>> tcp 1 0 x.x.x.x:80 x.x.x.x:39236 CLOSE_WAIT
>>>> tcp 0 0 x.x.x.x:22 x.x.x.x:47383 ESTABLISHED
>>>> tcp 0 0 127.0.0.1:80 127.0.0.1:34775
>>>> ESTABLISHED
>>>> tcp 1 0 x.x.x.x:80 x.x.x.x:39300 CLOSE_WAIT
>>>> ESTABLISHED
>>>> tcp 0 0 127.0.0.1:34775 127.0.0.1:80
>>>> ESTABLISHED
>>>> tcp 0 0 x.x.x.x:80 x.x.x.x:39330 ESTABLISHED
>>>> tcp6 0 0 :::22 :::*
>>>> LISTEN
>>>> tcp6 0 0 ::1:25 :::*
>>>> LISTEN
>>>>
>>>> So it does seem like there should be room for new tcp connections?
>>>>
>>>> But if I restart apache then it works again... So I guess it is a
>>>> apache/php configuration issue?
>>>>
>>>> --
>>>> Med venlig hilsen / Best Regards
>>>>
>>>> LFWeb
>>>> Lars Nielsen
>>>> Thorsensvej 30
>>>> 4800 Nykøbing Falster
>>>> Tlf: +45 20 64 85 76
>>>> email : l...@lfweb.dk
>>>> www : http://www.lfweb.dk
>>>>
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>
>>> Have you tried benchmarking a really simple php page, such as
>>>
>>> <?php echo 'hello world'; ?>
>>>
>>> ?
>>>
>>> It that works, than it is definitely an issue in Drupal's configuration
>>> and not in PHP/Apache. Additionally, you could check what happens when you
>>> try to establish a session or make a database call to rule out those as
>>> well, just make really simple tests that you know wouldn't fail and run ab
>>> on them.
>>>
>>> Greetings.
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> Thanks!
>>
>> Now I have made
>> <?php
>> echo "Hey from PHP!";
>> ?>
>>
>> It runs fine from a little concurrency. But with "-c 5 -n 500" it fails
>> after 308 requests!
>>
>>
>>
>> Best Regards / Med venlig hilsen
>>
>> LFWeb
>> Lars Nielsen
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> Have you tried benchmarking from localhost? Do you have any active firewall?
> Selinux? Shorewall? Anything that could block a ddos attack?
>
A firewall is not the case here. He's testing with -c 2 and is getting
errors, with -c 50 on a static file not. Also, blocking a DDOS attack
at only 50 connections is way too low, so I don't think that would
happen.
- Matijn
--- End Message ---
--- Begin Message ---
How is PHP running, fast-cgi, sapi, etc..?
Is there anything in the error_log for apache? Could be an issue with
prefork/worker.
Thanks,
Mike Mackintosh
PHP, the drug of choice - www.highonphp.com
--- End Message ---
--- Begin Message ---
> On Fri, May 11, 2012 at 9:53 AM, Camilo Sperberg <unrea...@gmail.com>
> wrote:
>>
>>
>> Sent from my iPhone 5 Beta [Confidential use only]
>>
>> On 11 mei 2012, at 07:09, "Lars Nielsen" <l...@lfweb.dk> wrote:
>>
>>>
>>>>
>>>> On 10 mei 2012, at 23:26, Lars Nielsen wrote:
>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>> Sent from my iPhone 5 Beta [Confidential use only]
>>>>>>
>>>>>> On 10 mei 2012, at 17:40, Matijn Woudt <tijn...@gmail.com> wrote:
>>>>>>
>>>>>>> On Thu, May 10, 2012 at 9:04 AM, Lars Nielsen <l...@lfweb.dk>
>>>>>>> wrote:
>>>>>>>> Hi there,
>>>>>>>>
>>>>>>>> I have apache-2.22/php 5.3.10 set up on a dedicated server but I
>>>>>>>> have
>>>>>>>> a
>>>>>>>> strange issue.
>>>>>>>>
>>>>>>>> I have made a Drupal 7 site with a mysql db.
>>>>>>>>
>>>>>>>> If I stress-test the site with : ab -c 1 -n 150 http://sitename/
>>>>>>>> it
>>>>>>>> works
>>>>>>>> fine.
>>>>>>>> If I stress-test the site with : ab -c 2 -n 20 http://sitename/ it
>>>>>>>> kills
>>>>>>>> apache.
>>>>>>>> If I stress-test the site with : ab -c 50 -n 1500
>>>>>>>> http://sitename/static.html it works fine.
>>>>>>>>
>>>>>>>> I have set apache's errorlog to debug. But it writes nothing,
>>>>>>>> either
>>>>>>>> in
>>>>>>>> the virtualhost or in the server-file.
>>>>>>>>
>>>>>>>> Can anyone give a hint about what can be wrong?
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> What do you mean with 'kills apache', does it terminate apache or
>>>>>>> does
>>>>>>> apache hang (eg. 100% cpu), and respond normal after the stress
>>>>>>> test
>>>>>>> is over?
>>>>>>> And what is the index of your site? A php script, or..? Do you have
>>>>>>> ModRewrite redirects etc?
>>>>>>>
>>>>>>> - Matijn
>>>>>>>
>>>>>>> --
>>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>>
>>>>>>
>>>>>> Can you visit the site normally? Try less verbosing in apache, that
>>>>>> is
>>>>>> pretty intensive, but as you can benchmark a static file well (with
>>>>>> moderate high settings), i assume it is some configuration problem
>>>>>> in
>>>>>> drupal.
>>>>>>
>>>>>> Greeting.
>>>>>> --
>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>
>>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I can visit the site normaly, but with 2-3 concurrent ab test it
>>>>> fails.
>>>>> seen from 'ps' and 'htop' it seems that both apache and mysql
>>>>> continues
>>>>> to
>>>>> run normaly but it doesnt respond.
>>>>>
>>>>> If i run netstat -an after the test it shows this :
>>>>> Active Internet connections (servers and established)
>>>>> Proto Recv-Q Send-Q Local Address      Foreign Address
>>>>> Â State
>>>>> tcp     0    0 0.0.0.0:22        0.0.0.0:*
>>>>> Â Â Â Â LISTEN
>>>>> tcp     0    0 127.0.0.1:25       0.0.0.0:* Â
>>>>> Â Â Â LISTEN
>>>>> tcp     0    0 127.0.0.1:3306      0.0.0.0:* Â
>>>>> Â Â Â LISTEN
>>>>> tcp     0    0 0.0.0.0:80        0.0.0.0:*
>>>>> Â Â Â Â LISTEN
>>>>> tcp     1    0 x.x.x.x:80     x.x.x.x:39237 Â
>>>>> CLOSE_WAIT
>>>>> tcp     1    0 x.x.x.x:80     x.x.x.x:39236 Â
>>>>> Â CLOSE_WAIT
>>>>> tcp     0    0 x.x.x.x:22     x.x.x.x:47383 Â
>>>>> Â ESTABLISHED
>>>>> tcp     0    0 127.0.0.1:80     Â
>>>>> Â 127.0.0.1:34775
>>>>> ESTABLISHED
>>>>> tcp     1    0 x.x.x.x:80     x.x.x.x:39300 Â
>>>>> Â CLOSE_WAIT
>>>>> ESTABLISHED
>>>>> tcp     0    0 127.0.0.1:34775     127.0.0.1:80
>>>>> ESTABLISHED
>>>>> tcp     0    0 x.x.x.x:80     x.x.x.x:39330 Â
>>>>> Â ESTABLISHED
>>>>> tcp6 Â Â Â 0 Â Â Â 0 :::22 Â Â Â Â Â Â Â Â Â :::*
>>>>> LISTEN
>>>>> tcp6 Â Â Â 0 Â Â Â 0 ::1:25 Â Â Â Â Â Â Â Â Â :::*
>>>>> LISTEN
>>>>>
>>>>> So it does seem like there should be room for new tcp connections?
>>>>>
>>>>> But if I restart apache then it works again... So I guess it is a
>>>>> apache/php configuration issue?
>>>>>
>>>>> --
>>>>> Med venlig hilsen / Best Regards
>>>>>
>>>>> LFWeb
>>>>> Lars Nielsen
>>>>> Thorsensvej 30
>>>>> 4800 Nykøbing Falster
>>>>> Tlf: +45 20 64 85 76
>>>>> email : l...@lfweb.dk
>>>>> www : http://www.lfweb.dk
>>>>>
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>
>>>> Have you tried benchmarking a really simple php page, such as
>>>>
>>>> <?php echo 'hello world'; ?>
>>>>
>>>> ?
>>>>
>>>> It that works, than it is definitely an issue in Drupal's
>>>> configuration
>>>> and not in PHP/Apache. Additionally, you could check what happens when
>>>> you
>>>> try to establish a session or make a database call to rule out those
>>>> as
>>>> well, just make really simple tests that you know wouldn't fail and
>>>> run ab
>>>> on them.
>>>>
>>>> Greetings.
>>>>
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>> Thanks!
>>>
>>> Now I have made
>>> <?php
>>> Â echo "Hey from PHP!";
>>> ?>
>>>
>>> It runs fine from a little concurrency. But with "-c 5 -n 500" it fails
>>> after 308 requests!
>>>
>>>
>>>
>>> Best Regards / Med venlig hilsen
>>>
>>> LFWeb
>>> Lars Nielsen
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>
>> Have you tried benchmarking from localhost? Do you have any active
>> firewall? Selinux? Shorewall? Anything that could block a ddos attack?
>>
>
> A firewall is not the case here. He's testing with -c 2 and is getting
> errors, with -c 50 on a static file not. Also, blocking a DDOS attack
> at only 50 connections is way too low, so I don't think that would
> happen.
>
> - Matijn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Php is running as mod_php under an apache worker configuration.
Med venlig hilsen
LFWeb
Lars Nielsen
--- End Message ---
--- Begin Message ---
Hello everyone,
Got a quick one (I hope), and probably an easy one.
For some reason it is eluding me at the moment.
Hoping someone can help.
I am building an ics file with PHP and the form that is submitting to
create this ics file has a jQuery date picker on it.
The date furnished comes to me like this "Saturday, January 1, 2012",
and a time furnished like "4:20 pm" with no seconds.
Now for the ics file, I need the date/time combo to be..
Ymd\THis\Z or in the case of the above date and time, 20120101T042000Z
Here is the block of code that I am using for this.
CODE [
...
}
else {
$dt_start = $_POST["field20"] ? $_POST["field20"] :
$_POST["field21"]; //Saturday, January 1, 2012
$dt_end = $_POST["field22"]; //Saturday, January 1, 2012
$t_start = $_POST["field24"]; //4:20 pm
$t_end = $_POST["field25"]; //5:55 pm
//date_default_timezone_set('UTC');
try {
$start_DT = new DateTime($dt_start . " " . $t_start);
$st_date_fmt = new DateTime($start_DT->format("l, F d, Y\TH:ia
T"));
//$startdate_stamp = strtotime($st_date_fmt);
$startdate = $st_date_fmt->format('U');
//$startdate = date('Ymd\THis\Z', $startdate_stamp);
}
catch (Exception $e) {
trigger_error("startdate error: " . $e->getMessage(),
E_USER_ERROR);
exit(1);
}
try {
if(empty($dt_end)) {
$enddate = $startdate + (60 * 60); //If no end date provided,
enddate is 1 hour after startdate.
} else {
$end_DT = new DateTime($dt_end . " " . $t_end);
$end_date_fmt = new DateTime($end_DT->format("l, F d,
Y\TH:ia T"));
//$enddate_stamp = strtotime($end_date_fmt);
$enddate = $end_date_fmt->format('U');
//$enddate = date('Ymd\THis\Z', $enddate_stamp);
}
}
catch (Exception $e) {
trigger_error("enddate error: " . $e->getMessage(),
E_USER_ERROR);
exit(1);
}
$stampnow = date('Ymd\THis\Z', time());
//$datestampnow = strtotime($stampnow);
}
...
]
I have a feeling I am mixing something up on my own, but I have been
staring at this code to long to see it.
Can anyone help me please? Like I said, this is probably an easy one.
TIA!!
Best,
Karl DeSaulniers
Design Drumm
http://designdrumm.com
--- End Message ---