简体   繁体   English

用于重启与被拒绝主机的连接的Erlang Supervisor策略

[英]Erlang Supervisor Strategy For Restarting Connections to Downed Hosts

I'm using erlang as a bridge between services and I was wondering what advice people had for handling downed connections? 我正在使用erlang作为服务之间的桥梁,我想知道人们有什么建议来处理被击落的连接?

I'm taking input from local files and piping them out to AMQP and it's conceivable that the AMQP broker could go down. 我从本地文件中获取输入并将它们输出到AMQP,可以想象AMQP经纪人可能会崩溃。 For that case I would want to keep retrying to connect to the AMQP server but I don't want to peg the CPU with those connections attempts. 对于这种情况,我想继续重试连接到AMQP服务器,但我不想将CPU与这些连接尝试挂钩。 My inclination is to put a sleep into the reboot of the AMQP code. 我倾向于在重新启动AMQP代码时进行睡眠。 Wouldn't that 'hack' essentially circumvent the purpose of failing quickly and letting erlang handle it? 难道“黑客”本能绕过快速失败并让erlang处理它的目的吗? More generally, should the erlang supervisor behavior be used for handling downed connections? 更一般地说,是否应该使用erlang管理员行为来处理故障连接?

I think it's reasonable to code your own semantics for handling connections to an external server yourself. 我认为编写自己的语义来处理与外部服务器的连接本身是合理的。 Supervisors are best suited to handling crashed/locked/otherwise unhealthy processes in your own process tree not reconnections to an external service. 监督员最适合处理您自己的流程树中的崩溃/锁定/其他不健康的流程,而不是重新连接到外部服务。

Is your process that pipes the local files in the same process tree as the AMQP broker or is it a separate service? 您的进程是否在与AMQP代理相同的进程树中管理本地文件,还是单独的服务?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM