Performance Issues - ODBC and yiiframework

Hello community,

I am working on a web solution for displaying some information from some databases with yiiframework. In the background there is a Ingres DB and with an ODBC driver I am getting the needed information. For the website I am using an apache2 server (based on Linux).

The connection to the database works, but I have very long charging times but don’t know why. The ODBC driver should not be the problem, with an ISQL command I am getting the information of the database in a few seconds.

  • debug mode is off
  • by using caching the sites load very fast

Should I upload my code somewhere?

Thanks in advance!

Can you try enabling the debug panel and see what you get in the profiling tab?

Is the Ingres DB and Yii running on the same server, or separate ones?

Can you try enabling the debug panel and see what you get in the profiling tab?

can you tell me, how I can do this?

Is the Ingres DB and Yii running on the same server, or separate ones?

The Ingres DB and Yii are running on different server, but unfortunately that’s not to change…

You can install the yii2-debug extension by following this guide: https://github.com/yiisoft/yii2-debug#installation

You should end up with something like this on your website:

The Logs section will show you some traces, like the time it takes to open the connection to the database, perform queries, etc. This will allow you to understand exactly what’s going on, and spot the place where time is wasted (if you see a big jump in timestamp, focus on that part)

The Ingres DB and Yii are running on different server, but unfortunately that’s not to change…

Separate servers is a good thing :+1: I was asking to know the setup. In the case of separate servers, a common problem is the connection overhead.

Thanks! I have some problems by installing the composer.
I have installed it but can’t use the command:

php composer.phar require --prefer-dist yiisoft/yii2-debug

Im am getting the message:
Cannot create cache directory /home/abntlfz/.composer/cache/repo/https—repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/abntlfz/.composer/cache/files/, or directory is not writable. Proceeding without cache
./composer.json is not writable.

Do you know, what is to do?

The command line user lacks write permission.

I have tried to run it with sudo … but that isn’t possible:
Do not run Composer as root/super user! See https://getcomposer.org/root for details

Is there a other possibility?

You should fix your rights.

For now you could just do a sudo chmod o+w composer.json and run the composer install again.

Sorry, but I have some problems while installing composer.

At first, I wanted to install it via:
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

But, I don’t know why, I can’t connect to the site to download the file. So I have downloaded it manually and copied the file to the root directory, where I have “installed” it. With ./composer I see, that it works.

Now I want to use the command:
php composer.phar require --prefer-dist yiisoft/yii2-debug but I am only getting the message “Do not run composer as super user…”.

Now I don’t know, what I could do, to fix this. Sorry, but I’ve tried many things and didn’t get it fixed. Thanks in advance!

oh, just change php composer.phar by ./composer then

Thanks for your fast reply. Then I have the problem again with creating cache directory:

Cannot create cache directory /home/abntlfz/.composer/cache/repo/https—repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/abntlfz/.composer/cache/files/, or directory is not writable. Proceeding without cache

I have the possibility to use root or my user abn… but with root, composer don’t let me do anything as super user and with my user I have not enough rights…

Edit: Oh I think mybe it worked? My command line shows the following:
> Cannot create cache directory /home/abntlfz/.composer/cache/repo/https—repo.packagist.org/, or directory is not writable. Proceeding without cache

Cannot create cache directory /home/abntlfz/.composer/cache/files/, or directory is not writable. Proceeding without cache
Using version ^2.0 for yiisoft/yii2-debug
./composer.json has been updated

In composer.json is now:
{
“yiisoft/yii2-debug”: “~2.0.0”,
“require”: {
“yiisoft/yii2-debug”: “^2.0”
}
}

Is it enough to set “defined(‘YII_DEBUG’) or define(‘YII_DEBUG’, true);” in index.php true? If yes, then maybe it didn’t worked because by reloading the page I dont see the composer debug window (like described).

No, you might need more things.

First off, composer warns about not using cache, then it continues.
Check if vendor/yiisoft/yii2-debug is created, if so, it’s installed.

As for the configuration, you should read the guide, there are more steps involved than setting YII_DEBUG to true: https://github.com/yiisoft/yii2-debug#usage

For a simple test it should be enough to set the debug var = true and insert the IP of the webpage in web.php, or? ‘allowedIPs’ => [‘190.16.200.155’, ‘::1’],

Is the part open files in IDE optional or isn’t it?

Yes it is.
Did you add the “debug” module to the bootstrap section?

The debug section was already there. Now my web.php file contains the following:

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        'allowedIPs' => ['172.16.200.155', '::1'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        'allowedIPs' => ['172.16.200.155', '::1'],
    ];
}

Is your Yii env set to dev? Try changing if (YII_ENV_DEV) { temporarly to if (true) { so see if that’s the problem.

Yes, my index.php contains:
// comment out the following two lines when deployed to production
defined(‘YII_DEBUG’) or define(‘YII_DEBUG’, true);
defined(‘YII_ENV’) or define(‘YII_ENV’, ‘dev’);

But I have changed it in web.php to (true) but I can’t see any debug tool. Maybe there is something wrong with the composer? Have I after running php composer.phar require --prefer-dist yiisoft/yii2-debug something else to do with the composer?

Could you send me an message? With my other account, I only can write 18 messages per day. Thanks! :slight_smile:

So we had a private chat, and it turns out that the debug panel is now showing, and the problem seems indeed to be that establishing the connection needs more than 4 seconds.

The reason of the slowness should be first fixed between the two servers, without regards to Yii. Then it should be way better.

Yes, yii isn’t the problem and machhour was a great help! Thanks.