Solved

CakePhp RAM overload

Posted on 2010-09-07
3
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Node.js 11 77
How to show popup no matter what a user clicks on navigation wise 10 62
How to remove  "0":  in a json string 4 44
PHP substring 3 50
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

739 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