Solved

CakePhp RAM overload

Posted on 2010-09-07
3
451 Views
Last Modified: 2012-06-21
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
Comment
Question by:ioustinos_sarris
3 Comments
 
LVL 14

Expert Comment

by:sentner
ID: 33619108
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
 
LVL 2

Expert Comment

by:ondrejsimek
ID: 33720658
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
 

Accepted Solution

by:
ioustinos_sarris earned 0 total points
ID: 33955705
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now