配置文件性能问题
我的网络服务器上有大约 60 个网络应用程序,所有这些应用程序在 web.config 中都有一些相同的应用程序设置值。应用程序启动后,这些设置就会加载到内存中。我想将这些值集中在一个配置文件中,以便所有应用程序加载。
我的问题是,如果我同时加载所有应用程序,同时访问同一配置文件是否会出现任何性能问题?
干杯
I have around 60 web apps on web server, all of these app have some of the same appsetting values in the web.config. These settings are loaded into memory as soon as the application starts. I would like to centralise these values in one config file for all apps to load.
My question is, if i load all of the apps up at the same time, would there be any performance issues accessing this same config file at the same time?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
读锁通常不是独占的,因此任意数量的应用程序都可以同时读取同一文件。如果您没有特别要求阅读独占权,那么应该没问题。
您应该查看如何将配置文件加载到每个应用程序中。
有关详细信息,请参阅 http://en.wikipedia.org/wiki/File_locking。
Read locks are generally not exclusive so any number of applications can read from the same file at the same time. If you're not specifically requesting read exclusivity, you should be fine.
You should look at how you're loading the configuration file into each application.
See http://en.wikipedia.org/wiki/File_locking for more information.
可能是因为您需要磁盘 IO 来访问文件。但如果这些值保留在内存中,我会说之后的性能问题将是最小的。只需确保在不锁定文件的情况下读出文件(我相信使用
FileShare.ReadWrite
枚举)。Probably, because you need disk IO to access the file. But if the values stay in memory, I would say the performance issue would be minimal afterwards. Just be sure to read out the file without locking it (I believe with the
FileShare.ReadWrite
enum).您甚至可能会看到性能的微小改进,因为当第一个应用程序读取文件时,操作系统将缓存该文件,后续文件将直接从内存读取。
但唯一确定的方法就是测量和观察。
You might even see a small performance improvement since the file will be cached by the operation system when the first application reads the file, subsequent files will read directly from memory.
But the only way to know for sure is to measure and see.