Optimizing disk writes

If your site creates many new files on disk, such as files uploaded by visitors, consider these performance improvements:

  • Avoid head seeks
  • Use FileStream.SetLength to avoid fragmentation
  • Use 64 K buffers
  • Disable 8.3 filenames

Avoiding head seeks

Writing bytes sequentially without moving the read/write head happens much faster than random access. If you are only writing the files and not reading them, try writing them on a dedicated disk drive using a single dedicated thread. That way, other processes won't move the read/write head on the drive.

Using FileStream.SetLength to avoid fragmentation

If multiple threads write files at the same time, space used for those files will become interleaved, leading to instant fragmentation. ...

Get ASP.NET Site Performance Secrets now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.