在生产环境中热交换Java代码是否是一种良好的实践?

huangapple go评论68阅读模式
英文:

Is it a good practice to hot swap java code in production?

问题

我们有一个庞大的基于Spring的单体Java应用程序,部署需要大约30分钟。我最近发现了JDK提供的热交换功能在开发中非常有帮助,尽管它只能热交换方法体。

Oracle的官方文档建议如下这里

长时间运行的服务器的组织希望能够在不关闭服务器的情况下修复错误。

在生产环境中建议这样做吗?这样做的利弊是什么?

英文:

We have a huge spring based monolith Java app that takes ~30 minutes to deploy. I recently found out the hotswap capabilities coming with the JDK quite helpful in development although it can only hotswap method body.

The official docs from oracle suggests below here
> Organizations deploying long running servers wish to be able to fix bugs without taking down the server.
>

Is it recommended to do it in production?. What are the pros and cons of it?

答案1

得分: 0

Pro:
不需要部署时间。

Con:
绝对不要在生产系统上进行热替换。只有当你对一切都有100%的把握时才可以,但没有人能够100%确定。
我建议永远不要练习这项任务。
节省的时间不值得放弃安全。
如果你的代码有你不知道的副作用呢?

请不要这样做。

修复错误,然后创建一个发布版本。

请查看这张图片:
https://rapidbi.com/wp-content/uploads/2017/03/Project-management-triangle.png.webp
你只能同时调整三角形的两个边。

英文:

Don't.

Pro:
No deploymemt time.

Con:
Never, NEVER do a hot swap on a production system. Only if you are 100% sure about everything, but no one is 100% sure.
I would recommend to never practice this task.
Saved time isn't worth more than safety.
What if your code has side effects you so not know?

Please don't.

Fix the bugs and then create a release.

Please Take a look at this Image:
https://rapidbi.com/wp-content/uploads/2017/03/Project-management-triangle.png.webp
You can only pull in TWO sides of the triangle.

Kind regards

huangapple
  • 本文由 发表于 2023年6月15日 23:58:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76483477.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定