Re: My App is Getting too Slow
Ok thanks AD, here is what I got from the Profiler I still can't understand which part to investigate and what eats up all the resources here: http://www.eg-host.net/cache_grind_requests_controller.zip Sorry for pasting the Model relations the way I did... thought this will be less confusing as Model Names will never affect the speed. Anyway the Request Model has the following relations: var $hasOne = array("DraftMessage"); var $hasMany = array("TourFile","RequestsMeal","RequestsCruise","RequestPayment","RequestsHotel","RequestsThingstodo","RequestReminder","RequestsGroupMember","RequestsDomesticFlight","RequestsTransfer","RequestsInternationalFlight","RequestsTrainTicket","RequestRefusal","RequestReply"=>array("order"=>"RequestReply.id asc")); var $belongsTo = array( 'Department', 'Branch', 'Client', 'RequestStatus', 'Currency', 'Source' => array( 'className' => 'Source', 'foreignKey' => 'source_id' ), 'SubSource' => array( 'className' => 'Source', 'foreignKey' => 'sub_source_id'), 'Staff' => array( 'className' => 'Staff', 'foreignKey' => 'staff_id'), 'DelegatedTo' => array( 'className' => 'Staff', 'foreignKey' => 'delegated_to')); It is important to say that the system is not only slow at this controller... I am just maintaining the same example request throughout the discussion. The whole system is heavy, although non-db dependent ones work bit faster. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
> PS Use real names, and real (abbreviated where possible) code. You > don't help anyone pasting erroneous made up code Certainly not me Andy :p -- jon bennett - www.jben.net - blog.jben.net Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
On Apr 10, 1:04 pm, Ayman Bedair wrote: > Got this error when I installed the profiler > > ( ! ) Fatal error: Maximum function nesting level of '100' reached, > aborting! in C:\AppServ\www\test\memphis_erp\cake\libs\folder.php on > line 239 Ayman, Xdebug isn't just a profiler. One of the things it does is prevent loops by imposing a max nesting level. http://xdebug.org/docs/basic Although hitting this limit (immediately) most likely hints at part of the cause of your problems - why don't you just increase the limit (to say 200) so you can get a profile - since your app "worked" before you obviously don't have an infinite loop in your code - you've simply got a very-nested loop in your code. And are currently getting distracted by a relevant - but not immediately so - detail. Hower, here's what you stack trace tells me: > 2 4.7698 3677016 Dispatcher->dispatch( ) ..\index.php:88 It took 4.7 seconds to get to line 88 of index.php. http://github.com/cakephp/cakephp1x/blob/master/app/webroot/index.php#L88 That's ALOT of time - and isn't dependent on your app code. it means you have some kind of setup problem. > 89 8.6338 11936400Model->schema( ) ..\model.php:753 It took a further 4 seconds before not-completing instantiating your model network. That's also a looong time. When you finally get a profile - you'll know more details where to look. hth, AD PS Use real names, and real (abbreviated where possible) code. You don't help anyone pasting erroneous made up code Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
> ^ Looks wrong - you have MODEL MODEL MODEL then source, is that > actually what you have? Ignore that - mistook 'Source' for an array param, not a model name. J -- jon bennett - www.jben.net - blog.jben.net Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
Hi Ayman, > var $hasOne = array("MODEL"); ^ looks ok > var $hasMany = > array("MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL"=>array("order"=>"MODEL.created > ASC")); ^ looks ok > var $belongsTo = array( > 'MODEL', MODEL', 'MODEL', 'MODEL', 'MODEL', > 'Source' => array( > 'className' => 'Source', > 'foreignKey' => 'source_id' > ), > 'SubSource' => array( > 'className' => 'Source', > 'foreignKey' => 'sub_source_id' > ), > 'Staff' => array( > 'className' => 'Staff', > 'foreignKey' => 'staff_id' > ), > 'DelegatedTo' => array( > 'className' => 'Staff', > 'foreignKey' => 'delegated_to' > ) ); > ^ Looks wrong - you have MODEL MODEL MODEL then source, is that actually what you have? > So as you can see there a a number of few models attached. And I am > still expecting this to increase... but this shouldn't be a problem > too cuz I am using containable No, the models are all connected when the app is instanciated, containable only affects things when you're querying the database. Remove some associations to see if that fixes it. If it does, rethink you're data model or look into the lazy loading behaviour. Cheers, Jon -- jon bennett - www.jben.net - blog.jben.net Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
Hey Jon... Actually I am running this on a windows server so the folders should be writable with no problems. I only have the Containable Behavior on all the models (AppModel) and Tree in both ARO and ACO (ACL) models. I believe this is not a problem. Here below is an example of the associated models to the this controller's main model. var $hasOne = array("MODEL"); var $hasMany = array("MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL","MODEL"=>array("order"=>"MODEL.created ASC")); var $belongsTo = array( 'MODEL', MODEL', 'MODEL', 'MODEL', 'MODEL', 'Source' => array( 'className' => 'Source', 'foreignKey' => 'source_id' ), 'SubSource' => array( 'className' => 'Source', 'foreignKey' => 'sub_source_id' ), 'Staff' => array( 'className' => 'Staff', 'foreignKey' => 'staff_id' ), 'DelegatedTo' => array( 'className' => 'Staff', 'foreignKey' => 'delegated_to' ) ); So as you can see there a a number of few models attached. And I am still expecting this to increase... but this shouldn't be a problem too cuz I am using containable Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: My App is Getting too Slow
> Are your tmp dirs definitely 777? > From looking at the API, __createLinks() creates the associated model > objects - do you have an huge number of models/associations? Could > there be something unusual about how they are set up? Do you have any Behaviours or Plugins that could be recursively getting in a mess with their associations? J -- jon bennett - www.jben.net - blog.jben.net Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
> Got this error when I installed the profiler > > ( ! ) Fatal error: Maximum function nesting level of '100' reached, > aborting! in C:\AppServ\www\test\memphis_erp\cake\libs\folder.php on > line 239 Are your tmp dirs definitely 777? >From looking at the API, __createLinks() creates the associated model objects - do you have an huge number of models/associations? Could there be something unusual about how they are set up? Cheers, J -- jon bennett - www.jben.net - blog.jben.net Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
Got this error when I installed the profiler ( ! ) Fatal error: Maximum function nesting level of '100' reached, aborting! in C:\AppServ\www\test\memphis_erp\cake\libs\folder.php on line 239 Call Stack # TimeMemory FunctionLocation 1 0.0041 135648 {main}( ) ..\index.php:0 2 4.7698 3677016 Dispatcher->dispatch( ) ..\index.php:88 3 4.9592 4902864 Dispatcher->_invoke( ) ..\dispatcher.php:194 4 4.9592 4904192 Controller->constructClasses( ) ..\dispatcher.php:207 5 5.6971 10230032Controller->loadModel( ) ..\controller.php:448 6 5.6986 10231864ClassRegistry->init( ) ..\controller.php:503 7 5.7032 10349208Model->__construct( ) ..\class_registry.php:140 8 5.8036 10427176Model->__createLinks( ) ..\model.php:418 9 5.8037 10429176Model->__constructLinkedModel( ) ..\model.php:609 10 5.8038 10429712ClassRegistry->init( ) ..\model.php:637 11 5.8073 10452704Model->__construct( ) ..\class_registry.php:140 12 5.9062 10464696Model->__createLinks( ) ..\model.php:418 13 5.9096 10467448Model->__constructLinkedModel( ) ..\model.php:609 14 5.9096 10467984ClassRegistry->init( ) ..\model.php:637 15 5.9137 10538504Model->__construct( ) ..\class_registry.php:140 16 6.0630 10586352Model->__createLinks( ) ..\model.php:418 17 6.0635 10588352Model->__constructLinkedModel( ) ..\model.php:609 18 6.0635 1058ClassRegistry->init( ) ..\model.php:637 19 6.0729 10612776Model->__construct( ) ..\class_registry.php:140 20 6.1849 10641896Model->__createLinks( ) ..\model.php:418 21 6.1850 10643896Model->__constructLinkedModel( ) ..\model.php:609 22 6.1851 10644432ClassRegistry->init( ) ..\model.php:637 23 6.1890 10674584Model->__construct( ) ..\class_registry.php:140 24 6.2675 10701984Model->__createLinks( ) ..\model.php:418 25 6.2677 10703984Model->__constructLinkedModel( ) ..\model.php:609 26 6.2678 10704520ClassRegistry->init( ) ..\model.php:637 27 6.2717 10736232Model->__construct( ) ..\class_registry.php:140 28 6.3996 10768352Model->__createLinks( ) ..\model.php:418 29 6.7588 10913824Model->__constructLinkedModel( ) ..\model.php:609 30 6.7589 10914360ClassRegistry->init( ) ..\model.php:637 31 6.7623 10941456Model->__construct( ) ..\class_registry.php:140 32 6.8624 10962528Model->__createLinks( ) ..\model.php:418 33 6.8625 10964528Model->__constructLinkedModel( ) ..\model.php:609 34 6.8626 10965064ClassRegistry->init( ) ..\model.php:637 35 6.8661 10997744Model->__construct( ) ..\class_registry.php:140 36 6.9800 11039424Model->__createLinks( ) ..\model.php:418 37 6.9801 11041424Model->__constructLinkedModel( ) ..\model.php:609 38 6.9802 11041960ClassRegistry->init( ) ..\model.php:637 39 6.9837 11065152Model->__construct( ) ..\class_registry.php:140 40 7.1217 11106224Model->__createLinks( ) ..\model.php:418 41 7.1231 11108224Model->__constructLinkedModel( ) ..\model.php:609 42 7.1232 11108760ClassRegistry->init( ) ..\model.php:637 43 7.1269 11133192Model->__construct( ) ..\class_registry.php:140 44 7.2092 11154360Model->__createLinks( ) ..\model.php:418 45 7.2107 11156360Model->__constructLinkedModel( ) ..\model.php:609 46 7.2108 11156896ClassRegistry->init( ) ..\model.php:637 47 7.2141 11188400Model->__construct( ) ..\class_registry.php:140 48 7.3457 11231856Model->__createLinks( ) ..\model.php:418 49 7.4631 11275248Model->__constructLinkedModel( ) ..\model.php:609 50 7.4632 11275784ClassRegistry->init( ) ..\model.php:637 51 7.4637 11278168Model->__construct( ) ..\class_registry.php:140 52 7.4689 11286520Model->__createLinks( ) ..\model.php:418 53 7.4708 11290272Model->__constructLinkedModel( ) ..\model.php:609 54 7.4709 11290808ClassRegistry->init( ) ..\model.php:637 55 7.4743 11325808Model->__construct( ) ..\class_registry.php:140 56 7.5923 11354536Model->__createLinks( ) ..\model.php:418 57 7.5955 11356536Model->__constructLinkedModel( ) ..\model.php:609 58 7.5956 11357072ClassRegistry->init( ) ..\model.php:637 59 7.5992 11385976Model->__construct( ) ..\class_registry.php:140 60 7.7042 11416408Model->__createLinks( ) ..\model.php:418 61 7.7
Re: My App is Getting too Slow
Have you profiled the request yet? (Suggested above.) Look into xdebug - specifically http://xdebug.org/docs/profiler. btw. Are you absolutely sure it's server time you're waiting on? Yslow or Pagespeed will tell you that. Hmm... 79 queries is absolutely nuts too. I've heard it said - can't remember where - that anything over about 7ish per request is asking for trouble. (General rule of thumb.) On Thu, Apr 8, 2010 at 12:39 PM, Ayman Bedair wrote: > That is what i get from the debug timer: > > http://www.eg-host.net/887.jpg > > I still have no clue what takes most of the time and what is the > normal time of doing the core processing :S > > > ANY HELP?! > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > > To unsubscribe, reply using "remove me" as the subject. > -- - "You can't reason people out of a position they didn't use reason to get into." Christian Leskowsky Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: My App is Getting too Slow
That is what i get from the debug timer: http://www.eg-host.net/887.jpg I still have no clue what takes most of the time and what is the normal time of doing the core processing :S ANY HELP?! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
I never tried any debuging kit I'll give it a try... and BTW it took 24 ms not 79 ... I am sure the thing is a Cakephp issue. Will try a debug kit and will let you know if I find anything interesting. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
On Apr 8, 12:03 pm, Zaky Katalan-Ezra wrote: > Did you test the queries with other client like phpmyadmin in order to > determine if it's a cake issue or database issue? The sql execution time for Ayman is 79ms, the page loads in 10s (apparently) - it's very obvious the queries themselves aren't the problem. It takes at most an hour from "what's profiling?" to using xdebug (or at the very least debug kit's awesome timers) to be able to see exacty where your php time is going. Doing anything except profiling is an interesting bit of procrastination at best. All IMHO, AD Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: My App is Getting too Slow
Did you test the queries with other client like phpmyadmin in order to determine if it's a cake issue or database issue? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
Well thanks for your help... Actually all 79 queries are made on the same database that runs on the same machine. My app is a CRM application where most of the pages can't be convert to a static one ! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
79 queries into a single database? You see, there's this design flaw in CakePHP, in which it connects into database as soon as the controller is instantiated. I am not sure about other database drivers, BUT, in Mysql's, i.e. if you have 4 databases schemas, and you happen to use 4 models in a single controller, each model connecting into a different database schema, you'll end up having 4 database connections for _each_ request you got in this controller - either you use the model object or not. 4 connections to 4 database schemas, even if they're in the same machine. Also take a look into the I/O resource used to connect into the database, which turns out to be a bottleneck point. If webserver and database are within the same host, consider using unix socket instead TCP/IP connections, it'll help to reduce connection latency. In my previous experience with such performance issues regarding DB, I solved this problem of yours when I've hidden CakePHP of the application. I mean, dinamically generating static pages with CakePHP... For instance: http://www.domain.com.br/customer/view/123.html is generated by http://www.domain.com.br/customer/view/123 []s Dérico Filho On Apr 6, 5:06 am, Ayman Bedair wrote: > My CakePHP app is getting very slow... Although the debug give me > "(default) 79 queries took 24 ms" the pages takes about 8 to 10 > seconds to load. Other script running on the same server are > performing well, even empty pages on this same application is still > loading good with all the App Controller functions running. Yet it is > too slow in querying pages even if the autoRender is set to false. so > it has nothing to do with the HTML and Images !! :( > > I thought it's with the mobile device detection I had there but that > runs in the App Controller beforeFilter() function so it should be > running on empty pages too !!! > > Is there a way i can debug that parts that makes all this delay ?! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Re: My App is Getting too Slow
On Apr 6, 10:06 am, Ayman Bedair wrote: > My CakePHP app is getting very slow... Although the debug give me > "(default) 79 queries took 24 ms" 79 queries is a lot. Even if each of those queries took 0ms (and returned nothing) it'll cost you approximately 2ms per query - which is not insignificant. Of course, if 78 of those queries are describes, and there's only 1 'real' query you don't need to worry about them. > the pages takes about 8 to 10 > seconds to load. Other script running on the same server are > performing well, even empty pages on this same application is still > loading good with all the App Controller functions running. Yet it is > too slow in querying pages even if the autoRender is set to false. so > it has nothing to do with the HTML and Images !! :( > > I thought it's with the mobile device detection I had there but that > runs in the App Controller beforeFilter() function so it should be > running on empty pages too !!! > > Is there a way i can debug that parts that makes all this delay ?! Install debug kit ( http://github.com/cakephp/debug_kit ) and look at the timer tab to get a broad idea of where most of your time goes set debug to 0 to get more accurate timer info. AND set debug to 0 and profile (http://xdebug.org/docs/profiler + e.g. http://code.google.com/p/webgrind/) to see /exactly/ into which functions your time is going. Do not profile with debug > 0 as what you'll get will be inaccurate to the point of pointless. Use the results to know where to focus your efforts. Bear in mind that if it's slow only because of some debug > 0 process you may not need to do anything. hth, AD Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
My App is Getting too Slow
My CakePHP app is getting very slow... Although the debug give me "(default) 79 queries took 24 ms" the pages takes about 8 to 10 seconds to load. Other script running on the same server are performing well, even empty pages on this same application is still loading good with all the App Controller functions running. Yet it is too slow in querying pages even if the autoRender is set to false. so it has nothing to do with the HTML and Images !! :( I thought it's with the mobile device detection I had there but that runs in the App Controller beforeFilter() function so it should be running on empty pages too !!! Is there a way i can debug that parts that makes all this delay ?! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.