将数据迁移到 Sitecore CMS 时的优化技巧
我目前面临着将大约 20 万个项目从自定义 CMS 实施导入 Sitecore 的任务。我创建了一个简单的导入页面,它使用实体框架连接到外部 SQL 数据库,并且创建了所有必需的数据模板。
在大约 5K 项目的测试导入过程中,我意识到我需要找到一种方法来使导入运行得更快,因此我开始寻找一些有关为此目的优化 Sitecore 的信息。我得出的结论是,没有太多具体信息,因此我想分享我所发现的内容,并为其他人提供进一步优化的机会。我的目标是为 Sitecore 创建某种可在导入大量数据时使用的维护模式。
我发现的最有用的信息是 Mark Cassidy 的博客文章 http:// intothecore.cassidy.dk/2009/04/migration-data-into-sitecore.html。在这篇文章的底部,他提供了一些运行导入时的提示。
- 如果迁移大量数据,请尝试禁用尽可能多的 Sitecore 事件处理程序以及其他任何您可以逃脱的方法。
- 使用 BulkUpdateContext()
- 不要忘记您的目标语言
- 如果可以的话,使字段共享且未版本化。这应该有助于提高迁移执行速度。
我从这个列表中注意到的第一件事是 BulkUpdateContext 类,因为我从未听说过它。我很快就明白了为什么在 SND 论坛和 PDF 文档中搜索没有返回结果。因此,想象一下当我实际测试它并发现它将项目创建/删除改进至少十倍时我的惊讶!
我接下来看的是第一点,他基本上建议创建一个仅包含执行导入所需的基本要素的 Web 配置版本。到目前为止,我已经删除了与创建、保存和删除项目和版本相关的所有事件。我还从 Web 配置中的主数据库元素以及任何自定义事件、计划和搜索配置中删除了历史引擎和系统索引声明。我希望我可以删除/禁用许多其他内容以提高性能。管道?时间表?
您有哪些优化技巧?
I am currently faced with the task of importing around 200K items from a custom CMS implementation into Sitecore. I have created a simple import page which connects to an external SQL database using Entity Framework and I have created all the required data templates.
During a test import of about 5K items I realized that I needed to find a way to make the import run a lot faster so I set about to find some information about optimizing Sitecore for this purpose. I have concluded that there is not much specific information out there so I'd like to share what I've found and open the floor for others to contribute further optimizations. My aim is to create some kind of maintenance mode for Sitecore that can be used when importing large columes of data.
The most useful information I found was on Mark Cassidy's blogpost http://intothecore.cassidy.dk/2009/04/migrating-data-into-sitecore.html. At the bottom of this post he provides a few tips for when you are running an import.
- If migrating large quantities of data, try and disable as many Sitecore event handlers and whatever else you can get away with.
- Use BulkUpdateContext()
- Don't forget your target language
- If you can, make the fields shared and unversioned. This should help migration execution speed.
The first thing I noticed out of this list was the BulkUpdateContext class as I had never heard of it. I quickly understood why as a search on the SND forum and in the PDF documentation returned no hits. So imagine my surprise when i actually tested it out and found that it improves item creation/deletes by at least ten fold!
The next thing I looked at was the first point where he basically suggests creating a version of web config that only has the bare essentials needed to perform the import. So far I have removed all events related to creating, saving and deleting items and versions. I have also removed the history engine and system index declarations from the master database element in web config as well as any custom events, schedules and search configurations. I expect that there are a lot of other things I could look to remove/disable in order to increase performance. Pipelines? Schedules?
What optimization tips do you have?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
顺便说一句,BulkUpdateContext() 是一个非常具有误导性的名称 - 因为它确实提高了项目创建速度,而不是项目更新速度。但正如您也指出的那样,它极大地提高了您的导入速度:-)
自从我写那篇文章以来,我在进行导入时在正常例程中添加了一些新内容。
,您可以尝试一下我一直在考虑亲自尝试但从未抽出时间的事情。它们可能会起作用,但我不能保证它们会:-)
希望这会有所帮助:-)
Incidentally, BulkUpdateContext() is a very misleading name - as it really improves item creation speed, not item updating speed. But as you also point out, it improves your import speed massively :-)
Since I wrote that post, I've added a few new things to my normal routines when doing imports.
And if you're really adventureous, there's a thing you could try that I'd been considering trying out myself, but never got around to. They might work, but I can't guarantee that they will :-)
Hope this helps a bit :-)
我猜您已经遇到过这个问题,但是将代码放入 SecurityDisabler() 块中也可能会加快速度。
我更担心 Sitecore 如何处理这么多数据……假设您只导入一次,谁在乎这个过程需要多长时间。这会经常发生吗?
I'm guessing you've already hit this, but putting the code inside a SecurityDisabler() block may speed things up also.
I'd be a lot more worried about how Sitecore performs with this much data... assuming you only do the import once, who cares how long that process takes. Is this going to be a regular occurrence?