Saturday, 8 February 2014

Synology Diskstation Performance Tuning

I'm lucky enough to own a couple of Synology Diskstation NAS devices. They are excellent devices, but when they're overloaded they don't feel so great, so here's how I reduced the load and increased the performance.

How to Tell When a Diskstation is Overloaded

Strictly speaking the diskstation is overloaded when the load, divided by the number of CPUs plus Hyperthreads, exceeds 1.0, and this number indicates the number of processes that are using the cpu or waiting for the cpu to be ready. So a system running at a load of 1.0 is utilising its cpu perfectly, neither the cpu or processes are waiting for each other. A load of 1.5 means that processes were waiting for cpu time for 50% of the time that the load average was taken. This waiting time is felt as lag or unresponsiveness.

The load can be subjective, but there's one metric that Synagios takes that really will show a poorly performing box, and that metric is Swap Activity. This is the amount of actual swapping the system is doing, transferring data to or from the swap file, and if swap activity is high then performance will be poor. The following graph shows the swap activity on my DS112 before and after tuning.

Swap Activity - before and after tuning
Using the 'top' program the load average will be shown as three numbers, for example '1.8 1.4 1.0', which are the load averages for the last 1 minute, 5 minutes and 15 minutes, respectively.

The current load on a Diskstation can be seen by enabling the terminal, logging in, then typing 'top' but it is useful to be able to see historical graphs to tune system performance. For this, Synagios, can be installed, which will graph this, and other statistics. Synagios can be downloaded for free from http://nagrestconf.smorg.co.uk.

Setting up Synagios is quite straightforward and a sample configuration can be loaded which will, among other things, graph the diskstation's load average.

A happy diskstation.
A slightly worried diskstation.

Overloading: Is it bad?

The Synology boxes can run under higher than optimal load quite comfortably, without damaging the system or components so is it bad? The answer to this question depends on your expectations and types of packages used.

Expectations
How long are you willing to wait for media to start playing, for media to be added, to open files over the network, or for pages to load? It's well worth getting the load down to below 1.0 then trying your favourite programs to see if they perform better. If the performance is the same or similar then allow the load to stay high - it's fine to run with high load if the performance is acceptable to you.

Types of Packages
As a general rule of thumb, packages written by Synology are highly performant. For example, by simply changing from Plex to Video station (plus Media Server) your system load will be greatly reduced. However, Plex has a few features that Video station doesn't so it's a trade off. For me, the reduction in performance is too great to warrant running Plex, although I miss it. Now I've switched, the whole system works better: Symform health now stays at 100%, applications are responsive and media playback starts quickly.

If you're only using your Synology NAS device as an, err, NAS device (perish the thought) then you'll probably not need to do any tuning.

Reducing the Load

To find out how much the system load is affecting performance stop as many packages as possible and try to get the load below 1.0, then browse shares, selectively add packages and use user interfaces or network access points to see if the experience is improved. If the increase in performance is only slight then don't bother tuning and allow the load to stay at its previous level. If not then some tips follow below:

Stop all packages that are no longer used - don't leave them running. Unused packages may sit in the swap file, which may not increase the load, but if they poll occasionally or try to do a bit of house-keeping then they will affect performance. It's safer just to stop them or uninstall them.

Tweak packages that poll. Packages that access sites on the Internet to check for things should be tweaked to lower the polling frequency, or to do their polling when you're not around, maybe very early in the morning or while you're at work.

Tweak downloaders. Packages that download from the Internet can really slow things down, especially if you have a fast internet connection. Set them to download when you're not going to be using the diskstation, which will also keep your ISP happy since this will usually be after 12pm.

Reduce threads and processes. Some packages have settings that control how many threads, processes or connections they use. Reduce these values and system load will reduce.

Backup when you're away. Synology's Time Backup is great, but doing it hourly for a large directory will incur a bit of a load penalty. Try to organise directories (folders) and shares so that hourly backups can be made for smaller directories, incurring less load, and backup larger directories when you're away.

Move DHCP and DNS. If you're using DNS and DHCP on the Synology box then maybe try moving one or both to your Internet router.

Reducing the Resources Synagios Uses

Synagios itself will use precious resources so some tweaking may be required to reduce the load Synagios puts on the system, especially for devices with smaller memory. Once the system tuning is finished, stop or uninstall Synagios, or leave it on and allow it to email you when things aren't going well.

I won't say exactly how to tune Synagios as files have to be edited manually. Instead, the following is for Linux savvy people, but for non-linux nerds a Synagios plugin is currently being written to make this process easy.

So for the techies among you:
  1. Edit the apache main configuration file and reduce the number of servers that are started and the max number of servers.
  2. Edit the main pnp4nagios configuration file reducing the number of threads and use the option that stops pnp4nagios from processing stats when the load is over a certain value.
The quest for better performance continues in Synology Diskstation Performance Tuning (2).

No comments:

Post a Comment