Re: [PHP] PHP tutorials
I like www.phpexercises.com. On 1/17/11, Paul M Foster wrote: > On Sun, Jan 16, 2011 at 01:26:07PM -0500, tedd wrote: > >> Hi gang: >> >> In the past we talked about PHP tutorials, but I don't remember if >> there was a single clearinghouse/link for them or not -- is there >> one? If not, what do you recommend? >> >> Disclaimer: This is a clear solicitation by me for help with my PHP >> class. I will be teaching this class at my local college starting >> this semester. Please realize this is the first time my local college >> has considered PHP anything of importance. >> >> In the past, the college has been totally ingrained in .NET (i.e., >> APS, VB, C#). They believe their focus should be teaching students >> what the Corporate World wants and those needs have been defined by >> the State of Michigan and General Motors. Considering that neither of >> those institutions are financially solvent, other avenues are being >> considered. >> >> I know I can Google for "PHP tutorials", but I am looking for >> recommendations from this list as to which tutorials/references are >> the best. > > I'm not sure that I wouldn't simply take one of the basic books on PHP > (like an O'Reilly) and simply follow along with how it approaches the > subject. > > You might also investigate a kid named Bucky Roberts on Youtube. His > channel on Youtube is: > > http://youtube.com/user/thenewboston > > He has tutorials on a wide variety of languages, including PHP. Check > the playlists link on his home page (above) and look for the PHP > tutorials playlist. It appears that he doesn't do a complete work-up of > the whole language (I haven't watched the PHP tutorials), but the other > stuff he's done seems pretty basic and thorough. > > If you decide to do your own video tutorials, I'd strongly suggest > hosting them at Youtube. Let them worry about traffic, bandwidth, etc. > > I'd also suggest students make heavy use of the php.net/manual/en/ tree, > since (as has been frequently noted) it's some of the best programming > language documentation on the web. > > Paul > > -- > Paul M. Foster > http://noferblatz.com > > > -- > 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] How to get cpu consumption of a php script
Hi everybody, I'm a php developper for a high traffic website. Our web servers run with lightty? We have some issues with the cpu consumption of our servers. The problem is that, we don't know exactly which script consumes so much cpu. So, we cant to figure out how much cpu does a php script take. We have tried 3 methods: 1) Microtime: microtime at the beginning and at the end and make the diff. The problem with that is that it takes the execution time of the script, but in our script we make: - connection to database - connection to memcache - connection to session server All of this is not taken into account, so microtime is not that accurate 2) Shell command: we get the pid of the process executing the script and make a 'top' on this pid . The problem is that the php-cgi manages many threads so it's not accurate too. Is there other methods for dealing with this problem. Thanks, best regards, Tanoor.
Re: [PHP] How to get cpu consumption of a php script
I can't think of anything except using top or ps. If you can't guarantee what process runs what individual script, are you able to just track them all globally, and check for differences as you start and stop scripts. Perhaps run certain scripts under different users which should give them their own pid (i believe, but not tested this) that let's you track them more easily. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Tanoor Dieng" Date: Mon, Jan 17, 2011 10:23 Subject: [PHP] How to get cpu consumption of a php script To: Hi everybody, I'm a php developper for a high traffic website. Our web servers run with lightty? We have some issues with the cpu consumption of our servers. The problem is that, we don't know exactly which script consumes so much cpu. So, we cant to figure out how much cpu does a php script take. We have tried 3 methods: 1) Microtime: microtime at the beginning and at the end and make the diff. The problem with that is that it takes the execution time of the script, but in our script we make: - connection to database - connection to memcache - connection to session server All of this is not taken into account, so microtime is not that accurate 2) Shell command: we get the pid of the process executing the script and make a 'top' on this pid . The problem is that the php-cgi manages many threads so it's not accurate too. Is there other methods for dealing with this problem. Thanks, best regards, Tanoor.
RE: [PHP] How to get cpu consumption of a php script
> -Original Message- > From: a...@ashleysheridan.co.uk [mailto:a...@ashleysheridan.co.uk] > Sent: Monday, January 17, 2011 2:36 AM > To: Tanoor Dieng; php-general@lists.php.net > Subject: Re: [PHP] How to get cpu consumption of a php script > > I can't think of anything except using top or ps. If you can't guarantee what > process runs what individual script, are you able to just track them all > globally, and check for differences as you start and stop scripts. Perhaps run > certain scripts under different users which should give them their own pid (i > believe, but not tested this) that let's you track them more easily. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > - Reply message - > From: "Tanoor Dieng" > Date: Mon, Jan 17, 2011 10:23 > Subject: [PHP] How to get cpu consumption of a php script > To: > > Hi everybody, > I'm a php developper for a high traffic website. Our web servers run with > lightty? > > We have some issues with the cpu consumption of our servers. > > The problem is that, we don't know exactly which script consumes so much > cpu. > So, we cant to figure out how much cpu does a php script take. > > We have tried 3 methods: > > 1) Microtime: microtime at the beginning and at the end and make the diff. > The problem with that is that it takes the execution time of the script, but > in > our script we make: > - connection to database > - connection to memcache > - connection to session server > > All of this is not taken into account, so microtime is not that accurate > > 2) Shell command: we get the pid of the process executing the script and > make a 'top' on this pid . The problem is that the php-cgi manages many > threads so it's not accurate too. > > Is there other methods for dealing with this problem. > > Thanks, > best regards, > > Tanoor. This is untested. Within the same script, you could use [1] or similar and combine with shellexec ps/top to get what you need. I think this would give you a better result. Regards, Tommy [1] php.net/function.getmypid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to get cpu consumption of a php script
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/17/2011 11:23 AM, Tanoor Dieng wrote: > Hi everybody, > I'm a php developper for a high traffic website. Our web servers run with > lightty? > > We have some issues with the cpu consumption of our servers. > > The problem is that, we don't know exactly which script consumes so much > cpu. > So, we cant to figure out how much cpu does a php script take. > > We have tried 3 methods: > > 1) Microtime: microtime at the beginning and at the end and make the diff. > The problem with that is that it takes the execution time of the script, but > in our script we make: > - connection to database > - connection to memcache > - connection to session server > > All of this is not taken into account, so microtime is not that accurate > > 2) Shell command: we get the pid of the process executing the script and > make a 'top' on this pid . The problem is that the php-cgi manages many > threads so it's not accurate too. > > Is there other methods for dealing with this problem. > > Thanks, > best regards, > > Tanoor. > Use something like xdebug & cachegrind to profile the application. This makes it easy to track down memory and CPU usage. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJNNB8vAAoJEMffsHAOnubXpRkP/2u0EHXnQR+kkp6pQqM8Gry1 1iFIfqck4Bco3rOYcsX9IK22c/YJZ3RGCMnyZyp+XUAmV615keAtqW/sRgWy/cO9 oaiDHdctdnLeFxmoyRVzR7/FkaeM/bJ7Tj29wnkii8gMbNi8W3zm/RQqBSxoAGig tJOx+SBi+jqgxfAn18dutRrqDm1lMRNi3wZI8k6Dg2U8i+s/sAjFMVPbNAvLfDzs uOisnYiJSCdA33zN3IkXD+W9vqVGdHjqF1UABG8srPY/DBUPDjtSrzuHICdQX4SJ luzgDvnoIVoOE0ntiAPIKba89iXDtIIIlvIX2BkQeGfNIoZWP0/M75siX4drLLI/ 6/omgCBOMXkjZ0GMJzdeLPsVjMqagNYKUZfor3KPj0PbpX4RoftWJgvLShHDv74v nusu8vClDwQNc9eBBZ5Kf7MkXzXVXnFUUO21PSb3WQtX/7eziGrhz8vxYEbR7/zA XidHE1vfyTr+DNdbkjkYPHyj/s+ZIloNmf/9rjdC8xpEYEevEErUxY+15MXvSZEq 4JmxVUOe3P9ICZSGMf1+BieH9oZRmteFLtMujwHdXVzWVDrCvurM6dwJVdSNZMhT Ct0PeOwJxJgAtvKL+bOpzd+AMHVEpoWETIYrpXepmCHxbCVCa0fDmxgZ73+32XI8 25mgBHxvMdfINaOjWZJf =mz+P -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to get cpu consumption of a php script
Please take into account that lighttpd does have some random high cpu-consumption problems, it could be that also. Give nginx a try instead. Also: microtime by itself isn't enough, sum time() to it because if a script lasts more than 1 second you can end up with negative total time, microtime doesn't have a seconds counter, only microseconds. Are you using a cms? Have you tried deactivating some plugins? Sent from my iPhone On 17-01-2011, at 7:23, Tanoor Dieng wrote: > Hi everybody, > I'm a php developper for a high traffic website. Our web servers run with > lightty? > > We have some issues with the cpu consumption of our servers. > > The problem is that, we don't know exactly which script consumes so much > cpu. > So, we cant to figure out how much cpu does a php script take. > > We have tried 3 methods: > > 1) Microtime: microtime at the beginning and at the end and make the diff. > The problem with that is that it takes the execution time of the script, but > in our script we make: > - connection to database > - connection to memcache > - connection to session server > > All of this is not taken into account, so microtime is not that accurate > > 2) Shell command: we get the pid of the process executing the script and > make a 'top' on this pid . The problem is that the php-cgi manages many > threads so it's not accurate too. > > Is there other methods for dealing with this problem. > > Thanks, > best regards, > > Tanoor. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to get cpu consumption of a php script
Hi thanks, for xdebug, we'll take al look at it. On Mon, Jan 17, 2011 at 11:51 AM, Thijs Lensselink wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 01/17/2011 11:23 AM, Tanoor Dieng wrote: > > Hi everybody, > > I'm a php developper for a high traffic website. Our web servers run with > > lightty? > > > > We have some issues with the cpu consumption of our servers. > > > > The problem is that, we don't know exactly which script consumes so much > > cpu. > > So, we cant to figure out how much cpu does a php script take. > > > > We have tried 3 methods: > > > > 1) Microtime: microtime at the beginning and at the end and make the > diff. > > The problem with that is that it takes the execution time of the script, > but > > in our script we make: > > - connection to database > > - connection to memcache > > - connection to session server > > > > All of this is not taken into account, so microtime is not that accurate > > > > 2) Shell command: we get the pid of the process executing the script and > > make a 'top' on this pid . The problem is that the php-cgi manages many > > threads so it's not accurate too. > > > > Is there other methods for dealing with this problem. > > > > Thanks, > > best regards, > > > > Tanoor. > > > > Use something like xdebug & cachegrind to profile the application. This > makes it easy to track down memory and CPU usage. > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.10 (GNU/Linux) > > iQIcBAEBAgAGBQJNNB8vAAoJEMffsHAOnubXpRkP/2u0EHXnQR+kkp6pQqM8Gry1 > 1iFIfqck4Bco3rOYcsX9IK22c/YJZ3RGCMnyZyp+XUAmV615keAtqW/sRgWy/cO9 > oaiDHdctdnLeFxmoyRVzR7/FkaeM/bJ7Tj29wnkii8gMbNi8W3zm/RQqBSxoAGig > tJOx+SBi+jqgxfAn18dutRrqDm1lMRNi3wZI8k6Dg2U8i+s/sAjFMVPbNAvLfDzs > uOisnYiJSCdA33zN3IkXD+W9vqVGdHjqF1UABG8srPY/DBUPDjtSrzuHICdQX4SJ > luzgDvnoIVoOE0ntiAPIKba89iXDtIIIlvIX2BkQeGfNIoZWP0/M75siX4drLLI/ > 6/omgCBOMXkjZ0GMJzdeLPsVjMqagNYKUZfor3KPj0PbpX4RoftWJgvLShHDv74v > nusu8vClDwQNc9eBBZ5Kf7MkXzXVXnFUUO21PSb3WQtX/7eziGrhz8vxYEbR7/zA > XidHE1vfyTr+DNdbkjkYPHyj/s+ZIloNmf/9rjdC8xpEYEevEErUxY+15MXvSZEq > 4JmxVUOe3P9ICZSGMf1+BieH9oZRmteFLtMujwHdXVzWVDrCvurM6dwJVdSNZMhT > Ct0PeOwJxJgAtvKL+bOpzd+AMHVEpoWETIYrpXepmCHxbCVCa0fDmxgZ73+32XI8 > 25mgBHxvMdfINaOjWZJf > =mz+P > -END PGP SIGNATURE- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] How to get cpu consumption of a php script
On 17 January 2011 10:58, Camilo Sperberg wrote: > Please take into account that lighttpd does have some random high > cpu-consumption problems, it could be that also. Give nginx a try instead. > > Also: microtime by itself isn't enough, sum time() to it because if a script > lasts more than 1 second you can end up with negative total time, microtime > doesn't have a seconds counter, only microseconds. http://www.php.net/manual/en/function.microtime.php : Return current Unix timestamp with microseconds Hmm. I'm guessing it does. [2011/01/17 11:16:06] [Z:\] [\\richardquadling\scratch$ ] >php -r "echo microtime(true);" 1295263156.1895 Oh yeah! -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pcntl_signal() get PID
Hi everyone! My question is:howto getPIDtreadchildto send a signalhandlerinstalled inpcntl_signal()? I apologizeformyEnglish,I'm fromRussia. Thanks.
[PHP] PHP Error logging
Hello, I currently have a strange issue where we are seeing 'random errors' being displayed to end users. What I find most interesting is that in the php.ini file we have the following error settings. error_reporting = E_ALL & ~E_NOTICE display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off track_errors = Off I thought that if we had dislay_errors = Off then end users should never see errors displayed on the web page. However at apparently random times we do still see errors being reported, its not consistent at all. To give a better idea of the problem we have 8 web servers, they all run an identical copy of the site which is stored on a common netapp nfs filer. At apparently random times we see that 1 out of 8 servers will reported strange errors like 'use of undefined constant' or 'Undefined variable'. What's most strange about these errors is that if the code was faulty wouldn't we expect to see the errors on all web servers? and secondly wouldn't we expect to see the errors constantly rather than at apparently random intervals? The php.ini files have a modify time of mid 2010 and yet this problem has only started in the last few weeks. Has anyone else experienced similar problems in the past and if so what was the root cause? Regards, Jimmy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Error logging
On Mon, Jan 17, 2011 at 19:33, Jimmy Stewpot wrote: > Hello, > > I currently have a strange issue where we are seeing 'random errors' being > displayed to end users. What I find most interesting is that in the php.ini > file we have the following error settings. > > error_reporting = E_ALL & ~E_NOTICE > display_errors = Off > display_startup_errors = Off > log_errors = On > log_errors_max_len = 1024 > ignore_repeated_errors = Off > track_errors = Off > > I thought that if we had dislay_errors = Off then end users should never see > errors displayed on the web page. However at apparently random times we do > still see errors being reported, its not consistent at all. To give a better > idea of the problem we have 8 web servers, they all run an identical copy of > the site which is stored on a common netapp nfs filer. At apparently random > times we see that 1 out of 8 servers will reported strange errors like 'use > of undefined constant' or 'Undefined variable'. What's most strange about > these errors is that if the code was faulty wouldn't we expect to see the > errors on all web servers? and secondly wouldn't we expect to see the errors > constantly rather than at apparently random intervals? > > The php.ini files have a modify time of mid 2010 and yet this problem has > only started in the last few weeks. Has anyone else experienced similar > problems in the past and if so what was the root cause? Sounds like someone added either ini_set('display_errors','On') in the script being called or an include, added a local php.ini file to the directory (or a parent directory), or added a php_flag to .htaccess in the directory (or a parent). Try checking into those possibilities. -- Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to avoid using temporary?
heres my sql query: EXPLAIN SELECT t1.szs_guige,SUM(t1.szs_shuliang) FROM szs_ck_ruku_items t1,szs_ck_ruku t2 WHERE t1.szs_rukubianhao = t2.szs_rukubianhao AND t2.szs_date>'2010-10-23' GROUP BY t1.szs_guige ORDER BY null result: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range PRIMARY,date date 3 \N 177 Using where; Using index; Using temporary 1 SIMPLE t1 ref PRIMARY PRIMARY 32 szs_jihuadan.t2.szs_rukubianhao 4 table structure below: CREATE TABLE `szs_ck_ruku` ( `szs_rukubianhao` varchar(10) NOT NULL, `szs_kuhao` varchar(10) NOT NULL, `szs_kuwei` varchar(10) NOT NULL, `szs_xianghao` varchar(4) NOT NULL, `szs_caozuoyuan` varchar(10) NOT NULL, `szs_date` date NOT NULL, PRIMARY KEY (`szs_rukubianhao`,`szs_kuhao`,`szs_kuwei`), KEY `date` (`szs_date`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 CREATE TABLE `szs_ck_ruku_items` ( `szs_rukubianhao` varchar(10) NOT NULL, `szs_kuhao` varchar(10) NOT NULL, `szs_kuwei` varchar(10) NOT NULL, `szs_shengchanhao` varchar(50) NOT NULL, `szs_guige` varchar(100) NOT NULL, `szs_tuhao` varchar(100) NOT NULL, `szs_shuliang` int(8) NOT NULL, `szs_beizhu` text NOT NULL, PRIMARY KEY (`szs_rukubianhao`,`szs_kuhao`,`szs_kuwei`,`szs_shengchanhao`,`szs_guige`,`szs_tuhao`), KEY `GG` (`szs_guige`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 how to avoid using temporary? i am confuzed.. thanks