php-general Digest 11 Feb 2013 09:26:57 -0000 Issue 8118

2013-02-11 Thread php-general-digest-help

php-general Digest 11 Feb 2013 09:26:57 - Issue 8118

Topics (messages 320184 through 320187):

Re: Random 404 screens
320184 by: Jim Giner

fopen and load balancing
320185 by: Adam Tong
320186 by: Adam Richardson
320187 by: marco.behnke.biz

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


--
---BeginMessage---
Im pretty sure its not a script error cause it always works a second later

jg


On Feb 10, 2013, at 2:48 PM, Matijn Woudt tijn...@gmail.com wrote:

 
 
 
 On Sun, Feb 10, 2013 at 6:53 PM, Jim Giner jim.gi...@albanyhandball.com 
 wrote:
 On 2/10/2013 12:45 PM, Andy McKenzie wrote:
 On Sat, Feb 9, 2013 at 11:51 AM, Geoff Shang ge...@quitelikely.com wrote:
 On Sat, 9 Feb 2013, Jim Giner wrote:
 
 Lately, my web pages are giving me some problems.  Once a day or so one or
 more of my pages/scripts will give me a 404 error page saying my web page
 has timed out.  Problem is that the page was just displayed.  I click on a
 link, the page shows up, I click on a button on it to trigger some activity
 and voila!  An error.  I hit refresh and my page is back and things work ok.
 
 
 Since someone mentioned network issues, I will ask this question.
 
 Is it actually a 404 page?  That is to say, does the string 404 actually
 appear in the error document?
 
 If it does, then this would rule out your home network, as 404 is a response
 code returned by the webserver.
 
 Geoff.
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 This is a good point, and one I hadn't thought of.  I saw Network
 time out and thought network problems, but Geoff is right.  If it's
 actually a 404, it's not a network problem between you and the server.
 
 -Andy
 
 The page has a 404 code in it.  Next time I see one (been good today so 
 far) I'll c/p it in here.
 
 
 There are btw much web servers that provide an error, and then give an 404 
 error because they can't find an error page for that error code.
 
 - Matijn
---End Message---
---BeginMessage---
Hi,

We had an issue with the code of a junior php developer that used
fopen to load images using the url of the companies website that is
load balanced.

We could not the detect the problem in dev and test because the dev
and test servers are not load balanced.

I know that he could load the images using just the filesystem, but I
am curious to know why it failed and if the load balancer is really
the source of the problem or it is a limitation on the function
itself.

Thank you
---End Message---
---BeginMessage---
On Sun, Feb 10, 2013 at 5:41 PM, Adam Tong adam.to...@gmail.com wrote:

 Hi,

 We had an issue with the code of a junior php developer that used
 fopen to load images using the url of the companies website that is
 load balanced.

 We could not the detect the problem in dev and test because the dev
 and test servers are not load balanced.

 I know that he could load the images using just the filesystem, but I
 am curious to know why it failed and if the load balancer is really
 the source of the problem or it is a limitation on the function
 itself.

 Thank you

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


I'm not sure it sounds like an issue with the load balancer, as a load
balancer shouldn't have any qualm with passing through the image data
associated with an http request (which is what the fopen wrapper
essentially performs behind the scenes.) It's possible that the prod
servers (those making the call to fopen) aren't configured to allow the
http wrapper. It could just be as simple as allow_url_fopen being set to
false, in contrast to the configuration of the dev server(s).

http://php.net/manual/en/function.fopen.php
http://php.net/manual/en/wrappers.php
http://www.php.net/manual/en/wrappers.http.php

Adam

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


Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben:
 Hi,

 We had an issue with the code of a junior php developer that used
 fopen to load images using the url of the companies website that is
 load balanced.

 We could not the detect the problem in dev and test because the dev
 and test servers are not load balanced.

 I know that he could load the images using just the filesystem, but I
 am curious to know why it failed and if the load balancer is really
 the source of the problem or it is a limitation on the function
 itself.

Do you have any error messages for us?
If the load balancer accessable from the internal servers? Normally it is not.



 Thank you

 

Re: [PHP] fopen and load balancing

2013-02-11 Thread ma...@behnke.biz


Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben:
 Hi,

 We had an issue with the code of a junior php developer that used
 fopen to load images using the url of the companies website that is
 load balanced.

 We could not the detect the problem in dev and test because the dev
 and test servers are not load balanced.

 I know that he could load the images using just the filesystem, but I
 am curious to know why it failed and if the load balancer is really
 the source of the problem or it is a limitation on the function
 itself.

Do you have any error messages for us?
If the load balancer accessable from the internal servers? Normally it is not.



 Thank you

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Apache to serve RESTful requests using PHP

2013-02-11 Thread Stuart Dallas
On 10 Feb 2013, at 06:57, AmirBehzad Eslami behzad.esl...@gmail.com wrote:

 Stuart, thanks for your detailed response.
 
   I find it unlikely that Apache is your bottleneck,
  especially with a service involving MySQL. 
  How have you come to this conclusion?
 
 Apache is the entry-point to our service, and I did a 
 benchmark with AB to see how it can handle concurrent
 requests in a timely fashion.  After a number of 50 concurrent
 requests, the average time per request reached from less than
 a second to 5 seconds.

I *strongly* recommend you try the same test with nginx. Unless this is due to 
the way your code works I'm confident you'll see this effect disappear!

  As far as keep-alive goes, how frequently will individual
  clients be accessing the service?
 
 There are only a few clients that call the service.  These clients
 are PHP-driven web pages. Each page has its own unique ClickID
 and a set of other unique parameters per user visit.  These pages send these 
 parameters to the service using php-curl, and expect a generated
 response to be returned.  That's why I'm saying each request and
 response is unique.
 
 Whenever a user visits a web-page, there would be a call to the
 web-service.  At the moment, we don't know number of concurrent
 visits.  We're looking for a way to figure that out in Apache.
 
 Is there a way to see if the requests are using the previously keep-alived
 http channel?  Because same client will send requests to the service,
 and I'm curious to know if the Apache will allocate the already-opened
 channel, or will create a new one?

If it's making one request to your service per page request, keep-alive is 
pointless as it won't be able to reuse the connection. In this instance I would 
turn keep-alive off.

  If you are using joins to pull in extra data (i.e. IDs to a name
  or similar) look at using Memcache for those, but make sure
  that when they're updated in the DB they're also updated in Memcache. 
 
 Memcache or Redis, I'm going to add a caching layer between
 MySQL and PHP, to store the de-normilized data.

For simple caching I'd recommend Memcache over Redis, purely because Redis is 
more complex due to its support for sets, queues and other very useful stuff. 
The only reason I'd use Redis for simple caching is because it can periodically 
flush the cache to disk so if it has to restart it can start with a primed 
cache. However, in most cases that is not a huge advantage.

If each request and response is unique you need to be careful about what you 
choose to cache such that you don't incur caching costs without reaping 
benefits that make it worthwhile.

-Stuart

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP 5.4.11 warnings - how to make them go away ?

2013-02-11 Thread Paul Lanken
I ran a quick mysql_connect test using the php 5.4.11 cli and was met
with many annoying warnings :

$ php -r mysql_connect( \localhost\, \username\, \password\ )
or die(\Unable to connect to MySQL\); echo \Connected to
MySQL\\n\; 21 | cat -n -
 1  PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/extensions/gd.so' - ld.so.1: php: fatal:
/usr/local/lib/php/extensions/gd.so: open failed: No such file or
directory in Unknown on line 0
 2  PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/extensions/gettext.so' - ld.so.1: php: fatal:
/usr/local/lib/php/extensions/gettext.so: open failed: No such file or
directory in Unknown on line 0
 3  PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/extensions/ldap.so' - ld.so.1: php: fatal:
/usr/local/lib/php/extensions/ldap.so: open failed: No such file or
directory in Unknown on line 0
 4  PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/extensions/mcrypt.so' - ld.so.1: php: fatal:
/usr/local/lib/php/extensions/mcrypt.so: open failed: No such file or
directory in Unknown on line 0
 5  PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/extensions/mhash.so' - ld.so.1: php: fatal:
/usr/local/lib/php/extensions/mhash.so: open failed: No such file or
directory in Unknown on line 0
 6  PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/extensions/mysql.so' - ld.so.1: php: fatal:
/usr/local/lib/php/extensions/mysql.so: open failed: No such file or
directory in Unknown on line 0
 7  PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/extensions/mysqli.so' - ld.so.1: php: fatal:
/usr/local/lib/php/extensions/mysqli.so: open failed: No such file or
directory in Unknown on line 0
 8  Connected to MySQL

So I am happy with the final line but annoyed by the seven previous.
There seems to be no need for gd.so or any of the other dynamic libs
that are being searched for.  Not sure why these messages are
happening and I looked in /usr/local/lib/php.ini where I see this :

; Directory in which the loadable extensions (modules) reside.
extension_dir = /usr/local/lib/php/extensions


Seems reasonable.  However I do not need mysql.so because the php
binaries were linked with -lmysqlclient.

So how to get rid of these warnings ?

Paul

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP 5.4.11 warnings - how to make them go away ?

2013-02-11 Thread ma...@behnke.biz


Paul Lanken lanken.p...@gmail.com hat am 11. Februar 2013 um 14:27
geschrieben:
 I ran a quick mysql_connect test using the php 5.4.11 cli and was met
 with many annoying warnings :

 $ php -r mysql_connect( \localhost\, \username\, \password\ )
 or die(\Unable to connect to MySQL\); echo \Connected to
 MySQL\\n\; 21 | cat -n -
  1  PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/local/lib/php/extensions/gd.so' - ld.so.1: php: fatal:
 /usr/local/lib/php/extensions/gd.so: open failed: No such file or
 directory in Unknown on line 0
  2  PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/local/lib/php/extensions/gettext.so' - ld.so.1: php: fatal:
 /usr/local/lib/php/extensions/gettext.so: open failed: No such file or
 directory in Unknown on line 0
  3  PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/local/lib/php/extensions/ldap.so' - ld.so.1: php: fatal:
 /usr/local/lib/php/extensions/ldap.so: open failed: No such file or
 directory in Unknown on line 0
  4  PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/local/lib/php/extensions/mcrypt.so' - ld.so.1: php: fatal:
 /usr/local/lib/php/extensions/mcrypt.so: open failed: No such file or
 directory in Unknown on line 0
  5  PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/local/lib/php/extensions/mhash.so' - ld.so.1: php: fatal:
 /usr/local/lib/php/extensions/mhash.so: open failed: No such file or
 directory in Unknown on line 0
  6  PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/local/lib/php/extensions/mysql.so' - ld.so.1: php: fatal:
 /usr/local/lib/php/extensions/mysql.so: open failed: No such file or
 directory in Unknown on line 0
  7  PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/local/lib/php/extensions/mysqli.so' - ld.so.1: php: fatal:
 /usr/local/lib/php/extensions/mysqli.so: open failed: No such file or
 directory in Unknown on line 0
  8  Connected to MySQL

 So I am happy with the final line but annoyed by the seven previous.
 There seems to be no need for gd.so or any of the other dynamic libs
 that are being searched for.  Not sure why these messages are
 happening and I looked in /usr/local/lib/php.ini where I see this :

 ; Directory in which the loadable extensions (modules) reside.
 extension_dir = /usr/local/lib/php/extensions


 Seems reasonable.  However I do not need mysql.so because the php
 binaries were linked with -lmysqlclient.

 So how to get rid of these warnings ?


remove the loading entries from php.ini or from you /etc/php5/conf.d directory



 Paul

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and load balancing

2013-02-11 Thread Adam Tong
I think this is what happened. As the application was trying to open
our url domain the request was sent to the load balancer, and as it
does not accept internal requests, the connection was timed out.

The only way we could avoid that is to not use fopen our url, is that right?


On Mon, Feb 11, 2013 at 4:26 AM, ma...@behnke.biz ma...@behnke.biz wrote:


 Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben:
 Hi,

 We had an issue with the code of a junior php developer that used
 fopen to load images using the url of the companies website that is
 load balanced.

 We could not the detect the problem in dev and test because the dev
 and test servers are not load balanced.

 I know that he could load the images using just the filesystem, but I
 am curious to know why it failed and if the load balancer is really
 the source of the problem or it is a limitation on the function
 itself.

 Do you have any error messages for us?
 If the load balancer accessable from the internal servers? Normally it is not.



 Thank you

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3

 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz

 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal

 http://www.behnke.biz

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Question about PHP-CGI, mysqld and sudden spiking average load readings on Linux Virtual Dedicated Server running CentOS 6.3

2013-02-11 Thread Gary Lebowitz
I have noticed when doing a top via SSH on my GoDaddy virtual dedicated
server that every time a user logs in in the COMMAND column I see the
PHP-CGI process start to run, followed by mysqld. Often when these two
processes run I start to see a spike in average load, and sometimes this
spike spins out of control to the point that when trying to log on to my
Moodle 2.3.2 LMS I get an 500 Internal Server Error from Apache. Now, what
I'd like to know given the fact that I have only 2GBytes of RAM and am
sharing a processor with other users :-( is if there is any way to make
sure my PHP 5.3.3 is properly configured. I am given, for example, a choice
between CGI, fastCGI and Apache in my Plesk panel, and I am not quite sure
how to optimize things for my environment. I went to the Moodle.org site to
try and see what's the right setting, but it's not clear if the persons
writing there have a different setup or not. Unfortunately, it's impossible
to get specs on my VDS's processor from the fine folks at GoDaddy, and
perhaps there is just a simple processor power issue going on here, but I
only have 30 students and only a handful going in simultaneously. And at
times my average load can move from .08 to 1.5+ and all the way up to 2+
within the space of a few seconds. I should point out that at one point it
was discovered by GoDaddy technicial people that a user was running a rogue
process that overtaxing resources. But perhaps I also need to tweak my
installation despite this incident. Any help here would be appreciated.


Re: [PHP] fopen and load balancing

2013-02-11 Thread Sean Greenslade
On Mon, Feb 11, 2013 at 10:11 AM, Adam Tong adam.to...@gmail.com wrote:
 On Mon, Feb 11, 2013 at 4:26 AM, ma...@behnke.biz ma...@behnke.biz
 wrote:
 
 
  Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41
  geschrieben:
  Hi,
 
  We had an issue with the code of a junior php developer that used
  fopen to load images using the url of the companies website that is
  load balanced.
 
  We could not the detect the problem in dev and test because the dev
  and test servers are not load balanced.
 
  I know that he could load the images using just the filesystem, but I
  am curious to know why it failed and if the load balancer is really
  the source of the problem or it is a limitation on the function
  itself.
 
  Do you have any error messages for us?
  If the load balancer accessable from the internal servers? Normally it
  is not.


 I think this is what happened. As the application was trying to open
 our url domain the request was sent to the load balancer, and as it
 does not accept internal requests, the connection was timed out.

 The only way we could avoid that is to not use fopen our url, is that
 right?



Yeah, sure. That's as good of a guess as any of us will be able to
conjure up. Since you've given us no details, no code and no error
messages, we're basically relegated to blind guessing. I don't think
that's what you want, so if you still have a question, I suggest you
start by investigating the relevant logs. If you can't figure out the
issue from there, post _relevant_ snippets to the list.

Also remember that this is the PHP mailing list. (Even though we tend
to masquerade as the MySQL list from time to time) If it's an issue
with your very likely non-PHP load balancer, we can't really help you
out.

--Sean Greenslade

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php