Welcome Guest, Not a member yet? Register   Sign In
Sporadic slowness
#1

[eluser]imorris[/eluser]
I have a codeigniter app that I've deployed that I'm seeing sporadic slowness with. Sometimes the controller/page will take .5 seconds to load and sometimes it will take 5+ seconds to load. Do you have any advice you can provide in regards to troubleshooting this issue?

We've enabled profiling and don't see any abnormalities and we also don't see any issues in the apache logs.

This same application runs fine from my local PC, pointed at the same database.

The database is isolated on its own server.
#2

[eluser]Phil Sturgeon[/eluser]
If you are using Windows sometimes CodeIgniter can have trouble making multiple writes to the log file so it ends up getting CRAZY slow. I had the same issue with 10+ second loads when config threshold was up to 4.
#3

[eluser]imorris[/eluser]
Phil,
That was a really good idea about the logging but I have it set to "0". The app is setup on an Ubuntu server.
#4

[eluser]imorris[/eluser]
Any other things I can look at to fix the sporadic performance issue?
#5

[eluser]Pascal Kriete[/eluser]
Quote:We’ve enabled profiling and don’t see any abnormalities and we also don’t see any issues in the apache logs.

This makes it sound like it may be a network latency issue to the web server.

If you turn on the profiler or add {elapsed_time} to the page. On one of the slow loads, how long does it say it took to execute?
#6

[eluser]imorris[/eluser]
Here's my welcome/index:
Code:
$this->output->enable_profiler(TRUE);
        
$this->benchmark->mark('my_mark_start');
$this->load->model('Member_model','',TRUE);
$this->benchmark->mark('my_mark_end');
        
$this->benchmark->mark('my_mark1_start');
$data['Members'] = $this->Member_model->get_members();
$this->benchmark->mark('my_mark1_end');

$this->benchmark->mark('my_mark2_start');
$data['checkins'] = $this->Member_model->get_last_ten_checkins();
$this->benchmark->mark('my_mark2_end');

$this->benchmark->mark('my_mark3_start');
$this->load->view('welcome_message',$data);
$this->benchmark->mark('my_mark3_end');


Here's my profiler:

Code:
Loading Time Base Classes   0.0080
My Mark   0.0023
My Mark1   0.0041
My Mark2   0.0013
My Mark3   0.0007
Controller Execution Time ( Welcome / Index )   5.0368
Total Execution Time   5.0448

My question is...My total profiler controller time is 5 seconds but my "mark" time is less than one second. How can I find out where the other 4.5 seconds are coming from?
#7

[eluser]Pascal Kriete[/eluser]
Eeek! Are you autoloading anything? If it slows down that much it must be something happening in the constructor, or in CI's parent controller.

In CI 1.7.2 (which is what I assume you're on), the autoloading step happens in the parent constructor. So to benchmark it you'll need to tweak your own a little bit:
Code:
class Welcome extends Controller {

    function Welcome()
    {
        // instead of parent::Controller();
        parent::CI_Base();
        
        global $BM;
        
        $BM->mark('initialize_start');
        $this->_ci_initialize();
        $BM->mark('initialize_end');
    }
}
#8

[eluser]imorris[/eluser]
The only thing I'm autoloading is 'databases' and 'DXAuth'.

I made the change as you suggested and here's what I got for output. What is "Initialize" and why is it taking so long?

Code:
Loading Time Base Classes   0.0077
Initialize   5.3600
My Mark   0.0034
My Mark1   0.0043
My Mark2   0.0013
My Mark3   0.0013
Controller Execution Time ( Welcome / Index )   5.3705
Total Execution Time   5.3783
#9

[eluser]Pascal Kriete[/eluser]
Initialize is where the autloading is happening. Try removing the autoloaded stuff libraries one by one to see if that makes it go down.
#10

[eluser]imorris[/eluser]
I've stopped autoloading DX_Auth. The only thing I'm autoloading now is my database. I'm still seeing sporadic slowness. Is there a way I can Benchmark the load and the connection process of the database?




Theme © iAndrew 2016 - Forum software by © MyBB