3

首先,我不是 Akka 新手(已经使用了 2 年以上)。我有一个高吞吐量(数百万条消息/分钟/节点)应用程序,它执行繁重的网络 I/O。初始 Actor(由 a 支持RandomRouter)接收消息并将它们分发给适当的子 Actor 进行处理:

private val distributionRouter = system.actorOf(Props(new DistributionActor)
  .withDispatcher("distributor-dispatcher")
  .withRouter(RandomRouter(distrib.distributionActors)), "distributionActor")

该应用程序经过高度调整并具有出色的性能。我想通过在DistributionActor. 这是相关配置(唯一的变化是添加了基于文件的邮箱):

akka.actor.mailbox.file-based {
    directory-path = "./.akka_mb"
    max-items = 2147483647

    # attempting to add an item after the queue reaches this size (in bytes) will fail.
    max-size = 2147483647 bytes
    # attempting to add an item larger than this size (in bytes) will fail.
    max-item-size = 2147483647 bytes
    # maximum expiration time for this queue (seconds).
    max-age = 3600s
    # maximum journal size before the journal should be rotated.
    max-journal-size = 16 MiB
    # maximum size of a queue before it drops into read-behind mode.
    max-memory-size = 128 MiB
    # maximum overflow (multiplier) of a journal file before we re-create it.
    max-journal-overflow = 10
    # absolute maximum size of a journal file until we rebuild it, no matter what.
    max-journal-size-absolute = 9223372036854775807 bytes
    # whether to drop older items (instead of newer) when the queue is full
    discard-old-when-full = on
    # whether to keep a journal file at all
    keep-journal = on
    # whether to sync the journal after each transaction
    sync-journal = off
    # circuit breaker configuration
    circuit-breaker {
        # maximum number of failures before opening breaker
        max-failures = 3
        # duration of time beyond which a call is assumed to be timed out and considered a failure
        call-timeout = 3 seconds
        # duration of time to wait until attempting to reset the breaker during which all calls fail-fast
        reset-timeout = 30 seconds
    }
}

distributor-dispatcher {
    executor = "thread-pool-executor"
    type = Dispatcher
    thread-pool-executor {
        core-pool-size-min = 20
        core-pool-size-max = 20
        max-pool-size-min = 20
    }
    throughput = 100
    mailbox-type = akka.actor.mailbox.FileBasedMailboxType
}

我一介绍这个,我就注意到很多丢失的消息。当我通过 Typesafe 控制台对其进行分析时,我看到一堆死信(比如每 1M 大约 100k)。我的邮箱文件每个演员只有 12MB,所以它们甚至没有接近限制。我还设置了一个死信侦听器来计算死信,这样我就可以在分析器之外运行它(我想可能是仪器问题?)。结果相同。

知道什么可能导致死信吗?

我在 Scala 2.9.2 上使用 Akka 2.0.4。

更新:

我注意到这些死信似乎是为 . 拥有的几个儿童演员绑定的DistributionActor。我不明白为什么更改父母的邮箱对此有任何影响,但这绝对是行为。

4

0 回答 0