MarcM
MarcM

Reputation: 2251

How to debug bad performance on code igniter 3 + sql_server 2008

On a project developed with Code Igniter 3.0.1 accessing to a SQL_server 2008 database I get very bad response times when using the 'real' database. (>5 seconds for serving any page).

The same project tested in several test environements works fine, with 'normal' output times (<1 second).

So I imagine there's some performance issue with real database. But none other DB applications seem to have any perfomance problems. Real DB Admin says 'Everything is fine with our database. No one else has any problem.'

I'm stucked. Don't know what else to try.

How can I debug to find out where the performance issue is? Any help or hint will be appreciated.


Detailed versions of tools and environements used:

Real environment: Web server: XAMPP 5.5.30 on windows 7. Database server: SQL_server 2008 on Windows Server 2008 R2 Standard.

Several test environements: Web server: same XAMPP 5.5.30 on windows 7 and windows 10. Also tested with older XAMPP versions. Database server: SQL_server 2008 Express and SQL_server 2014 Express. On windows 7 and windows 8.

Network: Tested both in the same computer as XAMPP and in diferent computers. Tested in the same network as real environement and tested in other networks.

DB Driver: Using native drivers to connect to sql_server:

$db['my_db_name'] = array(
    'dsn'    => '',
    'hostname' => 'my_server\SQLEXPRESS',
    'username' => 'xxx',
    'password' => 'yyy',
    'database' => 'zzz',
    'dbdriver' => 'sqlsrv',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => TRUE,
    'cache_on' => FALSE,
    'cachedir' => 'application/cache',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'autoinit' => TRUE,
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

Upvotes: 0

Views: 249

Answers (1)

Eric Hansen
Eric Hansen

Reputation: 26

There's a few ways to start looking into this locally:

  • Install a profiler (Xdebug functions as a 2-in-1 for this) and use a cache grind viewer (phpStorm supports this but there's other tools out there) to see the bottlenecks
  • Use an APM like NewRelic to drill down into different calls and queries (I don't know if profilers like Xdebug or xhprof go as deep as queries)
  • Ensure your database is indexed and structured properly (this seems to me the most likely since the issue is on database calls)

Upvotes: 1

Related Questions