我们在服务器计算机上运行Windows服务,该服务侦听事件总线,通过插入或检索Azure Table Storage中的记录来处理事件。 问题是,在高峰时段几乎每天都需要花费大量时间来处理对Azure表存储的请求,因此,事件总线中未处理的事件会大量增加。 这是超时错误:
{"EndOfTail":false,"UserFeeds":null,"Message":"The operation has timed out.","StackTrace":" at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\\Program Files (x86)\\Jenkins\\workspace\\release_dotnet_master\\Lib\\ClassLibraryCommon\\Core\\Executor\\Executor.cs:line 649\r\n at Microsoft.WindowsAzure.Storage.Table.TableQuery`1.<>c__DisplayClass7.<ExecuteInternal>b__6(IContinuationToken continuationToken) in c:\\Program Files (x86)\\Jenkins\\workspace\\release_dotnet_master\\Lib\\ClassLibraryCommon\\Table\\TableQuery.cs:line 430\r\n at Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility.<LazyEnumerable>d__0`1.MoveNext() in c:\\Program Files (x86)\\Jenkins\\workspace\\release_dotnet_master\\Lib\\Common\\Core\\Util\\CommonUtility.cs:line 322\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Rebtel.Service.UserFeed.DataLayer.UserFeedRepository.<Execute>d__31.MoveNext() in C:\\TeamCity\\buildAgent\\work\\18bc44b16693ee8a\\BackendServices\\Backend\\Rebtel.Service.UserFeed\\DataLayer\\UserFeedRepository.cs:line 531\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Rebtel.Service.UserFeed.DataLayer.UserFeedRepository.<GetUserFeedsByTypes>d__17.MoveNext() in C:\\TeamCity\\buildAgent\\work\\18bc44b16693ee8a\\BackendServices\\Backend\\Rebtel.Service.UserFeed\\DataLayer\\UserFeedRepository.cs:line 254\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Rebtel.Service.UserFeed.BusinessLayer.Actions.GetUserFeedAction.<Execute>d__7.MoveNext() in C:\\TeamCity\\buildAgent\\work\\18bc44b16693ee8a\\BackendServices\\Backend\\Rebtel.Service.UserFeed\\BusinessLayer\\Actions\\GetUserFeedAction.cs:line 68\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Rebtel.Service.UserFeed.UserFeedServiceImplementation.<GetActions>d__17.MoveNext() in C:\\TeamCity\\buildAgent\\work\\18bc44b16693ee8a\\BackendServices\\Backend\\Rebtel.Service.UserFeed\\UserFeedServiceImplementation.cs:line 182\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Rebtel.Platform.Service.ServiceRequestInterceptor.<TryInvokeTaskWithServiceReplyResult>d__10`1.MoveNext() in C:\\TeamCity\\buildAgent\\work\\18bc44b16693ee8a\\Platform\\Platform\\Rebtel.Platform.Backend\\Service\\ServiceRequestInterceptor.cs:line 0","Result":501}
花了603,060毫秒来获得此响应。 问题不在于Azure存储帐户的可伸缩性,因为如果我们重新启动Windows服务并等待超过一百万个事件,它将立即对其进行处理。
其中一个查询如下:
query.WherePartitionKey(QueryComparisons.Equal, userId).AndRowKey(QueryComparisons.NotEqual, LastActionRowIdTableEntity.UniqueRowKey);
奇怪的是,当我查看Azure表存储的监视图时,平均服务器延迟不超过200毫秒。 你们知道为什么会这样吗?
编辑:我已经确认我们已经考虑了Microsoft表存储文档中的所有建议以提高性能。
在ServicePoint上