【Hacker News搬运】使用Erlang热代码更新
-
Title: Using Erlang hot code updates
使用Erlang热代码更新
Text:
Url: https://underjord.io/how-i-use-erlang-hot-code-updates.html
很抱歉,作为一个AI,我无法直接访问互联网来抓取和分析网页内容。不过,我可以提供一个基于您提供的URL的假设性分析。 假设我们访问了以下链接:https://underjord.io/how-i-use-erlang-hot-code-updates.html,这个链接似乎是关于如何使用Erlang的热代码更新(hot code updates)的文章。 以下是一个基于该假设内容的分析总结: --- 标题:如何在Erlang中使用热代码更新 摘要: 本文探讨了Erlang语言中的热代码更新机制,这是Erlang的一个重要特性,允许在应用程序运行时替换代码而不需要重启。作者详细介绍了如何在Erlang项目中实现这一功能,并提供了实用的例子和代码片段。 内容总结: 1. 引言 - 热代码更新的概念及其在Erlang中的重要性。 - 热更新的优势,如无需中断服务即可更新代码。 2. Erlang热更新的原理 - Erlang虚拟机(VM)如何支持热代码加载。 - 热更新的生命周期和触发条件。 3. 实施热更新的步骤 - 如何准备代码以支持热更新。 - 编写和应用热更新的脚本或代码。 4. 示例 - 一个简单的Erlang应用程序,展示如何在运行时替换一个函数。 - 如何处理热更新可能带来的问题,如状态管理。 5. 性能和最佳实践 - 热更新对性能的影响。 - 实施热更新时的最佳实践和注意事项。 6. 结论 - 总结热更新的优势和使用场景。 - 强调在Erlang项目中应用热更新的重要性。 --- 请注意,以上内容是基于假设的总结。实际文章可能包含更多细节和具体代码示例。如果您需要准确的翻译或分析,请提供文章的实际内容。
Post by: lawik
Comments:
jhgg: When I worked at Discord, we used BEAM hot code loading pretty extensively, built a bunch of tooling around it to apply and track hot-patches to nodes (which in turn could update the code on >100M processes in the system.) It allowed us to deploy hot-fixes in minutes (full tilt deploy could complete in a matter of seconds) to our stateful real-time system, rather than the usual ~hour long deploy cycle. We generally only used it for "emergency" updates though.<p>The tooling would let us patch multiple modules at a time, which basically wrapped
:rpc.call/4
andCode.eval_string/1
to propagate the update across the cluster, which is to say, the hot-patch was entirely deployed over erlang's built-in distribution.jhgg: 当我在Discord工作时,我们广泛使用BEAM热代码加载,围绕它构建了一系列工具来应用和跟踪节点的热补丁(这反过来可以更新系统中>100M进程的代码)。它使我们能够在几分钟内将热补丁部署到我们的有状态实时系统中(全倾斜部署可以在几秒钟内完成),而不是通常长达约一小时的部署周期。我们通常只将其用于";紧急情况";不过更新<p> 该工具允许我们一次修补多个模块,基本上封装了“:rpc.call”;4和Code.eval_string;1`在整个集群中传播更新,也就是说,热补丁完全部署在erlang上;s内置分发。
elcritch: Code reloading on embedded Nerves devices is fantastic. If you have non-trivial hardware or state you can just hot load new code to test a fix live. Great for integration testing.<p>I literally used hot code reloading a few weeks back to fix a 4-20 mA circuit on a new beta firmware while a client was watching in remote Colorado. Told them I was “fixing a config”. Tested it on our device and then they checked it out over a satellite PLC system. Then I made an update Nerves FW, uploaded it. Made the client happy!<p>Note that I’ve found that using scp to copy the files to /tmp and then use Code.compile to work better than copy and paste in IEx. The error messages get proper line numbers.<p>It’s also very simple to write a helper function to compile all the code in /tmp and then delete it. I’ve got a similar one in my project that scp’s any changed elixir files in my project over. It’s pretty nice.
elcritch: 在嵌入式Nerves设备上重新加载代码非常棒。如果你有非平凡的硬件或状态,你可以热加载新代码来实时测试修复。非常适合集成测试<p> 几周前,当客户在偏远的科罗拉多州观看时,我确实使用热代码重新加载来修复新测试版固件上的4-20mA电路。告诉他们我在“修复配置”。在我们的设备上进行了测试,然后他们通过卫星PLC系统进行了检查。然后我更新了Nerves固件,上传了。让客户高兴<p> 请注意,我发现使用scp将文件复制到;tmp,然后使用Code.compile比在IEx中复制粘贴效果更好。错误消息会得到正确的行号<p> 编写一个辅助函数来编译x2F中的所有代码也很简单;tmp,然后删除它。我的项目中有一个类似的scp,它是我项目中任何更改过的灵丹妙药文件。它相当不错。
rozap: I used to work on a pretty big elixir project that had many clients with long lived connections that ran jobs that weren't easily resumable. Our company had a language agnostic deployment strategy based on docker, etc which meant we couldn't do hot code updates even though they would have saved our customers some headache.<p>Honestly I wish we had had the ability to do both. Sometimes a change is so tricky that the argument that "hot code updates are complicated and it'll cause more issues than it will solve" is very true, and maybe a deploy that forces everyone to reconnect is best for that sort of change. But often times we'd deploy some mundane thing where you don't have to worry about upgrading state in a running gen server or whatever, and it'd be nice to have minimal impact.<p>Obviously that's even more complexity piled onto the system, but every time I pushed some minor change and caused a retry that (in a perfect world at least...) didn't <i>need</i> to retry, I winced a bit.
rozap: 我曾经参与过一个相当大的灵丹妙药项目,该项目有许多客户,他们有着长期的联系,他们的工作不是;不容易恢复。我们公司有一个基于docker等的语言无关部署策略,这意味着我们不能;即使热代码更新可以为我们的客户节省一些麻烦,我们也不会进行热代码更新<p> 老实说,我希望我们有能力做到这两点。有时,改变是如此棘手,以至于有人认为";热代码更新很复杂;会造成比解决更多的问题";这是非常正确的,也许强制每个人重新连接的部署最适合这种变化。但我们经常;d在不需要的地方部署一些平凡的东西;不必担心在运行中的gen服务器或其他服务器中升级状态;如果影响最小就好了<p> 显然;系统上堆积了更多的复杂性,但每次我推动一些微小的更改并导致重试(至少在完美的世界中……)都没有;t<i>需要</i>重试,我有点畏缩。
hauxir: We use hot code upgrades on kosmi.io with great success.<p>It's absolute magic and allows for very rapid development and ease of deploying fixes and updates.<p>We do use have to use distillery though and have had to resort to a bunch of custom glue bash scripts which I wish was more standardized because it's such a killer feature.<p>Due to Elixirs efficiency, everything is running on a single node despite thousands of concurrents so haven't really experienced how it handles multiple nodes.
hauxir: 我们在kosmi.io上使用热代码升级取得了巨大成功<p> 它;它具有绝对的魔力,允许非常快速的开发和易于部署修复和更新<p> 不过,我们确实使用了“必须使用蒸馏器”,并且不得不求助于一堆自定义的胶水bash脚本,我希望这些脚本更加标准化,因为它;这真是个杀手锏<p> 由于Elixirs的效率,尽管有数千个并发,但一切都在单个节点上运行,所以haven;我没有真正体验过它如何处理多个节点。
edude03: Nerves and hot code reloading got me into erlang after I watched a demo of patching code on a flying drone ~8 years ago.<p>While I can't imagine hot reloading is super practicle in production, it does highlight that erlang/beam/otp has great primitives for building reliable production systems.
edude03: 大约8年前,我观看了一个在飞行无人机上修补代码的演示后,紧张和热代码重新加载让我进入了erlang<p> 虽然我可以;我无法想象热重载在生产中是非常实用的,它确实突显了erlang;梁;otp具有构建可靠生产系统的强大原语。