• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

CakePhp RAM overload

Hi there,
We are using the CakePhp framework for a website we have built.
A few days ago, at an expected peak of concurrent traffic our server with 8GB of RAM crashed due to insufficient RAM resources!!
While trying to see what caused this problem, we found out that each page load uses up to 20mb of ram without taking into account mysql's ram usage.

I find those 20MB of RAM way too high for php files, and i would not expect a widely used framwork to perform that badly, so i guess we have done something wrong.

Can anybody guide me to find out what i am doing wrong?? If i am doing something wrong...
0
ioustinos_sarris
Asked:
ioustinos_sarris
1 Solution
 
sentnerCommented:
Without seeing your website code, it's difficult to know what your problem is... It may be that you are making copies of the data for each hit, rather than using shared memory, or that you are reading in far more than is necessary for a single page load.
0
 
ondrejsimekCommented:
It can be anything, but I think it's probably because of the Cake ORM - I had simillar problems.

Does your AppModel look like the one I've attached? $recursive = -1 means that no data from related models are fetched. And Containable behavior is kind of replacement for the recursion (that you've lost with $recursive = -1).

Don't use $recursive - leave it on -1. Since you can use Containable, there is no reason for using $recursive.

Always specify which fields you want to fetch.

I've attached an example find(), so you can see how it should look like when you do all the things I've described.
class AppModel extends Model
{
    public $recursive = -1;
    public $actsAs = array ('Containable');
}

// an example find()
$this->Article->find('first', array (
    'fields' => array (
        'Article.id',
        'Article.title',
        'Article.perex',
        'Article.content',
        'Article.published',
    ),  
    'conditions' => array (
        'Article.id' => $id,
    ),  
    'contain' => array (
        'Category.id',
        'Category.title',
    ),  
));

Open in new window

0
 
ioustinos_sarrisAuthor Commented:
Well the footprint of cakePhp is about 20mb.
With the usage of APC, html caching and some optimizations on my apache i managed to make it 8mb and save my problems
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now