.NET 2 web site calling System.IO.File.Exists safe/performant with Azure Files?


  • We have an ASP.NET 2 web site (ASPDotNetStoreFront) which is constantly using the System.IO.File.Exists method to check for the existence of image files.

    These images files are stored in Azure Files, and shared to the web server machine (IIS 8 on Server 2012 R2). That directory is then mounted in IIS as a virtual directory so the website can see it.

    During normal day-to-day, the site works fine, images show up, etc. But under periods of heavy load, our application performance monitoring tool is showing a major hotspot for this chain of method calls:

    System.IO.File.Exists -> System.IO.File.InternalExists -> System.IO.File.FillAttributeInfo

    And these methods being slow causes our entire website to slow down to 20+ second page load times.

    Is this method OK to use with a mounted Azure Files share? Is it supposed to be performant? or should we be using a different method or technique?

    For context, the entire reason we were doing this as a file share is so that we can eventually setup a cluster of IIS machines and not have to have 1 million+ images on every machine.

    (I realize the ideal would be not to do these checks all the time, but that would involve a large re-write of a 3rd party application, and we're not able to do that...)

    Friday, April 22, 2016 5:49 PM

All replies

  • Hi,

    Thanks for posting here.

    We are working on this and will revert to you at the earliest.

    Girish Prajwal

    Saturday, April 23, 2016 5:09 PM
  • Hi,

    Sincere apologies for the delay in responding.

    Have you tried to leverage azure file storage SDK to check the existence of file, if not then can you please try with below code ?
    Have you tried to identify when it start giving a performance slowness?
    // Create a CloudFileClient object for credentialed access to File storage.
    CloudFileClientfileClient =storageAccount.CreateCloudFileClient();
    // Get a reference to the file share we created previously.
    CloudFileShareshare =fileClient.GetShareReference("logs");
    // Ensure that the share exists.
        // Get a reference to the root directory for the share.
        CloudFileDirectoryrootDir =share.GetRootDirectoryReference();
        // Get a reference to the directory we created previously.
        CloudFileDirectorysampleDir =rootDir.GetDirectoryReference("CustomLogs");
        // Ensure that the directory exists.
            // Get a reference to the file we created previously.
            CloudFilefile =sampleDir.GetFileReference("Log1.txt");
            // Ensure that the file exists.
                // Write the contents of the file to the console window.

    Please let me know, if you have any question or concern.

    Girish Prajwal

    Wednesday, May 11, 2016 7:43 AM