H
H
Hint2013-02-20 15:08:38
linux
Hint, 2013-02-20 15:08:38

Are the glob, readdir, etc. functions slowing down on the new server?

Moved a large blog from an old server to a new one. The client complained that the Tiny MCE editor, or rather TinyBrowser (file manager) became very slow. I began to understand and found out that the dirtree folder tree building function is slowing down.
On the old server, the function runs for about 50 ms, on the new one, almost 10 seconds (200 times slower). It looks like the glob and readdir functions are slowing down. The directories are identical: 3,000 folders, 80,000 files. At the same time, at the time of the function execution, the processor load is 100%, the disk load is 0% (looked through atop). What can be wrong?
Old server:
2 x Intel Xeon 5650, 16 GB RAM, 4 SAS drives in hardware RAID-10, Ext3 file system, Debian
New server:
2 x Intel Quad Core Xeon L5410, 16 GB RAM, 4 SAS drives in hardware RAID-10, Ext4 file system, CentOS 6
Dirtree feature:

function dirtree(&$alldirs, $root = '', $tree = '', $branch = '', $level = 0)
{
  if ($level == 0 && is_dir($root . $tree . $branch))
  {
    $filenum = count(glob($root . $tree . $branch . '*.*', GLOB_NOSORT));
    $topname = end(explode('/', rtrim($tree, '/')));
    $alldirs[] = array($branch, rtrim($topname, '/') . ' (' . $filenum . ')', rtrim($topname, '/'), rtrim($topname, '/'), $filenum, filemtime($root . $tree . $branch));
  }
  $level++;

  $dh = opendir($root . $tree . $branch);
  while (($dirname = readdir($dh)) !== false)
  {
    if (substr($dirname, 0, 1) != '.' && is_dir($root . $tree . $branch . $dirname) && $dirname != '_thumbs')
    {
      $filenum = count(glob($root . $tree . $branch . $dirname . '/' . '*.*', GLOB_NOSORT));
      $indent = '';
      for ($i = 0; $i < $level; $i++)
      {
        $indent .= '   ';
      }
      if (strlen($indent) > 0) $indent .= '→ ';
      $alldirs[] = array(urlencode($branch . $dirname . '/'), $indent . $dirname . ' (' . $filenum . ')', $indent . $dirname, $dirname, $filenum, filemtime($root . $tree . $branch . $dirname));
      dirtree($alldirs, $root, $tree, $branch . $dirname . '/', $level);
    }
  }
  closedir($dh);
  $level--;
}

Mount:
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext2 (rw)
/dev/sda4 on /tmp type ext4 (rw,noexec,nosuid,nodev)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/etc/named on /var/named/chroot/etc/named type none (rw,bind)
/var/named on /var/named/chroot/var/named type none (rw,bind)
/etc/named.rfc1912.zones on /var/named/chroot/etc/named.rfc1912.zones type none (rw,bind)
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)
/usr/lib64/bind on /var/named/chroot/usr/lib64/bind type none (rw,bind)
/etc/named.iscdlv.key on /var/named/chroot/etc/named.iscdlv.key type none (rw,bind)
/etc/named.root.key on /var/named/chroot/etc/named.root.key type none (rw,bind)

dmesg: pastebin.com/eZpGvnva

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
Hint, 2013-02-22
@Hint

It turned out that the problem was in the Plesk Panel. I put the OS - everything is fine, I put Plesk - disk operations start to slow down.

A
Andrey Burov, 2013-02-20
@BuriK666

Show output of mount and dmesg

N
Nikolai Turnaviotov, 2013-02-20
@foxmuldercp

iowait, iostat what do they write on both machines?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question