【发布时间】:2019-02-12 16:55:10
【问题描述】:
团队,
我在 Azure 上发布了一个 Azure 网站。该应用程序从 API 读取大约 30,000 名员工,读取成功后,它会使用所有 30,000 名员工更新二级 redis 缓存。
超时发生在第二步,即当它与所有员工一起更新辅助 redis 缓存时。从我当地来看,它工作正常。但是一旦我将它部署到 Azure,它就会给我一个
500 - The request timed out.
The web server failed to respond within the specified time
从博客中我了解到,Azure 网站的默认超时设置为 4 分钟。
我已经尝试了博客上提供的所有修复,例如将应用程序设置中的命令 SCM_COMMAND_IDLE_TIMEOUT 设置为 3600。
我什至尝试将 Azure redis 缓存会话状态提供程序设置像这样放在 web.config 中,并带有夸大的超时数字。
<add type="Microsoft.Web.Redis.RedisSessionStateProvider" name="MySessionStateStore" host="[name].redis.cache.windows.net" port="6380" accessKey="QtFFY5pm9bhaMNd26eyfdyiB+StmFn8=" ssl="true" abortConnect="False" throwOnError="true" retryTimeoutInMilliseconds="500000" databaseId="0" applicationName="samname" connectionTimeoutInMilliseconds="500000" operationTimeoutInMilliseconds="100000" />
导致超时的违规代码如下: `
public void Update(ReadOnlyCollection<ColleagueReferenceDataEntity> entities)
{
//Trace.WriteLine("Updating the secondary cache with colleague data");
var secondaryCache = this.Provider.GetSecondaryCache();
foreach (var entity in entities)
{
try
{
secondaryCache.Put(entity.Id, entity);
}
catch (Exception ex)
{
// if a record fails - log and continue.
this.Logger.Error(ex, string.Format("Error updating a colleague in secondary cache: Id {0}, exception {1}", entity.Id));
}
}
}
`
我可以对此代码进行更改吗?
请任何人帮助我...我已经没有想法了!
【问题讨论】:
标签: azure azure-web-app-service azure-redis-cache