Unusual amount of read activity/ HDD activity when NAS not in use

Server Version#:Any version
Player Version#: Not applicable

Even when my server is not in use - No one is connected to server, the NAS is still having a full on party it seems, making reading sounds, like when you copy a file from time to time. I am not highly familiar with the settings of neither the Synology NAS, nor the PLEX server settings, but I find it tedious that it does the reading activity during “off hours”. I do not want to power it down, as I want it available and at the ready whenever I need it.
(This has been a problem on all PLEX server updates since I bought the device 6 months ago).

Are there settings to reduce the random read activity within PLEX?
Any tips or tricks to this?

Thanks,

assuming it is plex and not some other application;

configure to your liking
Plex Web > settings

  • library > generate video preview/markers/chapter thumbs/analyze audio
  • scheduled tasks

Thank you.

Was set to quite limited updates, and nowhere near as often as the HDD activity is.

Are there any logs that might shed some light onto this?

plex web > settings > alerts

or raw log info >

settings > console

If you have Plex clients online on your network, even if they aren’t playing anything, PMS will keep the drive(s) that store the plex database (very) busy. See Plex constantly writes to Plug-in Support/Databases/com.plexapp.plugins.library.db-{shm,wal}

Has that been confirmed or is this just your deduction from your other thread post? On my home network, there will always be “Plex Clients”. Multiple Android devices with Plex installed, plus my Nvidia Shield.

What constitutes an active-but-not-playing client?

If I may here?

If PMS is running – the volume will be written to.
If you have clients on the LAN which are running (app active) – more will be written due to the SSDP activity

@Kaldek it is my observation from the other post yes: as soon as any plex client is started on the network, PMS will start writing to the files mentioned there. Stop the clients, writing ceases.

@ChuckPa I’m afraid I don’t follow your reasoning. Nothing in the SSDP protocol implementation details requires a service advertiser to use persistent storage; let alone write an average 5MB/s of data to it (see other thread). It seems something is rather wrong here?

same issue on my system, in this thread i have explained it

@BulletZ

I’m sorry I didn’t see this until now. Since this topic touches on a number of things at this point, I’d like to make a sorta ‘explanatory’ post to hopefully shed some light on what’s going on.

I am not referring to the SSDP protocol itself
I am referring to how PMS handles unexpected results of SSDP queries (e.g. malformed XML - which does occur quite often) from nodes.

Normally, PMS will output one line acknowledging the device is found or gone idle.
When it gets a bad reply, dependent on the actual reply, as many as 15 lines can be written.

While PMS logs are always generous , those add to it.

One caution which I need state is:

  1. The defaults are DEBUG: ON, VERBOSE: OFF
  2. If VERBOSE is manually enabled, thinking it will help, log file output can 10-20x greater. At 10 MB/log file, with a total retention of 60 MB per which will ‘roll off’ in 2-3 minutes, you have 1.2 GB/hr wasted in Verbose log file writing. This is multiplied exponentially when streaming because EVERY packet exchange between Server and Player is logged.
  3. On systems which are totally “production stable”, it’s perfectly OK to turn off DEBUG, with the caveat DEBUG is enabled again and an issue re-created before posting logs in the forum for us to review. INFO/WARN/ERROR (when DEBUG is OFF) is never enough for us to diagnose with.

An alternative to PMS writing in the Logs directory is to use SYSLOG.

On normal Linux, this is an option however we don’t support diagnosing syslogs. (Would you want to sift through months of someone’s syslog trying

On Synology, we don’t have that luxury.

Speaking to the “Disk Activity” itself,

To list the activities PMS is doing when it’s not in use is all listed in the Scheduled Tasks and Library sections.

If you click SHOW ADVANCED in both, you’ll see where PMS will:

  1. Monitor your media directories for any changes and rescan when changes are detected.
  2. Optionally also scan periodically.
  3. Unless “Partial Scan” is enabled (only of benefit when all media is local) it will rescan all the media directories. Enabling “Partial Scan” is, imho, a MUST ENABLE option on NAS boxes. – This also minimizes database and log file activity as well (significantly)
  4. The list of scheduled tasks. Most of these are enabled by default and constitute a substantial amount of disk activity during the maintenance period. (shown at the top of the Scheduled Tasks page)
Backup database every three days
Optimize database every week
Remove old bundles every week
Remove old cache files every week
Refresh local metadata every three days
Update all libraries during maintenance
Upgrade media analysis during maintenance
Refresh music library metadata periodically
Perform extensive media analysis during maintenance
Perform refresh of program guide data.
Fetch missing location names for items in photo sections
Analyze and tag photos

The media analysis will read every bit of indexed media and profile it for auto bit rate use (Remote Access).

Audio will have loudness analyzed as well.

I’m not trying to defend what PMS is doing. I know it pushes hard on the system during maintenance and I know that if you’re going to use a SSD, don’t get a cheap one. Use a “Pro” rated SSD and get a big one. SSD life is dependent on the total number of storage pages on the device. There is a finite limit to how many times a storage page can be written. Obviously , the more free pages on the device, the longer it will last (device wear leveling in the device ASIC).

I use the Samsung 970 Pro 1TB. It has a TBW (TerraBytesWritten) rating of 1200 TBW (1.2 Petabytes). Yes.. it’s not cheap. $350 USD list price.

On my QNAP (where I keep my main PMS and all the QA test media), 42GB for metadata.

[/share/PlexData/Plex Media Server] # du -ms .
42835	.
[/share/PlexData/Plex Media Server] # 

Total number of files indexed:

[chuck@lizum /vie.166]$ find movie* qa tv* *music* -type f -print | wc -l
166035
[chuck@lizum /vie.167]$ 

If I start doing rough math (VERY rough).

  1. I can rebuild the entire Plex database 23 times before getting to 1 TB of usage.
  2. I can roll though 13,000 full sets of logs (at 75 MB / full set) before getting to 1 TB of usage when in DEBUG logging mode.

Let’s assume

10 sets of logs / day (750MB) for 1000 days = 750 GB.
1000 full rebuilds of the Plex datase (43GB) = 43,000 GB

43.750 TB of the total life of a typical 600 TBW SSD.

1000 days @ 1 rebuild per day = 3+ years.
Under normal use, you will have grown out of the NAS long before.

Between the two above, I need over 10 years to wear out the SSD.

This begs the question:

What else is being written to the SSDs ?

Where’s the Transcoder temp directory? By default, on Synology, I keep it in the Plex share /volume1/Plex/tmp_transcoding.

If the entire Plex share is on SSD and the transcoder temp is still at its default location – “Houston, we have a problem”

Lastly, to the point of disk activity , which I’ve deviated far from.

  1. Drives don’t go bad by using them
  2. Drives, very much like light bulbs, fail from turning them off (they cool down) and rapid heating when turned back on. (bulbs fail when you turn them on and rarely fail if left on continuously - true?)
  3. My drives are left on continuously. I don’t hear what PMS is doing. All my equipment is in the closet behind a closed door.

If this is of any info, with drives left on continuously since last upgrade ,
(Syno got the then-older & smaller 6TB drives and the QNAP got the 8TB drives)

Newer drives in the QNAP

What I’m trying to say here is that

  • PMS does a lot of work behind the scenes.
  1. It figures out, in advance, how to stream under both local & remote situations.
  2. It keeps metadata up to data (it does change from time to time but not the norm)
  3. It will work its way through the entire media content until everything has been fully “imported” (analyzed in depth).
  • If NAS-rated drives are being used, don’t worry about them being on all the time. It’s actually better for them in the long haul (thermal stability + heads remain out over the platters). If Desktop drives are being used, Danger Will Robinson :wink:

  • If SSD wear is an issue, let’s work on that. This is largely an educational issue.

@ChuckPa Thanks for the lengthy explanation and thanks for taking the time. It is however rather unfortunate that you completely missed the tentative bug report listed here Plex constantly writes to Plug-in Support/Databases/com.plexapp.plugins.library.db-{shm,wal} (for lack of a proper public bug tracker for Plex) and specifically the part where I explain that the problem me and others are reporting is directly related to clients being connected on the server network (idle clients, that is) and the two specific files that get near constantly written to (the sqlite shared-memory and write-ahead log). That activity ceases as soon as no clients are connected.

FWIW I have disabled all login to the maximum extent possible, and I have no problem with the scheduled maintenance and library housekeeping you describe. The log files (in the Logs folder) don’t even begin to register in the disk I/O we’re talking about.

And while I hear your appreciation of how disks (be them rotating or solid state) age, I have my own experience in the field (having dealt with pools of hundreds of drives), and I might see otherwise. Finally, you seem to ignore the induced power usage. Any unnecessary disk activity, however small, translates into real power usage when it happens 24/7.

I hope someone can actually look into this technical issue and hopefully improve the situation.

Thanks

@BulletZ

SQLITE3 may not be perfect but

  1. It’s portable
  2. It’s self-contained (no external server process required)

You do understand what the SHM and WAL files are?

May I call your attention to Temporary Files Used By SQLite

2.2. Write-Ahead Log (WAL) Files

A write-ahead log or WAL file is used in place of a rollback journal when SQLite is operating in WAL mode. As with the rollback journal, the purpose of the WAL file is to implement atomic commit and rollback. The WAL file is always located in the same directory as the database file and has the same name as the database file except with the 4 characters " -wal " appended. The WAL file is created when the first connection to the database is opened and is normally removed when the last connection to the database closes. However, if the last connection does not shutdown cleanly, the WAL file will remain in the filesystem and will be automatically cleaned up the next time the database is opened.

2.3. Shared-Memory Files

When operating in WAL mode, all SQLite database connections associated with the same database file need to share some memory that is used as an index for the WAL file. In most implementations, this shared memory is implemented by calling mmap() on a file created for this sole purpose: the shared-memory file. The shared-memory file, if it exists, is located in the same directory as the database file and has the same name as the database file except with the 4 characters " -shm " appended. Shared memory files only exist while running in WAL mode.

The shared-memory file contains no persistent content. The only purpose of the shared-memory file is to provide a block of shared memory for use by multiple processes all accessing the same database in WAL mode. If the VFS is able to provide an alternative method for accessing shared memory, then that alternative method might be used rather than the shared-memory file. For example, if PRAGMA locking_mode is set to EXCLUSIVE (meaning that only one process is able to access the database file) then the shared memory will be allocated from heap rather than out of the shared-memory file, and the shared-memory file will never be created.

The shared-memory file has the same lifetime as its associated WAL file. The shared-memory file is created when the WAL file is created and is deleted when the WAL file is deleted. During WAL file recovery, the shared memory file is recreated from scratch based on the contents of the WAL file being recovered.

With respect to the typical 10 watts of power consumption per hard drive,

Here is the total usage in my office for:

  1. QNAP TVS-1282-i7-32GB w/ 13 of 14 drive slots populated.
  2. Synology DS-1815+ w/ 8 of 8 drive slots populated.
  3. NUC8-i7-HVK w/ 10GbE Aquantia external NIC
  4. HPE-1820 24 port switch
  5. Netgear GS-110EMX 10 GbE switch.
  6. Thecus, Synology DS418J, QNAP TS128A - development NAS boxes
  7. ISP modem and Netgate SG-2220 PfSense router
  8. Two MG-28UQ - 2160p monitors
  9. Desk lamp.

at this power utilization, everything ON (which it always is)

Which translates to 1 KWH per 4 clock hours = 6 KWH/day
6 * 30 days / billing cycle = 180 KWH / month

At 12 cents per KWH = $21.60 / month to run everything and do all I need do for Plex from this home office.

Is this really too expensive?

@ChuckPa are you always this condescending with users (and paying customers) trying to provide useful information to debug a problem?

The fact that I named the two files for what they are should have been a clue that I didn’t need a lecture about them.

These files are written as soon as there is sqlite activity. The main database file is also updated of course, albeit less frequently, when the WAL itself is checkpointed (see: I know how this works).

Instead of bikeshedding, why not try to actually look into the issue? The problem isn’t SQLITE. The problem is why is there so much database activity when an idle client is connected? The link is clear: turn off the client and the disk activity stops. Clearly no amount of telemetry or statistical usage should warrant this? Of course I would be happy to try to debug this myself since you seem uninterested in doing so, but as the server is closed source, that’s not going to happen.

Finally,

at this power utilization, everything ON (which it always is)

Of course. Why bother saving power, right?

Which translates to 1 KWH per 4 clock hours = 6 KWH/day
6 * 30 days / billing cycle = 180 KWH / month
At 12 cents per KWH = $21.60 / month to run everything and do all I need do for Plex from this home office.

Spoken like a True American™. “I can pay for it so it doesn’t matter”.

Well, first not everybody lives in the US and energy prices can vary drastically (for instance Germans pay about 0.30€/kWh, which is about 3x the rate you quoted in US$, for your information), and regardless, the point is: this extra consumption (and wear) can - and should - be avoided

Frankly, this type of patronizing behavior makes me wonder why even bother paying for Plex Pass.

SQLite sucks and Plex needs to have alternative DB support. The posts above where informative have no bearing on the issues we see with SQLite. and FYI MySQL can be made portable and be included in the software package for all platforms. No excuse for the issues that happen when your Plex database exceeds 5k titles, or you have an unexpected shutdown that takes hours to un screw up because SQCrap was in the middle of a write-through operation.

Upvote the feature request for additional SQL db support!

If I may assert that SQLite3 isn’t the root problem here.

SQLite3 is in big-data use where record counts are in the 100’s of millions of rows.

As demonstration, I have far greater than 5K items indexed.

[chuck@lizum sql.422]$ sqlite3 com.plexapp.plugins.library.db-2020-08-24
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> select count(*) from media_parts;
140792
sqlite> 

As can be seen above, I have a great deal of data indexed without issue.

In attempting to help others sort through this, one thing which has been found to be problematic is ZFS. I went off and researched this myself to see if I can find the root. What I discovered was the default nature of ZFS’s compression/decompression is constantly getting in the way of database operations.

If I may suggest, for those who can do this, move the metadata to an EXT4 or XFS file system (set PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR) and retest.

It might be in the best interest of all to create a new thread regarding databases and not continue to take this thread off its original subject.
Sub-topics to consider: ZFS, MergerFS, and other “FS” layers between the application and the storage. Keep in mind that ZFS slows down quite profoundly when above 50% utilization.

Ref: Implementation Limits For SQLite

The theoretical maximum number of rows in a table is 2^64 ( 18446744073709551616 or about 1.8e+19). This limit is unreachable since the maximum database size of 281 terabytes will be reached first.

Ref: https://www.percona.com/blog/2018/02/16/why-zfs-affects-mysql-performance/

ps: regarding a previous comment; I’m German but now do live in the US.