开发者

How to handle images folder with many images

I'm developing a new aspnet website with 200k images in a /Images/ -folder.

Many operations in Visual Studio is slow because it access the folder, adding a web servic开发者_StackOverflow社区e takes 10 minutes.

The images is not checked into scm (svn).

How should I structure the tree of code, to improve performance in VS?

It would also be neat if not all developers needed to copy 200k images to their local disk to be able to develop on the site.

Images as DB blobs is not an option.


Put the image-directory outside the project and if your images at least have corresponding entries in db, use ID to create subdirs.

Rule of thumb, direcory shouldn't contain more than 10k files.

path = [id / 10^6] / [ id / 10^3] / [ id]

regards /t


Use a Shared folder on the network, and point to that location, set the App-pool identity property if you run under iis.


Depending on how you want to manage this, you could simply "Exclude from Project" the folder with images in it.

However, keep in mind that using the "Publish" option of Visual Studio the images would not be there.


Exclude the images from the VS solution but include them in SVN. The developers can chose to not checkout the images from SVN should they not need them. VS will still find the images when running but you just lose intelisense on them.


Performance Considerations


Use Multiple Folders

  • Having a single folder with 200,000 image files in it is not a good idea. You should see if you can break them into multiple folders such as A,B,C,D.

Use A Temporary Working Folder

  • Create a temporary working folder where anything and everything you want to do with the image is performed.
    • Move files from the working folder to their storage location (i.e. A,B,C,D)

No Reading Filenames

  • Do not attempt to read the filenames from disc. Doing so will result in terrible performance.
    • Instead you should store the filename and path to your images instead.
    • You can work with this in memory instead and you will have great performance.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜