我们尝试从Tridion 2009 Broker Link_Info表中获取某些数据的同时,服务器性能下降
-
12-12-2019 - |
题
<link rel="alternate" hreflang="en-GB" href="http://www.mysite.com/english/index.aspx" />
<link rel="alternate" hreflang="de-DE" href="http://www.mysite.com/de/german/index.aspx" />
<link rel="alternate" hreflang="en-DE" href="http://www.mysite.com/de/english/index.aspx" />
<link rel="alternate" hreflang="ru-RU" href="http://www.mysite.com/ru/russian/index.aspx" />
<link rel="alternate" hreflang="en-RU" href="http://www.mysite.com/ru/english/index.aspx" />
<link rel="alternate" hreflang="fr-FR" href="http://www.mysite.com/fr/french/index.aspx" />
<link rel="alternate" hreflang="it-IT" href="http://www.mysite.com/it/italian/index.aspx" />
<link rel="alternate" hreflang="ja-JP" href="http://www.mysite.com/jp/japanese/index.aspx" />
<link rel="alternate" hreflang="ko-KR" href="http://www.mysite.com/kr/korean/index.aspx" />
<link rel="alternate" hreflang="pt-BR" href="http://www.mysite.com/br/portuguese/index.aspx" />
<link rel="alternate" hreflang="zh-Hans-CN" href="http://www.mysite.com/cn/chinese/index.aspx" />
<link rel="alternate" hreflang="en-US" href="http://www.mysite.com/us/english/index.aspx" />
<link rel="alternate" hreflang="en-GB" href="http://www.mysite.com/uk/english/index.aspx" />
<link rel="alternate" hreflang="en-AU" href="http://www.mysite.com/au/english/index.aspx" />
<link rel="alternate" hreflang="en-AE" href="http://www.mysite.com/ae/english/index.aspx" />
.
在上面的HTML中,您可以找到HTML“/ae/english/index.aspx,/au/english/index.aspx等”的这一部分来自brokerlink_info表,此实现工作了很好,直到我们与现场经纪人一起去了现场网站数据库,当我们启用此功能时,我们的服务器性能因代理数据库的命中而被杀,似乎锁定链接_Info表时,因为我们的网站每天有150万次命中,以上功能如下,如下所示:
- 每当加载任何网站页面时,它都会调用我们的代理和代理调用我们的WebService和WebService调用我们的SQL过程,该过程转到Link_Info表,并根据PageID传递给SQL过程的结果列表。
- SQL过程返回XML结果将传递给我的控件,其中我的XSLT使用它并呈现出满HTML上方。
似乎有些东西出错了,请建议可以其他方式在没有触摸代理数据库的情况下实现以上功能。写入页面事件或自定义部署者会有所帮助?
请建议!!
注意:我们使用Tridion 2009
编辑:Broker SQL过程如下:
.ALTER PROCEDURE [dbo].[GETDataFromLinkInfo] -- Add the parameters for the stored procedure here (@PageID INT) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT DISTINCT [PUBLICATION_ID] AS n, [URL] AS u FROM [LINK_INFO] WITH(NOLOCK) WHERE Page_ID = @PageID AND Component_Template_Priority > 0 AND PUBLICATION_ID NOT IN( 232, 481 ) ORDER BY URL FOR XML RAW ('p'), ROOT ('ps'); RETURN END
解决方案
我希望您在实现中有一些标准代码,您可能能够搜索某些合适的Tridion API链接。显然,正如之前所说的那样,不支持直接查询Tridion Broker,但这对于此Tridon核心链接功能也没有意义。
无论如何,查找如下所示的代码:
<tridion:ComponentLink runat="server" PageURI='tcm:12-1234-64'
TemplateURI="tcm:0-0-0" ComponentURI="tcm:12-1233"
LinkText="proper Tridion Linking in .NET" TextOnFail="true"/>
.
尽快掌握一些Tridon文档。在使用Tridion时,这是必须的!
祝你好运!
编辑:未经测试的代码样本,当使用PageID(没有TCM)的方法ID时,应该能够在头部中的Google标记多语言链接写出:
using System;
using Tridion.ContentManager;
using Tridion.ContentManager.CommunicationManagement;
using Tridion.ContentManager.ContentManagement;
using Tridion.ContentManager.Templating;
namespace Website.TridionTBBs.Utilities
{
/// <summary>
/// Class exposing utility methods for frequent Tridion item methods.
/// </summary>
public static class TridionCustomUtilities
{
#region Constants
public const string PageLinkGoogleMarkup = "<link rel=\"alternate\" hreflang=\"{0}\" href=\"{1}\" />\r\n";
#endregion
#region PageLinks
/// <summary>
/// This method will return the MultiLingual Google Markup link
/// Relies on two important Webconfig entries where the publication and culture information is located
/// <add key="publications" value="26,27,28,29,30,31,32,33,34" />
/// <add key="tcm:0-26-1" value="en-GB" />
/// <add key="tcm:0-27-1" value="de-DE" />
/// etc...
/// </summary>
/// <param name="pageID">The PageId is provided from the page</param>
static void GoogleMarkupPageLink(int pageID)
{
string[] publicationIDs = ConfigurationManager.AppSettings["publications"].Split(',');
StringWriter s = new StringWriter();
using (PageLink pageLink = new PageLink())
{
for (int i = 0; i < publicationIDs.Count; i++)
{
Link link = pageLink.GetLink(String.Format("tcm:{0}-{1}", publicationIDs[i], pageID.ToString()));
if (link != null && link.IsResolved)
{
string linkUrl = link.Url;
}
string culture = ConfigurationManager.AppSettings[String.Format("tcm:0-{0}-1", publicationIDs[i])];
Response.Write(String.Format(PageLinkGoogleMarkup, culture, linkUrl));
}
}
}
#endregion
}
}
.
这将要求您存储属于Web.config中的每个发布的发布和文化字符串。当然,你也可以在其他地方存储这个,但这似乎是WebServers的最快和最不压力。当然需要适当的缓存。
这将避免您必须编写自定义部署脚本或其他复杂的非标准条件方法。
其他提示
直接查询数据库不受支持,可能使您的支持合同无效,显然 - 避免Tridion缓存的使用(可能部分解释您的性能问题)。建议:使用链接API的Tridion用于您尝试实现的内容。
每当您遇到数据库性能问题时,有两种方法可以提供快速浮雕:
- 将其他索引添加到用于(分类和过滤)查询的列中
- 缓存昂贵查询的结果一定的时间
在这种情况下,我肯定会查看索引,因为它听起来可能会遗留在实时数据库上的一些必要的XML索引。如果您对数据库操作并非非常流利,请考虑仅保留在静态变量中生成的HTML片段并重新使用它以用于后续请求。即使你只是这样做的5分钟,你最终会通过因素来减少数据库上的命中。
我认为关于使用SQL对Tridion数据库的警告已经够了够了。在更长的术语中,您肯定应该通过Tridion内容交付API来寻找获得相同信息的方法。我非常确定相同的信息也在那里有很快可用,虽然我并不完全确定您是否也可以尽快将结果作为列表作为列表,但是在此处这样做。
即使您最终可能会出现类似的性能问题,如果您走该路由,您将至少返回支持支持的Tridion域。这意味着更多的Tridion社区成员可以帮助您。
缓存肯定也是一个选项,可以在切换到使用Tridion API后减少性能问题。替代方案确实可以将语言/ URL列表保存为磁盘上的单独文件,并在每次部署相关事项时更新。 Tridion Deployer的扩展将是执行此操作的逻辑位置。如果您对谷歌搜索“Tridion Deployer扩展名”,我非常确定一些好的结果将显示出来。