php-general Digest 23 Apr 2013 17:14:16 -0000 Issue 8206

Topics (messages 320962 through 320972):

Re: Load testing an app
        320962 by: Adam Richardson
        320970 by: Andrew Ballard

A little confused
        320963 by: Chris Knipe
        320964 by: Stuart Dallas
        320965 by: Chris Knipe
        320966 by: Stuart Dallas
        320967 by: shiplu
        320968 by: Chris Knipe

Re: mysql_connect noob question
        320969 by: Tedd Sperling
        320971 by: Glob Design Info
        320972 by: Jim Giner

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 Mon, Apr 22, 2013 at 10:41 PM, Andrew Ballard <aball...@gmail.com> wrote:

> The other developer in our office spent some time profiling the site with
> xdebug and found that an exec() call to netsh used on a couple pages seems
> to take 2-4 seconds to complete. Unfortunately, those exec() calls are the
> one function that we cannot test in our development environment. We are
> considering some optimizations, but since load on the production server is
> at a seasonal low we want to duplicate the problem so we can measure the
> impact of any changes we make. We spent most of today hammering the site
> with JMeter today in an attempt to reproduce the issue. While we were
> easily able to slow the site to a crawl (some samples taking over 2 minutes
> to complete), the server returned to normal as soon as the test concluded
> and it never became totally unresponsive like it did this past fall.
>

If you can't test the exec calls, directly, I'd refactor the functionality
that calls exec() so you could pass in replacement functionality that
creates that artificially creates the pause in your development environment:

function callnetsh($args, $func) {
    $func($args);
}
// in dev environment, pass in $func that doesn't call exec but just sleeps
for the expected duration
callnetsh(['some', 'args'], function($args){
    sleep(4);
});

We're both new to JMeter. I know a single test server may not be able to
> create enough simultaneous requests to accurately simulate real traffic,
> but I'm fairly confident that our tests involved far more (roughly-)
> simultaneous connections than we were experiencing live. (The first test
> used 20 threads; we gradually increased the threads for each test to 500
> threads before we quit for the day.) The site is on a private subnet, so
> distributed and/or cloud-based testing are probably not options.
>

2 quick notes:

If you have a linux box available, I like the simplicity of siege, but
jmeter is nice, too:
http://www.joedog.org/siege-home/

If the exec() calls were not being executed (e.g., they were bypassed) and
weren't being accounted for in terms of processing time, then these tests
would likely fail to recreate the load issues with similar numbers.

The site is running PHP 5.3 on IIS/Windows Server 2003. The netsh calls are
> to a DHCP server on a separate Windows server, and the database is SQL
> Server 2008 (previously 2000).
>

PHP 5.4 offers performance improvements. I don't suspect the migration from
SQL Server 2003 to 2008 caused any of these issues.


> So, any ideas we can try?


We'd probably have to know more about what the netsh calls were doing.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
On Tue, Apr 23, 2013 at 2:29 AM, Adam Richardson <simples...@gmail.com> wrote:
>
> On Mon, Apr 22, 2013 at 10:41 PM, Andrew Ballard <aball...@gmail.com> wrote:
>>
>> The other developer in our office spent some time profiling the site with
>> xdebug and found that an exec() call to netsh used on a couple pages seems
>> to take 2-4 seconds to complete. Unfortunately, those exec() calls are the
>> one function that we cannot test in our development environment. We are
>> considering some optimizations, but since load on the production server is
>> at a seasonal low we want to duplicate the problem so we can measure the
>> impact of any changes we make. We spent most of today hammering the site
>> with JMeter today in an attempt to reproduce the issue. While we were
>> easily able to slow the site to a crawl (some samples taking over 2 minutes
>> to complete), the server returned to normal as soon as the test concluded
>> and it never became totally unresponsive like it did this past fall.
>
>
> If you can't test the exec calls, directly, I'd refactor the functionality 
> that calls exec() so you could pass in replacement functionality that creates 
> that artificially creates the pause in your development environment:
>

I'm not sure the issue is solely because of the delay. At any rate, we
were running the load test yesterday against the production system
that was having problems last fall. I wish we had a test system where
we could test everything end-to-end, but unfortunately we can't
duplicate the DHCP part of the production environment.

> 2 quick notes:
>
> If you have a linux box available, I like the simplicity of siege, but jmeter 
> is nice, too:
> http://www.joedog.org/siege-home/


Hahahaha. This system AND the DHCP both USED to run on linux boxes.
This task was much simpler then, because the DHCP table was a text
file that we parsed and updated directly from PHP. It was decided to
standardize on a single platform to make system maintenance and
security management simpler, and most of our client/server stack was
already Windows. If necessary, I could probably spin up a virtual box
for testing though.

>> The site is running PHP 5.3 on IIS/Windows Server 2003. The netsh calls are
>> to a DHCP server on a separate Windows server, and the database is SQL
>> Server 2008 (previously 2000).
>
>
> PHP 5.4 offers performance improvements. I don't suspect the migration from 
> SQL Server 2003 to 2008 caused any of these issues.


I can't imagine the DB upgrade would have caused it. I think at the
same time he switched to using Zend_Db (not the full framework, just
the DB library) over top of the SQL Server driver for PHP for database
queries.

>>
>> So, any ideas we can try?
>
>
> We'd probably have to know more about what the netsh calls were doing.


This particular call is querying DHCP for a list of leases within a
specific scope so we can get the MAC address of the client. Once we
authenticate the user, calls on later pages expire the current lease
for that MAC address on a private subnet and create a semi-permanent
lease on the public subnet.

Our testing yesterday stepped through the process beginning with this
initial DHCP query (which was the long running process identified in
profiling) and the next few very simple pages but stopped short of
actually making any changes to the network assignment. With a single
user, the first page takes a couple seconds and the next few pages are
<50ms. During testing yesterday, we had the system stressed enough to
stretch those times out past a couple minutes.

It looks like we're going to have to continue the test into the next
part of the sign-up process, but that will take some time to learn
about JMeter conditional logic. I suspect we'll have to wait a couple
weeks until students are gone before we can actually run that level of
testing.

Andrew

--- End Message ---
--- Begin Message ---
Hi All,

$_SESSION['ExpiryDate'] = "2013-04-23";
echo date_format($_SESSION['ExpiryDate'], "D, \t\h\e jS \o\f M Y");

Required Result: Mon, the 23rd of Apr 2013

I get however:  PHP Warning:  date_format() expects parameter 1 to be
DateTime, integer given in

I've had a look at the date/time function list, but I cannot seem to find
any way to convert $_SESSION['ExpiryDate'] to an DateTime??

--
Chris.



--- End Message ---
--- Begin Message ---
On 23 Apr 2013, at 11:07, "Chris Knipe" <sav...@savage.za.org> wrote:

> $_SESSION['ExpiryDate'] = "2013-04-23";
> echo date_format($_SESSION['ExpiryDate'], "D, \t\h\e jS \o\f M Y");
> 
> Required Result: Mon, the 23rd of Apr 2013
> 
> I get however:  PHP Warning:  date_format() expects parameter 1 to be
> DateTime, integer given in
> 
> I've had a look at the date/time function list, but I cannot seem to find
> any way to convert $_SESSION['ExpiryDate'] to an DateTime??

http://php.net/strtotime

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
Yes,

strtotime() does convert the $_SESSION value to a unix epoc, as expected.
However, date_format still complains that the argument is a Integer value,
instead of a DateTime.




On Tue, Apr 23, 2013 at 12:09 PM, Stuart Dallas <stu...@3ft9.com> wrote:

> On 23 Apr 2013, at 11:07, "Chris Knipe" <sav...@savage.za.org> wrote:
>
> > $_SESSION['ExpiryDate'] = "2013-04-23";
> > echo date_format($_SESSION['ExpiryDate'], "D, \t\h\e jS \o\f M Y");
> >
> > Required Result: Mon, the 23rd of Apr 2013
> >
> > I get however:  PHP Warning:  date_format() expects parameter 1 to be
> > DateTime, integer given in
> >
> > I've had a look at the date/time function list, but I cannot seem to find
> > any way to convert $_SESSION['ExpiryDate'] to an DateTime??
>
> http://php.net/strtotime
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
>



-- 

Regards,
Chris Knipe

--- End Message ---
--- Begin Message ---
On 23 Apr 2013, at 11:13, Chris Knipe <sav...@savage.za.org> wrote:

> Yes,
> 
> strtotime() does convert the $_SESSION value to a unix epoc, as expected.  
> However, date_format still complains that the argument is a Integer value, 
> instead of a DateTime.

Sorry, I didn't read your email properly and didn't realise you were trying to 
use DateTime objects.

$datetime = new DateTime('2013-04-23');

If all you're doing is formatting the date you'll find using 
date($unix_timestamp) far more efficient than date_format($datetime_object).

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

> On Tue, Apr 23, 2013 at 12:09 PM, Stuart Dallas <stu...@3ft9.com> wrote:
> On 23 Apr 2013, at 11:07, "Chris Knipe" <sav...@savage.za.org> wrote:
> 
> > $_SESSION['ExpiryDate'] = "2013-04-23";
> > echo date_format($_SESSION['ExpiryDate'], "D, \t\h\e jS \o\f M Y");
> >
> > Required Result: Mon, the 23rd of Apr 2013
> >
> > I get however:  PHP Warning:  date_format() expects parameter 1 to be
> > DateTime, integer given in
> >
> > I've had a look at the date/time function list, but I cannot seem to find
> > any way to convert $_SESSION['ExpiryDate'] to an DateTime??
> 
> http://php.net/strtotime
> 
> -Stuart
> 
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
> 
> 
> 
> -- 
> 
> Regards,
> Chris Knipe


--- End Message ---
--- Begin Message ---
On Tue, Apr 23, 2013 at 4:07 PM, Chris Knipe <sav...@savage.za.org> wrote:

> echo date_format($_SESSION['ExpiryDate'], "D, \t\h\e jS \o\f M Y");
>

Why not construct DateTime object

echo date_format(new DateTime($_SESSION['ExpiryDate']), "D, \t\h\e jS \o\f
M Y");

Or

$dt = new DateTime($_SESSION['ExpiryDate']);
echo $dt->format("D, \t\h\e jS \o\f M Y");

I personally like the later. It takes less characters to do more.






-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

--- End Message ---
--- Begin Message ---
Thanks for the replies guys - figured it out!

Using date() directly with strtotime() and the appropriate formating works
:)

date("D, \\t\h\e jS \o\\f M Y", strtotime($_SESSION['ExpiryTime']))




On Tue, Apr 23, 2013 at 12:16 PM, shiplu <shiplu....@gmail.com> wrote:

>
> On Tue, Apr 23, 2013 at 4:07 PM, Chris Knipe <sav...@savage.za.org> wrote:
>
>> echo date_format($_SESSION['ExpiryDate'], "D, \t\h\e jS \o\f M Y");
>>
>
> Why not construct DateTime object
>
> echo date_format(new DateTime($_SESSION['ExpiryDate']), "D, \t\h\e jS \o\f
> M Y");
>
> Or
>
> $dt = new DateTime($_SESSION['ExpiryDate']);
> echo $dt->format("D, \t\h\e jS \o\f M Y");
>
> I personally like the later. It takes less characters to do more.
>
>
>
>
>
>
> --
> Shiplu.Mokadd.im
> ImgSign.com | A dynamic signature machine
> Innovation distinguishes between follower and leader
>



-- 

Regards,
Chris Knipe

--- End Message ---
--- Begin Message ---
On Apr 21, 2013, at 3:33 PM, Glob Design Info <i...@globdesign.com> wrote:

> What question did I not answer?


That proves that you're not listening -- you are total waste of time for anyone 
trying to help.

Welcome to my ignore file.

tedd

_____________________
tedd.sperl...@gmail.com
http://sperling.com


--- End Message ---
--- Begin Message --- Well all, it turns out the *correct* answer to my question, which no one answered, and which only degenerated into a kindergarten-like argument is:

"You need to add the port # to the *end* of the mysql_connect() call".

i.e.:

$link = mysqli_connect( $host, &user, pass, $database, $port );

Glad to see the maturity level of posters on this list, as in most of IT these days is that of a bunch of squabling 5-year olds.

On 4/23/13 5:47 AM, Tedd Sperling wrote:
On Apr 21, 2013, at 3:33 PM, Glob Design Info <i...@globdesign.com> wrote:

What question did I not answer?

That proves that you're not listening -- you are total waste of time for anyone 
trying to help.

Welcome to my ignore file.

tedd

_____________________
tedd.sperl...@gmail.com
http://sperling.com

--- End Message ---
--- Begin Message ---
On 4/23/2013 10:39 AM, Glob Design Info wrote:
Well all, it turns out the *correct* answer to my question, which no one
answered, and which only degenerated into a kindergarten-like argument is:

"You need to add the port # to the *end* of the mysql_connect() call".

i.e.:

$link = mysqli_connect( $host, &user, pass, $database, $port );

Glad to see the maturity level of posters on this list, as in most of IT
these days is that of a bunch of squabling 5-year olds.

On 4/23/13 5:47 AM, Tedd Sperling wrote:
On Apr 21, 2013, at 3:33 PM, Glob Design Info <i...@globdesign.com>
wrote:

What question did I not answer?

That proves that you're not listening -- you are total waste of time
for anyone trying to help.

Welcome to my ignore file.

tedd

_____________________
tedd.sperl...@gmail.com
http://sperling.com
Tedd - you got off easy on this post. You should have seen the shouting tirade I received offline from this guy. What a putz!


--- End Message ---

Reply via email to