Windows Workflow Foundation 状态机是否适合高性能场景?

发布于 2024-08-02 12:14:11 字数 270 浏览 6 评论 0原文

我目前正在处理一个系统,我必须并行跟踪数千个对象的状态,这些对象每分钟发送几次可能的状态更新。另外我必须执行额外的计算(没有慢速的 IO 东西,只是使用 CPU)。

我目前使用自定义状态机实现。然而,由于 WF 在系统的其他部分中使用,我想知道 WF 状态机是否适合这种具有少数(<5)状态的场景。

我担心在性能方面的开销可能太大。由于 MS 文档并未真正涵盖有关 WF 状态机性能的主题,我想知道某些 SO 成员是否有一些有关 WF 状态机性能的信息或资源?

问候 j。

i´m currently dealing with a system where i have to track the state for several thousand objects in parallel that send possible state updates a few times every minute. In addition i have to perform additional computation (no slow IO stuff, just using CPU).

I currently use a custom state machine implementation. however, as WF is used within other parts of the system, i wonder if the WF state machine´s may be suitable for such a scenario with a handful (<5) of states.

I fear that the overhead might be too big when it comes to performance. As the MS documentation does not really cover topics regarding performance for WF state machines, i wonder if some SO member has some information or resources regaring WF state machine performance?

regards
j.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

忆梦 2024-08-09 12:14:11

状态机非常适合高性能系统。如果您确实需要非常高的性能,那么使用工作流基础会增加很多复杂性和开销。我发现 biztalk 完全不适合非常高的性能。

State machines are great for a high performance system. If you really need very high performance using workflow foundation adds a lot of complexity and overhead. I've found biztalk to be totally unsuitable for very high performance.

悟红尘 2024-08-09 12:14:11

如果您正在寻找基于 .Net 的高性能状态机,我会推荐 Stateless。以下是项目网站的摘录:

支持大多数标准状态机构造:

  • 对状态和的通用支持
    任何 .NET 类型的触发器(数字、
    字符串、枚举等)
  • 分层状态进入/退出
    状态事件
  • Guard 子句支持条件
    转换
  • 内省

还提供了一些有用的扩展:

  • 能够在外部存储状态
    (例如,在跟踪的属性中
    by Linq to SQL)
  • 参数化触发器
  • 可重入状态

配置如下:

var phoneCall = new StateMachine<State, Trigger>(State.OffHook);

phoneCall.Configure(State.OffHook)
    .Permit(Trigger.CallDialed, State.Ringing);
        
phoneCall.Configure(State.Ringing)
    .Permit(Trigger.HungUp, State.OffHook)
    .Permit(Trigger.CallConnected, State.Connected);
 
phoneCall.Configure(State.Connected)
    .OnEntry(() => StartCallTimer())
    .OnExit(() => StopCallTimer())
    .Permit(Trigger.LeftMessage, State.OffHook)
    .Permit(Trigger.HungUp, State.OffHook)
    .Permit(Trigger.PlacedOnHold, State.OnHold);

// ...

phoneCall.Fire(Trigger.CallDialled);
Assert.AreEqual(State.Ringing, phoneCall.State);

好处是,由于它实现了泛型,您可以使用 int 或 string 来表示状态和触发器,从而使您可以非常轻松地与数据库或 ORM 集成。美妙之处在于,您无需担心额外的运行时主机,只需从对象或记录加载状态机的当前状态即可。

If you are looking for a .Net based high performance state machine I would recommend Stateless. Here is an excerpt from the project site:

Most standard state machine constructs are supported:

  • Generic support for states and
    triggers of any .NET type (numbers,
    strings, enums, etc.)
  • Hierarchical states Entry/exit
    events for states
  • Guard clauses to support conditional
    transitions
  • Introspection

Some useful extensions are also provided:

  • Ability to store state externally
    (for example, in a property tracked
    by Linq to SQL)
  • Parameterised triggers
  • Reentrant states

Configuration is as follows:

var phoneCall = new StateMachine<State, Trigger>(State.OffHook);

phoneCall.Configure(State.OffHook)
    .Permit(Trigger.CallDialed, State.Ringing);
        
phoneCall.Configure(State.Ringing)
    .Permit(Trigger.HungUp, State.OffHook)
    .Permit(Trigger.CallConnected, State.Connected);
 
phoneCall.Configure(State.Connected)
    .OnEntry(() => StartCallTimer())
    .OnExit(() => StopCallTimer())
    .Permit(Trigger.LeftMessage, State.OffHook)
    .Permit(Trigger.HungUp, State.OffHook)
    .Permit(Trigger.PlacedOnHold, State.OnHold);

// ...

phoneCall.Fire(Trigger.CallDialled);
Assert.AreEqual(State.Ringing, phoneCall.State);

And the nice thing is that since it implements Generics, you can use int or string to represent the states and triggers, allowing you to integrate very easily with your database or ORM. The beauty is that there is no additional runtime host that you have to worry about, just load the state machine with the current state from an object or a record and you are good to go.

北方。的韩爷 2024-08-09 12:14:11

Microsoft 目前在其服务器产品中使用 WF,并且正在扩展此功能。例如,WF 引擎可以在 Share Point Server (MOSS) 和 BizTalk Server 中找到。两者都可以很好地扩展并允许横向扩展场景 - 即,如果您需要更多的计算能力,则可以在负载平衡集群中添加更多(廉价)硬件。

哈特哈,
托马斯

Microsoft is currently using WF in their server products and they are expanding this. So for example the WF engine can be found in Share Point Server (MOSS) and in BizTalk Server. Both scale quite well and allow scale out scenarios - i.e. you add more (cheap) hardware in a load balanced cluster if you need more computing power.

HTH,
Thomas

酒浓于脸红 2024-08-09 12:14:11

这并不直接影响性能,但如果您计划最终迁移到 WF 4.0,您应该意识到 StateMachineActivity 可能 不会晋级

This doesn't speak directly to performance, but if you're planning to eventually move to WF 4.0 you should be aware that StateMachineActivity likely won't be making the cut.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文