• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
database connection constantly over 1 second

#1
[eluser]Sweden[/eluser]
Hello!
I’m having a problem with CodeIgniter that it’s taking over 1 second to load every time.
I have navigated this down to being problem with the database connection that’s taking over 1 second to connect.

I’ve read some people having this issue too in PHP who have solved it by changing the server from “localhost” to 127.0.0.1, this however only solves it for me in application not using CodeIgniter.

I’ve come to this after disabling everything on autoload (Controller Execution Time: 0.0029), but when putting database on autoload it gets slow (Controller Execution Time: 1.0172) even when no queries are run.

Does anyone have any idea what could be causing this?
Some settings:

Code:
$config['sess_cookie_name']  = 'ci_session';
$config['sess_expiration']  = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'ci_sessions';
$config['sess_match_ip']  = TRUE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update'] = 300;

$db['default']['hostname'] = 'mysql:127.0.0.1';
$db['default']['username'] = DBUSER;
$db['default']['password'] = DBPASS;
$db['default']['database'] = DATABASE;
$db['default']['dbdriver'] = 'pdo';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

#2
[eluser]yacman[/eluser]
Have you tried a pattern like:
Code:
$db['default']['hostname'] = 'mysql:host=127.0.0.1;';

#3
[eluser]Sweden[/eluser]
Hi!
Thanks for your reply and your idea, it did however not solve the problem.

If anyone else have any idea for this, please let us know, we are really looking for a solution for this.

#4
[eluser]xerobytez[/eluser]
Have you tried running this on a different machine, perhaps with a fresh httpd and mysqld stack? Could be something going on with the daemon's themselves?

#5
[eluser]Sweden[/eluser]
Hello!

I will see if I'm able to try it on another PC tomorrow, but all I need to do to replicate this is to set the below settings, so maybe there is something wrong with the machine, but using "plain and simple" script with just the "new PDO..." code connects instantly... Hmm

Code:
$autoload['libraries'] = array('database');

$db['default']['hostname'] = 'mysql:127.0.0.1';
$db['default']['username'] = 'xxx';
$db['default']['password'] = 'xxx';
$db['default']['database'] = 'xxx';
$db['default']['dbdriver'] = 'pdo';


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.