Tuesday, November 17, 2015

browser performance sucks on NFS -- "waiting on cache"

I've got a server where all the drives live and use NFS to export home directories to other machines. You might do the same with a NAS.

After updating one of the client machines to Ubuntu 15.10 I noticed the browser performance was terrible. Lots of time "waiting on cache". I checked the load on the server and it is not CPU bound. Clearing the cache did not help ('cause its Unix not DOS).

So I tried tuning NFS to see if that helped. Since I have NFS v4, pretty much all the advice was already in place. Added async,relatime to the mount options which helped but not much.

As it happens, most of the stuff our browser saves ends up in a folder/directory called .cache (this is at least true on Ubuntu). So I set up a bind mount on the client so that folder is on local disk and not on NFS. Performance is now back to normal.

What the bind mount does is mount part of a local file system on part of a remote file system. You have to do this on the client as it is not something the server can do for you. That is nice as you only have to have it where you need it. But it means setting this up on each client and for each user.

Here are the steps:

  1. Create a place for local caches for as many users as you might have. Should be under /var. /var/cache exists so I created /var/usercache/ and changed the owner ship to the user
    sudo mkdir /var/usercache/
    sudo chown : /var/usercache/
  2. Copy the existing .cache over:
    cp -rp ~/.cache/* /var/usercache/
  3. Edit /etc/fstab to add the bind mount:
    sudo vi /etc/fstab
  4. append to the end of the file:
    /var/usercache/ /home//.cache none bind
  5. mount /home//.cache or reboot

No comments:

Post a Comment