How to improve performance on codeigniter

Viewed 3077

I have a program written with Codeigniter which turns out to be very slow when logging out.

When I debug the program, I realize that there is a step that lasts for 10 s

Session: Class initialized using 'files' driver

here is the complete debug

INFO - 2017-09-20 12:56:05 --> Config Class Initialized
INFO - 2017-09-20 12:56:05 --> Hooks Class Initialized
DEBUG - 2017-09-20 12:56:05 --> UTF-8 Support Enabled
INFO - 2017-09-20 12:56:05 --> Utf8 Class Initialized
INFO - 2017-09-20 12:56:05 --> URI Class Initialized
INFO - 2017-09-20 12:56:05 --> Router Class Initialized
INFO - 2017-09-20 12:56:05 --> Output Class Initialized
INFO - 2017-09-20 12:56:06 --> Security Class Initialized
DEBUG - 2017-09-20 12:56:06 --> Global POST, GET and COOKIE data sanitized
INFO - 2017-09-20 12:56:06 --> Input Class Initialized
INFO - 2017-09-20 12:56:06 --> Language Class Initialized
INFO - 2017-09-20 12:56:06 --> Loader Class Initialized
INFO - 2017-09-20 12:56:06 --> Helper loaded: url_helper
INFO - 2017-09-20 12:56:06 --> Controller Class Initialized
INFO - 2017-09-20 12:56:06 --> Database Driver Class Initialized
INFO - 2017-09-20 12:56:06 --> Helper loaded: string_helper
INFO - 2017-09-20 12:56:06 --> Helper loaded: form_helper
INFO - 2017-09-20 12:56:06 --> Helper loaded: language_helper
DEBUG - 2017-09-20 12:56:06 --> Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.
INFO - 2017-09-20 12:56:06 --> Session: Class initialized using 'files' driver.
INFO - 2017-09-20 12:56:16 --> Language file loaded: language/french/messages_lang.php
INFO - 2017-09-20 12:56:16 --> File loaded: C:\wamp\www\SESAME\application\views\template/header.php
INFO - 2017-09-20 12:56:16 --> File loaded: C:\wamp\www\SESAME\application\views\connect_user.php
INFO - 2017-09-20 12:56:16 --> File loaded: C:\wamp\www\SESAME\application\views\template/footer.php
INFO - 2017-09-20 12:56:16 --> Final output sent to browser
DEBUG - 2017-09-20 12:56:16 --> Total execution time: 10.8679

Can you help me find the cause of this low performance?

2 Answers

I think "Session: Class initialized using 'files' driver." taking time.

Files Driver: The ‘files’ driver uses your file system for storing session data.

AS per Codeigniter Session documentation you can change storage engine session in database or other places like files, redis, memcached.

$config['sess_driver'] = 'database';
$config['sess_save_path'] = 'ci_sessions';


CREATE TABLE IF NOT EXISTS `ci_sessions` (
        `id` varchar(128) NOT NULL,
        `ip_address` varchar(45) NOT NULL,
        `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
        `data` blob NOT NULL,
        KEY `ci_sessions_timestamp` (`timestamp`)
);

Also, you can set absolute path :

To be more specific, it doesn’t support PHP’s directory level and mode formats used in session.save_path, and it has most of the options hard-coded for safety. Instead, only absolute paths are supported for $config['sess_save_path'].

I think I found the cause to my problem.

In fact, it is a rather heavy class that my controller was loading every time (registered_user - when I comment it, the program becomes much faster - )

public function __construct() {
    parent::__construct();
    $this->load->model('user_inscription');
    $this->load->model('user_connexion');
    $this->load->model('mouchard');
    $this->load->model('synchronisation');
    $this->load->helper('string');
    $this->load->helper('form');
    $this->load->helper('language');
    $this->load->library('session');
    //$this->load->library('registered_user');
    $this->load->library('sendsms');
}

and here is the class. It connects to an oracle database. I don't know why it takes so much time to instanciate.

class Registered_user {

    private $query;
    private $connexion;

    public function __construct($host, $port, $serviceName, $user, $passwd) {
        $baseLink = '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(Host = ' . $host . ')(Port = ' . $port . '))) (CONNECT_DATA = (SERVICE_NAME = ' . $serviceName . ')))';
        $this->connexion = oci_connect($user, $passwd, $baseLink);
    }

    public function getConnexion() {
        return $this->connexion;
    }

    public function setQuery($query) {
        /*set the query*/
    }

    public function getInfos() {

        $stid = oci_parse($this->connexion, $this->query);
        oci_execute($stid);

        $row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS);

        return $row;
    }

}
Related