Solved

CakePhp RAM overload

Posted on 2010-09-07
3
454 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

786 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