load user's picture very slow

load user's picture very slow

by Shwu-Fen Kuo -
Number of replies: 17

I have installed moodle 1.9.5 on ubuntu 12.04 LTS, apache 2.2.22, php 5.3.10-1 ubuntu3.2.

I'm trying to view a course participants list, then the users pictures load very slowly.

It almost takes 2~3 minutes to  load this page completed.

does anyone know the problem?


Thanks.

Average of ratings: -
In reply to Shwu-Fen Kuo

Re: load user's picture very slow

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

You wrote:
> I have installed moodle 1.9.5 on ubuntu 12.04 LTS, apache 2.2.22, php 5.3.10-1 ubuntu3.2.

"Please include as much background information as possible about your hardware, the operating system, the web server, the database server, the PHP scripting framework, etc. If your machine is virtualized, also mention the host hardware, the operating system, the virtualization technology used and the resources assigned to the guest OS. If you use a hosting service, mention either the hosting provider and the package or the resources they've allocated to your Moodle instance."
http://moodle.org/mod/forum/view.php?id=596

Also tell us how you installed by linking to the documentation from http://docs.moodle.org/19/en/Category:Installation.

> It almost takes 2~3 minutes to load this page completed.

Could also be a severe configuration problem. Post the relevant lines of your moodle/config.php. Don't forget to "annonymize" your domain name and hide passwords!
In reply to Visvanath Ratnaweera

回應: Re: load user's picture very slow

by Shwu-Fen Kuo -

The system is installed on Virtual machine.(vmware)

OS:ubuntu 12.04 LTS,
web server:apache 2.2.22
database server:mysq l5.1.34
php:5.3.10-1 ubuntu3.2

I found the root cause is pix.php. When I view participans list, system will load the user's picture via pix.php(If user has uploaded his picture).

There are many people in list, so the pix.php is executed many times.

But I still don't know how to solve this problem, maybe is server's configuration.

In reply to Shwu-Fen Kuo

回應: Re: load user's picture very slow

by Shwu-Fen Kuo -

below is modules installed about apache2:

root@Moodle1:/etc/php5/apache2/conf.d# dpkg -l '*apache2*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                          Version                                       Description
+++-=============================================-============================
ii  apache2                                       2.2.22-1ubuntu1                               Apache HTTP Server metapackage
un  apache2-common                                <none>                                        (no description available)
un  apache2-doc                                   <none>                                        (no description available)
un  apache2-mpm                                   <none>                                        (no description available)
un  apache2-mpm-event                             <none>                                        (no description available)
un  apache2-mpm-itk                               <none>                                        (no description available)
un  apache2-mpm-perchild                          <none>                                        (no description available)
ii  apache2-mpm-prefork                           2.2.22-1ubuntu1                               Apache HTTP Server - traditional non-threaded model
un  apache2-mpm-threadpool                        <none>                                        (no description available)
un  apache2-mpm-worker                            <none>                                        (no description available)
un  apache2-suexec                                <none>                                        (no description available)
un  apache2-suexec-custom                         <none>                                        (no description available)
ii  apache2-utils                                 2.2.22-1ubuntu1                               utility programs for webservers
ii  apache2.2-bin                                 2.2.22-1ubuntu1                               Apache HTTP Server common binary files
ii  apache2.2-common                              2.2.22-1ubuntu1                               Apache HTTP Server common files
un  libapache2-mod-apparmor                       <none>                                        (no description available)
un  libapache2-mod-perl2                          <none>                                        (no description available)
un  libapache2-mod-php4                           <none>                                        (no description available)
ii  libapache2-mod-php5                           5.3.10-1ubuntu3.2                             server-side, HTML-embedded scripting language (Apache 2 module)
un  libapache2-mod-php5filter                     <none>                                        (no description available)

below is modules installed about php:

root@Moodle1:/etc/php5/apache2/conf.d# dpkg -l '*php*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                          Version                                       Description
+++-=============================================-=================================
un  libapache2-mod-php4                           <none>                                        (no description available)
ii  libapache2-mod-php5                           5.3.10-1ubuntu3.2                             server-side, HTML-embedded scripting language (Apache 2 module)
un  libapache2-mod-php5filter                     <none>                                        (no description available)
ii  php-apc                                       3.1.7-1                                       APC (Alternative PHP Cache) module for PHP 5
ii  php-pear                                      5.3.10-1ubuntu3.2                             PEAR - PHP Extension and Application Repository
un  php-xml-util                                  <none>                                        (no description available)
un  php4-pear                                     <none>                                        (no description available)
ii  php5                                          5.3.10-1ubuntu3.2                             server-side, HTML-embedded scripting language (metapackage)
un  php5-cgi                                      <none>                                        (no description available)
ii  php5-cli                                      5.3.10-1ubuntu3.2                             command-line interpreter for the php5 scripting language
ii  php5-common                                   5.3.10-1ubuntu3.2                             Common files for packages built from the php5 source
ii  php5-curl                                     5.3.10-1ubuntu3.2                             CURL module for php5
ii  php5-dev                                      5.3.10-1ubuntu3.2                             Files for PHP5 module development
un  php5-fpm                                      <none>                                        (no description available)
ii  php5-gd                                       5.3.10-1ubuntu3.2                             GD module for php5
un  php5-json                                     <none>                                        (no description available)
un  php5-mhash                                    <none>                                        (no description available)
ii  php5-mysql                                    5.3.10-1ubuntu3.2                             MySQL module for php5
un  php5-mysqli                                   <none>                                        (no description available)
un  php5-mysqlnd                                  <none>                                        (no description available)
un  php5-suhosin                                  <none>                                        (no description available)
un  php5-xcache                                   <none>                                        (no description available)
ii  php5-xmlrpc                                   5.3.10-1ubuntu3.2                             XML-RPC module for php5
ii  php5-xsl                                      5.3.10-1ubuntu3.2                             XSL module for php5
un  phpapi-20090626                               <none>

In reply to Shwu-Fen Kuo

Re: 回應: Re: load user's picture very slow

by Matt Clarkson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

It could be session contention - are you using file or database for session storage? If using file storage is it on local disk or NFS mounted?

In reply to Matt Clarkson

回應: Re: 回應: Re: load user's picture very slow

by Shwu-Fen Kuo -

The sessions are stored in storage with NFS mounted.

What is "session contention" mean? how to solve?


Thanks.

In reply to Shwu-Fen Kuo

Re: 回應: Re: 回應: Re: load user's picture very slow

by Matt Clarkson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Session contention occurs when the same moodle session is accessed by many PHP processes at the same time. In your case, each request to pix.php will be trying to access the session and but has to wait until the session has been closed by a prevous instance if pix.php accessing the session.

This problem is particulary bad on NFS due to extra latency and locking that occurs with NFS. If you only have one webserver try storing your moodledata on local disk. Otherwise you could try storing you session in the database.

My preferred choice for session storage is Memcached, however this requires some patches to Moodle.

Average of ratings: Useful (2)
In reply to Matt Clarkson

回應: Re: 回應: Re: 回應: Re: load user's picture very slow

by Shwu-Fen Kuo -

Thanks for your reply.

But I don't understand, we have another moodle site and it is work normal.

That moodle site is installed on solaris 10, Apache/2.2.11, php 5.2.6.

They use the same database server(mysql), database(mysql) and NFS storage to store sessions/files/moodle code.

(please refer to below graph)

If NFS storage is root cause, why the old environment(solaris) is work normal?

Thanks.

In reply to Shwu-Fen Kuo

Re: 回應: Re: 回應: Re: 回應: Re: load user's picture very slow

by Matt Clarkson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

It could be different behaviour between Linux NFS client vs the Solaris NFS client. Or it may not be session contention at all, but it's definitely worth experimenting with changing the session storage.

In reply to Shwu-Fen Kuo

Re: load user's picture very slow

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Shwu-Fen

So you have Moodle code, session files, moodledata and the database externally. What are the two servers (solaris and ubuntu) doing then?

About the NFS, why don't you shift Moodle code, session files and moodledata one by one to the local disk temporarily and test? OK, I know, at least in the case of Ubuntu it is a VMware disk. If Solaris is physical, that is the next thing you must check, whether Ubuntu on a physical server makes a difference.

BTW, is you MySQL server also virtual?
In reply to Visvanath Ratnaweera

回應: Re: load user's picture very slow

by Shwu-Fen Kuo -

Default, the sessions/files are saved in $CFG->dataroot.
So I assigned $CFG->dataroot to local disk, then the problem is solved.

But now,I want to make files saved in NFS storage because the size of files is very huge.

What can I do let session stored in local disk and file stored in NFS storage?

Does assign the 'session.save_path' in php.ini to save session, still assign $CFG->dataroot to NFS storage(store files)?

Thanks.

In reply to Shwu-Fen Kuo

Re: load user's picture very slow

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

You wrote:
> I assigned $CFG->dataroot to local disk, then the problem is solved.

Congratulations! That is a big piece of evidence. Credit goes to Matt for bringing up this possibility.

> But now,I want to ...

Before continuing pl. reread my previous post. There were couple of questions which you failed to answer. Your setup is quite complicated. Those questions help to understand what you are doing.
In reply to Visvanath Ratnaweera

回應: Re: load user's picture very slow

by Shwu-Fen Kuo -

MySQL server is real device.

The solaris server is our old moodle server, we want to change the service in Virtual machine(i.e. Ubuntu).

Now in testing step, we just maintenance one moodle code in NFS storage.

In reply to Shwu-Fen Kuo

Re: load user's picture very slow

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Shwu-Fen

You wrote:
> MySQL server is real device.

If you browse the web, you'll see that the (virtual) hard disk get bad marks in the (desktop) virtualization world. Therefore have a physical server is a sensible thing.

> The solaris server is our old moodle server,

Assume it is a physical machine too,

> we want to change the service in Virtual machine(i.e. Ubuntu).

which will be replaced by an Ubuntu Linux server?

> Now in testing step, we just maintenance one moodle code in NFS storage.

So this complicated setup is only during the testing period?

Then, there is no need to change to moodle scripts during testing. Why don't you simply pull a copy into the Ubuntu Linux?

Matt has answered the session-files problem. You have to have them somewhere. As you found out yourself NFS is a bad place. The other two possibilities are: to have them either in the local disk or let the database handle them. You have to try both, assuming that your Solaris and Ubuntu are not in a load balance setup (in which case you can't have session-data in the local disk).
In reply to Visvanath Ratnaweera

回應: Re: load user's picture very slow

by Shwu-Fen Kuo -

In the future, we'll do load balance. So the session need to store database.

In reply to Shwu-Fen Kuo

Re: 回應: Re: load user's picture very slow

by Matt Clarkson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Firstly, try doing another test and enabling database session storage. Since you're on MySQL that may perform OK.

If that doesn't work, you will need set $CFG->respectsessionsettings = true in your config.php, this will make moodle respect your sessions settings in the php.ini.

In reply to Matt Clarkson

回應: Re: 回應: Re: load user's picture very slow

by Shwu-Fen Kuo -

If the sessions are store in database, it will increase MySQL server's loading?

I mean the session access is frequently or not, because we had encountered MySQL locking situation before.

In reply to Shwu-Fen Kuo

Re: 回應: Re: 回應: Re: load user's picture very slow

by Matt Clarkson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Yes it will increase the load on your MySQL server. Locking may be an issue with MySQL, but it's worth testing to find out.