Nick Zinger
Nick Zinger

Reputation: 1174

CakePHP - optimizing specific urls by stripping down unnecessary functionality

Besides the obvious like caching pages, using recursive and containable, what is a good way to really minimize the memory footprint on certain urls, without just going out and writing flat php?

For example, I have certain controller actions (and model methods) that have minimal interaction with the rest of the system but are accessed frequently by many users at the same time.

Or another example would be an API endpoint. It only pulls some specific data, but uses way more memory than it should.

Any way to optimize these actions but still staying within CakePHP? (maybe by selectively disabling some heavy CakePHP stuff for them)

I'm currently on CakePHP 1.3.x, but moving to 2.x is on my todo list.

Upvotes: 1

Views: 53

Answers (1)

floriank
floriank

Reputation: 25698

I'm currently on CakePHP 1.3.x, but moving to 2.3 is on my todo list.

Move to 2.x which will give you a boost of sometime 50% better performance and I think also less memory usage. 2.0 loads models and other things lazy. So if something is not needed it won't be loaded as long as it is not needed. You can get that lazy loading for models for 1.3 as well. See https://github.com/lorenzo/lazy_loader

It only pulls some specific data, but uses way more memory than it should.

Well, how do you know that? Did you profile the request? If yes what was the slowest or most memory eating method call? It is impossible to give any advice besides caching without know and profiling the code.

I would not waste more time with optimizing the old 1.3 app much when you're going to switch to 2.x soon. Why do you want to go for 2.3? There is already 2.4 and 2.5 is coming.

Upvotes: 2

Related Questions