【发布时间】:2018-10-09 18:34:46
【问题描述】:
我正在使用 http POST 触发器开发 Azure 函数,一旦客户端调用它并发布 json 数据,我会将其发送到事件中心并保存到数据湖。 一旦遇到高流量,20k/hour,azure functino 将产生高出站 TCP 连接,这将超过计划的限制(1920)。
- 高出站 TCP 连接是否由写入事件中心、数据湖或两者兼而有之?
- 有没有办法减少它,这样我就不必支付更多费用来升级我们的计划?
- 如何调试它来解决问题?
这里是发送数据到事件中心的代码:
EventHubClient ehc = EventHubClient.CreateFromConnectionString(cn);
try
{
log.LogInformation($"{CogniPointListener.LogPrefix}Sending {batch.Count} Events: {DateTime.UtcNow}");
await ehc.SendAsync(batch);
await ehc.CloseAsync();
}
catch (Exception exception)
{
log.LogError($"{CogniPointListener.LogPrefix}SendingMessages: {DateTime.UtcNow} > Exception: {exception.Message}");
throw;
}
这是发送到数据湖的数据:
var creds = new ClientCredential(clientId, clientSecret);
var clientCreds = ApplicationTokenProvider.LoginSilentAsync(tenantId, creds).GetAwaiter().GetResult();
// Create ADLS client object
AdlsClient client = AdlsClient.CreateClient(adlsAccountFQDN, clientCreds);
try
{
using (var stream = client.CreateFile(fileName, IfExists.Overwrite))
{
byte[] textByteArray = Encoding.UTF8.GetBytes(str);
stream.Write(textByteArray, 0, textByteArray.Length);
}
// Debug
log.LogInformation($"{CogniPointListener.LogPrefix}SaveDataLake saved ");
}
catch (System.Exception caught)
{
string err = $"{caught.Message}Environment.NewLine{caught.StackTrace}Environment.NewLine";
log.LogError(err, $"{CogniPointListener.LogPrefix}SaveDataLake");
throw;
}
谢谢,
【问题讨论】:
标签: azure azure-functions azure-data-lake azure-eventhub