SQL Server 2017 Backup of Filestreams is slow

Paolo Taverna 101 Reputation points
2022-08-26T07:38:25.913+00:00

We use SQL Server 2017 Standard Edition with CU 29
Our Database has approximately 400GB Data (Standard SQL Server tables and index) and 1.2 Terabyte of SQL Server Filestream Files. We use 20 SQL Server FileStream Groups. The Files are distributed equally on the 20 Filestreams Filegroup.
Each SQL Server FileStream Filegroups has approximately 162'000 Files. Each of this FileStream Filegroup is approximately 55GB.

The SQL Server Data, Index and SQL Server Filestream Filegroup are on the same disk for example on G:
The SQL Server Backups are written on another disk lets say P:

We start the SQL Server TSQL Backup command "with stats=5". After 2 hours it shows 20% and the Table and Index Data are written, it starts to backup the SQL Server Filestreams. After 8 hours it shows 35%. So it took 6 hours for the next 15% of the database.
The backup rate for the SQL Server Filestream is much slower as the backup rate for tables and index.

We are now investigating the setting of the disk with the SQL Server Filestreams. We check:

  • if "windows search" is disabled
  • if "Last access time" is disabled, Registry Key NtfsDisableLastAccessUpdate
  • if "Disable 8.3 file names generation" is set, Registry NtfsDisable8dot3NameCreation

Is there something else that could cause this slow backup performance of the SQL Server Filestreams?

Thank you for advice and help
Kind regards
Paolo

SQL Server | Other
{count} votes

4 answers

Sort by: Most helpful
  1. Paolo Taverna 101 Reputation points
    2022-10-26T09:45:37.91+00:00

    Took a lot of time to analyze this issue. Used the process monitor of the sysinternals suite. The microsoft defender service watching the sql server filestream directories slowed down the backup.
    Solution:
    you have to configure file extension and folder exclusions for the Windows Defender

    • Open Group Policy Management Console
    • go to Computer configuration and select Administrative templates
    • expand the tree to Windows components > Windows Defender Antivirus > Exclusions.
    • configure the "Path Exclusions" add the directory where all SQL Server Filestream are stored and the In-Memory directory. Value must be 0
    • open the Extension Exclusions and add "mdf", "ldf", "ndf" with the value 0

    No Windows OS restart needed.

    Executed a new Full SQL Server Database Backup. Now the Backup I/O for the SQL Server Filestream is the same as for Table / Index Data.

    2 people found this answer helpful.

  2. Olaf Helper 47,441 Reputation points
    2022-08-26T11:14:06.087+00:00

    slow backup performance of the SQL Server Filestreams?

    I would say, it's an expected behavoiur.
    The backups picks file by file. The database data file is one large one and is processed in one batch.
    And the each filestream file is processed, one by one and that takes some time.


  3. PandaPan-MSFT 1,931 Reputation points
    2022-08-29T02:53:48.747+00:00

    Hi @Paolo Taverna ,
    To see the situation of filestream, you can use the Windows Resource Monitor. And there is one article slow-backup-performance-of-sql-server-database-with-a-large-filestream-151 you may follow its steps. I hope it can give you some help.

    Best regards


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment"

    0 comments No comments

  4. Paolo Taverna 101 Reputation points
    2022-09-08T09:33:32.64+00:00

    Some news regarding this problem. Yesterday i experienced the same behavior on the server of another customer.
    The backup of the relational table had an I/O of 200MB/sec, the I/O on the Backup of the SQL Server Filestreams was only 8MB/sec.
    On the server of this customer i had the possibility to install the sysinternals Tools and analyze which processes accessed files.
    Turns out that a Antivirus Software with their services "blocked / slowed down" the SQL Server TSQL Backup Statement.
    Stopped the Antivirus Services on this Server - the backup of the Filestream then raised to 200MB/sec.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.