带有 XML 数据存储的博客引擎 .NET 怎么这么快?
我正在寻找一种将博客引擎嵌入到我自己的应用程序中的方法,并且我对博客引擎算法非常好奇。
这可能不是正确的提问地点,但是,如何才能使用默认配置将博客条目数据存储在像 BlogEngine.Net 这样的 XML 文件中。随着文件越来越大,它肯定每天都在变慢。
我想知道其背后的算法。是否以不同的方式加载?还是我对时间的估计有误?
我知道它是开源的,但我认为最好在这里看到讨论,因为其他人可能也有同样的想法,并且该线程可以作为参考。
I am looking for a way to embed a blog engine into my own application and I am too curious about Blog Engine algorithm.
This may not be the correct place to ask but, How is that possible to store blog entry data in an XML file like BlogEngine.Net with Default Configuration. It must be getting slower everyday while the file is getting larger and larger.
I am wondering the algorithm behind that. Is it loading with a different way ? Or Am I wrong with the time estimation ?
I know it is open source but I thought it would be better to see a discussion here for some others might be thinking the same and this thread can be a reference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它在启动时将帖子加载到内存中。
It loads posts into memory at startup.
每个帖子都存储为带有 GUID 文件名的单独 xml 文件。
当系统启动或回收时,如果 30 分钟不活动,系统会遍历所有 xml 文件并将它们加载到系统内存“app_pool”中。
对于第一个在“冷”启动下访问的访问者来说,通常会比之后的访问者体验到更慢的页面加载速度。
第二个访问者和其他访问者将体验到比第一个访问者更快的页面加载速度。
它之所以快,是因为它存储在内存中,不需要连接数据库以及访问数据库并返回所请求的页面/帖子的往返过程。
当“app_pool”由于帖子/页面太多而开始变满时,它就会开始变慢。
总共大约有 150 个帖子/页。
当您总共达到大约 151 个帖子/页面时,您将需要切换到使用 SQL 数据库或 xml 之外的其他提供程序。
Each post is stored as an individual xml file with a GUID file name.
When the system starts up or when it recycles if 30 mins of inactivity the system goes through all of the xml files and loads them up into the system memory "app_pool".
For the first visitor to visit on the "cold" boot will often experience a slower page load than visitors after them.
The 2nd visitor and others will experience a some what faster page load than the 1st visitor.
The reason why it is fast because it is stored in memory and does not require a connection to a database and the round trip process of accessing the database and returning with the requested page/post.
When the "app_pool" starts to get full because of too many posts/pages then it will start to slow down.
This is est to be around 150 posts/pages total.
When you reach about 151 posts/pages in total you will need to switch to using SQL database or some other provider other than xml.
要回答您提出的 XML 问题,通过扩展 ProviderBase 类,您可以将其挂接到任何数据库,包括 XML 文件。有关详细信息,请参阅 BlogProvider.cs 类和 Providers 文件夹及其 BlogEngine.Core 文件夹中的子文件夹 XmlProvider。
如果你看到Web.Config文件,你可以看到下面的代码。
通过将 defaultProvider 更改为 DbBlogProvider,您可以挂钩 BlogEngine.NET 支持的任何 RDBMS。
To answer XML question you have asked,by extending ProviderBase class you can hook it any database including XML files.For more information see BlogProvider.cs class and Providers folder and it's sub folder XmlProvider in BlogEngine.Core folder.
If you see the Web.Config file ,you can see the below code.
by changing the defaultProvider to DbBlogProvider you can hook any RDBMS which are supported by BlogEngine.NET.