Re: Cake performance tips

2009-03-09 Thread jcorrea

I was trying to do that, but loading one model loads lots of other
related models. That's why it take too long.

On 6 mar, 19:50, Miles J mileswjohn...@gmail.com wrote:
 Well I use this technique, it only loads models that we need for that
 current action. Cuts down the models tremendously.

 http://www.milesj.me/blog/read/16/loading-models-specific-to-certain-...
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-09 Thread Miles J

Yes this is true of course, but it still cuts out unnecessary models
which help slightly. Im just hoping Cake can find a work around/fix to
that problem.
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-06 Thread LunarDraco

I would start a simple test with two different database.
one very small with at least one but no more than 5 records per table.

Then do another test with a database with at least 1000 records in the
tables that you would expect to grow.
If your code is setup correctly with view pagination etc. the time
between these two scenarios should change very little.

If you see a huge delay difference with the 1000 record database, then
you definitely have some bind or containable work to do.

If both scenarios are slow, your going to have to look a little deeper
at your code. As an example I had a wicked loop in my Auth and Menu
system which generated 250+ querys for something that should have only
been 13. Add to that a lazy find on my groups table which was bound to
my Users via a HABTM mapping netting more than a few thousand users
being pulled in for every cycle in this loop.

I guess my point is cake is very flexible. Flexible enough to let you
dig yourself a pretty deep hole. The DebugKit and FireCake has proven
to be a priceless set of tools for debugging (mainly because their
free) and they are very will put together, great examples of how to
write plugins. I would add a couple log statments in your
app_controller beforeFilter. spit out the controller and action that
is being called. This will show you a nice trace of what your app is
doing. I find this a good practice to run every once in a while. If
you want a real test write down on paper what you think the trace of
your app should look like for say logging in. Then log in and compare
I'm going to bet there some stuff happening that you wouldn't expect.


--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-06 Thread Miles J

1000 rows is nothing, try 100,000 rows, then that would possibly
stress test the database and models.
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-06 Thread jcorrea

Profiling my applications give me some good insights about where our
application is having bottlenecks.
The slow methods within cake core are:
1. Loading models takes a lot of the time (85% of the total time),
specifically at Model::__createLink
2. FormHelper::select with large lists

Is there any way to limit the model loading? maybe caching the object
the first time they are loaded?
Or do i have to re-engenieer my relations (cake's model relations) to
fit the performance requirement?
We could use bindModel all over the application but that's not the
idea.

On Mar 6, 9:07 am, Miles J mileswjohn...@gmail.com wrote:
 1000 rows is nothing, try 100,000 rows, then that would possibly
 stress test the database and models.
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-06 Thread Miles J

Well I use this technique, it only loads models that we need for that
current action. Cuts down the models tremendously.

http://www.milesj.me/blog/read/16/loading-models-specific-to-certain-actions
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-05 Thread Paul

Have you tried indexing your foreign keys?

I work on an app with a page that does about 100 minimum queries per
page load (it combines data from a lot of tables) and the query time
spent is only about 80ms.

On Mar 5, 6:10 am, Javier javier.cor...@gmail.com wrote:
 Hello everyone,
 I've read some posts about cakephp performance posted here and we've
 implemented some of the stuff discussed previously, but our
 application still have a really slow response time (it feels really
 really slow). We are using cake 1.2RC3 and we don't have an opcodes
 cache (like APC or xcache) installed yet.
 I have a few questions:
 Updating to CakePHP helps?
 Our application have a lot of models and relation between them, could
 this is be the cause of the slow response time? Can this be fixed/
 improved somehow?
 Does anyone have any tips to improve the performance of a cakephp
 application?
 Are there any plans on improving CakePHP performance on the near
 future?

 Thanks in advance for any reply.

--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-05 Thread Maine

Caching whole pages makes a difference: 
http://book.cakephp.org/view/346/Caching-in-the-Controller

--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-05 Thread Javier

Thx for the answers, here are some points:
1. We do have index on my DB (from primary keys and foreign keys
mainly), usually the DB access is really fast.
2. We aren't using the Containable behavior, but we make use of
bindModel and unBindModel to limit the queries produced
3. I just updated to 1.2 final 8004 and gain a little speed (thx!)
4. To develop we use Firefox with some add-ons (firebug, developer
toolbar, YSlow), and we test our application with a clean IE (we have
even tested it on Chrome who has a really fast javascript engine), in
all cases, the application has a very slow response time
5. Our css and js are both concatenated and obfuscated, so it
shouldn't be an issue. I'll try to profile the application, but right
now I can't install a profiler on our developer machine.
6. Our project has 68 models and 22 controllers, 2 plug-ins (with no
models and a few controllers). We make use of Auth and RequestHandler
components and HTML and Form helpers.
 Loading the initial page with debug=2 make a describe of all tables
(our models have lots of relations).
 Right now the application performance's about 1 request per second on
the initial page and the apache process use around 20MB of memory for
each request. Other pages take up to 4 or 5 seconds to load.

I'll try to get some profile info next time.

Any other good practices or tips to further improve the performance??
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-05 Thread AD7six



On Mar 5, 9:02 pm, Javier javier.cor...@gmail.com wrote:
 Thx for the answers, here are some points:
 1. We do have index on my DB (from primary keys and foreign keys
 mainly), usually the DB access is really fast.
 2. We aren't using the Containable behavior, but we make use of
 bindModel and unBindModel to limit the queries produced
 3. I just updated to 1.2 final 8004 and gain a little speed (thx!)
 4. To develop we use Firefox with some add-ons (firebug, developer
 toolbar, YSlow), and we test our application with a clean IE (we have
 even tested it on Chrome who has a really fast javascript engine), in
 all cases, the application has a very slow response time
 5. Our css and js are both concatenated and obfuscated, so it
 shouldn't be an issue. I'll try to profile the application, but right
 now I can't install a profiler on our developer machine.
 6. Our project has 68 models and 22 controllers, 2 plug-ins (with no
 models and a few controllers). We make use of Auth and RequestHandler
 components and HTML and Form helpers.
  Loading the initial page with debug=2 make a describe of all tables
 (our models have lots of relations).
  Right now the application performance's about 1 request per second on
 the initial page and the apache process use around 20MB of memory for
 each request. Other pages take up to 4 or 5 seconds to load.

 I'll try to get some profile info next time.

 Any other good practices or tips to further improve the performance??

When talking about performance, you are using debug = 0, right?

Your best course of action will always be to profile your app and
therefore *identify* what is slow rather than guess at the usual
suspects.

That said, if you have 68 models and they are all inter related (i.e.
you could if you want go from any model to any other model by
traversing associations) that means all 68 models will be loaded for
each page load. Using Persistent models, or modifying the way you're
using associations such that they aren't all inter-related would help
with that.

hth,

AD
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-05 Thread Miles J

Ill mention a few more things:

- Install the DebugKit. It has load timers for everything, the
controller, the views, etc so you can figure out whats taking the
longest.

- Look at all your queries and see what is taking the longest, and see
if you can lower what fields/relations are returned to shave off a few
milliseconds.

- Use containable compared to bind/unbind. Binding can be extremely
slow, because when you bind a model, that model has to load all its
relation models, and then that one does also, down and down. So it
could be very slow, containable disregards all this unless need be.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Cake performance tips

2009-03-04 Thread Javier

Hello everyone,
I've read some posts about cakephp performance posted here and we've
implemented some of the stuff discussed previously, but our
application still have a really slow response time (it feels really
really slow). We are using cake 1.2RC3 and we don't have an opcodes
cache (like APC or xcache) installed yet.
I have a few questions:
Updating to CakePHP helps?
Our application have a lot of models and relation between them, could
this is be the cause of the slow response time? Can this be fixed/
improved somehow?
Does anyone have any tips to improve the performance of a cakephp
application?
Are there any plans on improving CakePHP performance on the near
future?

Thanks in advance for any reply.
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-04 Thread Nate

Hint: that RC in the version identifier (1.2RC3) stands for release
candidate.  And the one that you have in particular is outdated by
several versions.  We have a final release now, and several minor
releases that have come after it.  That in itself is probably your
main issue.

On Mar 4, 3:10 pm, Javier javier.cor...@gmail.com wrote:
 Hello everyone,
 I've read some posts about cakephp performance posted here and we've
 implemented some of the stuff discussed previously, but our
 application still have a really slow response time (it feels really
 really slow). We are using cake 1.2RC3 and we don't have an opcodes
 cache (like APC or xcache) installed yet.
 I have a few questions:
 Updating to CakePHP helps?
 Our application have a lot of models and relation between them, could
 this is be the cause of the slow response time? Can this be fixed/
 improved somehow?
 Does anyone have any tips to improve the performance of a cakephp
 application?
 Are there any plans on improving CakePHP performance on the near
 future?

 Thanks in advance for any reply.
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-04 Thread keymaster

Have you tried profiling your app to see where time is going?

Is the bottleneck on the server side?
Or is it the http requests due to your js, css, flash, images, and
other client side stuff?

If you come to this list with more specific information, you'll
probably get a better response.



--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-04 Thread Miles J

Use containable instead of recursive. Thatll cut down a ton of
unnecessary queries.

My app currently has about 30 models and 40 database tables, all using
a ton of HABTM relations and it loads within 1 second.
--~--~-~--~~~---~--~~
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: Cake performance tips

2009-03-04 Thread brian

On Wed, Mar 4, 2009 at 4:17 PM, Miles J mileswjohn...@gmail.com wrote:

 Use containable instead of recursive. Thatll cut down a ton of
 unnecessary queries.

 My app currently has about 30 models and 40 database tables, all using
 a ton of HABTM relations and it loads within 1 second.

I'll second that. Containable makes for a much simpler task of getting
just what you want and not having to worry too much about whether a
recursive level that's necessary for one model will pull in 10 others,
as well. Also, run with debug = 2 to check what queries are being run,
though set that to 0 when you want to test for speed.

And, I should mention that I resolved an ugly slow-down in one app by
realising that the problem was with Firebug, not Cake. Make sure
you're profiling the right thing.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---