?
Solved

CakePhp RAM overload

Posted on 2010-09-07
3
Medium Priority
?
461 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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 dynamically set the form action using jQuery.
Suggested Courses

765 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