如何故意使 Azure 角色崩溃?

发布于 2024-11-09 07:32:29 字数 269 浏览 0 评论 0原文

我希望使 Windows Azure 应用程序尽可能具有容错性,并且我需要能够故意使角色崩溃,以测试整个应用程序如何从此类崩溃中恢复。

我想我可以将代码插入到角色中,该角色将获得一个随机数并决定以相当低的概率崩溃。真正的问题是,

if( isTimeToCrash() ) {
   //what exactly do I do here?
}

一旦我决定是时候了,如何让角色崩溃。

如何可靠地故意使 Azure 角色崩溃?

I want to make a Windows Azure application as fault-resistant as possible and I need to be able to make roles crash intentionally to test how the whole application recovers from such crashes.

I guess I could insert code right into role that would obtain a random number and decide to crash with some rather low probability. The real problem is

if( isTimeToCrash() ) {
   //what exactly do I do here?
}

how to crash a role once I decide it is time.

How do I reliably crash an Azure role intentionally?

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

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

发布评论

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

评论(3

哀由 2024-11-16 07:32:29

您可以通过 RDP 连接到计算机,也可以使用启动任务添加计划任务,该任务将定期终止“WaAppAgent”进程。 Powershell 非常适合查找并终止进程。您需要成为管理员才能执行此操作。这将在一段时间内切断与结构控制器的通信,直到其恢复并重新启动进程。 IIRC,它还会终止您的 RoleEntryPoint 代码(在 WaWebHost 或 WaWorkerHost 下运行)。这将模拟一个相当大的失败。

如果您想变得更酷,可以运行一个后台启动任务来侦听队列,并在看到队列消息时按需终止进程。请注意,您不会将此代码放入 RoleEntryPoint 中,它需要作为“后台”运行的启动任务,否则您还会终止导致角色崩溃的进程。

You can either RDP into the machine or use a Startup task to add a scheduled task that will periodically kill the 'WaAppAgent' process. Powershell is pretty good here to find and kill the process. You need to be an admin to do it. This will sever the communication with the fabric controller for a period of time until it recovers and restarts the process. IIRC, it will also kill your RoleEntryPoint code (running under either WaWebHost or WaWorkerHost). That will simulate a pretty big failure.

If you want to get really fancy, run a background startup task that listens to a queue and will kill the process on demand when it sees a queue message. Note, you would not put this code in RoleEntryPoint, it would need to be a startup task running as 'background' or you would also kill the process that is crashing your role.

旧伤还要旧人安 2024-11-16 07:32:29

我不确定角色是否会崩溃,但使用角色管理 API,您可以重新启动角色。您可以查看此示例

I am not sure about crashing a role, but using Role Management API you can reboot a role. You can look at this sample

硬不硬你别怂 2024-11-16 07:32:29

对于辅助角色,您可以从 Run() 中抛出异常并让它不被处理。然而,我不知道这是否符合你对“崩溃”的定义——这个角色会被优雅地回收。

我们的角色倾向于通过 IIS 捕获未处理的异常,因此 dunnry 的建议可能会让您更接近您正在寻找的 ASOD(Azure 死亡屏幕)。

For a worker role, you can throw an exception from your Run() and let it go unhandled. However, I don't know if that meets your qualification as a "crash" - the role would be gracefully recycled.

we roles tend to catch unhandled exceptions via IIS, so dunnry's suggestion probably gets you much closer to the ASOD (Azure Screen of Death) that you're looking for.

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