我正在从一台机器测试 Azure 事件中心。
我有一个具有最大允许分区 (32) 的事件中心。
我发现写入集线器的速度非常快——基本上是 1000 条消息/秒。但是,当我尝试提取数据时,我并没有获得几乎相同的吞吐量。提取 1000 条消息大约需要一分钟。
我已经尝试过使用 32 个并行接收器的 Direct 方法和 EventHost 方法。两者在速度方面大致相同。
我已将所有设置保留为默认设置。
是因为我使用单台机器来提取数据吗?请注意,从同一台机器写入不是问题。
更新:这是我用于从事件中心提取数据的代码(直接版本):
let startDirectPump
stream
eventHubConnectionString
storageConnectionString
fPost =
let tag = "startEventHubPump"
let client = EventHubClient.CreateFromConnectionString(eventHubConnectionString,stream)
let cg = client.GetDefaultConsumerGroup()
let runtimeInfo = client.GetRuntimeInformation()
let pCount = runtimeInfo.PartitionCount
let receivers =
[for p in 0..pCount - 1 ->
cg.CreateReceiver(runtimeInfo.PartitionIds.[p],System.DateTime.UtcNow)
]
let tasks =
receivers
|> List.map (fun r ->
async {
try
while not r.IsClosed do
let! e = r.ReceiveAsync() |> Async.AwaitTask
if e <> null then
fPost e
with ex ->
do! Async.Sleep 5000
Logging.logex "eh receive" ex
})
tasks |> Async.Parallel |> Async.Ignore |> Async.Start
client