使用 Nailgun 与 netcat 为 Java 应用程序提供快速 CLI 有何优缺点?
已经讨论了减少 Java 和 Scala 应用程序启动时间的方法 此处和此处。建议的解决方案之一是使用客户端-服务器方法,使用 Nailgun 或简单的手-编写的服务器通过 TCP 套接字与 netcat 进行通信。
一方面,钉枪就是为此目的而设计的。另一方面,它的最后一个版本 0.7.1 是在 2005 年,我有点担心开发是否已经停止以及它的稳定性如何。 netcat 似乎是一个非常标准的工具,可以在许多 Linux/Unix 系统上使用。但这两个系统对我来说都是新的,所以我想知道我的观察是否正确,以及使用 Nailgun 与 netcat 为 Java 应用程序提供快速命令行界面的其他优点和缺点是什么?
PS 您可能想知道为什么要改进启动时间,因为它已经相当合理(在我的机器上约为 100 毫秒),或者为什么不使用 C/C++ 来代替。第一个是因为应用程序将被执行多次(例如,从 bash 脚本中的循环),并且不幸的是这个使用场景无法更改,第二个是因为这个控制台程序将只是现有部分的替代接口(CLI)用Java编写的软件。
The ways to reduce startup time of Java and Scala applications have been already discussed here and here. One of the solutions suggested there was to use client-server approach with either Nailgun or a simple hand-written server communicating through a TCP socket with netcat.
On the one hand, Nailgun is designed for this purpose. On the other hand, its last release 0.7.1 was in 2005 and I am a bit worried if the development has stopped and how stable it is. netcat seems to be a pretty standard tool and available on many Linux/Unix systems. But both these systems are new to me so I would like to know if my observations are right and what are the other advantages and disadvantages of using Nailgun vs netcat to provide fast command-line interface to a Java application?
P.S. You may wonder why to improve the startup time since it is already quite reasonable (~100ms on my machine) or why not to use say C/C++ instead. The first is because the application will be executed many times (e.g. from a loop in a bash script) and this use scenario cannot be changed unfortunately, the second is because this console program will be just an alternative interface (CLI) to the existing piece of software written in Java.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的建议是现在就使用钉枪,并证明这种解决方案确实对启动时间有积极的影响。
如果您已经确认瓶颈是启动时间,那么您可以实现一个非常简单的客户端/服务器,其优点是可以自由使用任何通信程序(netcat、wget、curl、perl 等)并完全控制协议。
My recomendation would be to go now with nailgun and to prove that this kind of solution really has an positive effect of starting time.
If you have confirmed that the bottleneck is the startup time then you may implement a very simple client/server with the advantage to be free to use any comunication program (netcat, wget, curl, perl, etc) and to have full control over the protocol.
“在下载之前,请注意它不安全。甚至不安全。虽然有办法确保客户端从本地计算机连接到服务器,但还没有任何“用户”的概念。任何程序在 Nailgun 中运行的程序与服务器本身具有相同的权限。”
我个人希望在投入生产之前解决这个问题......
"Before you download it, be aware that it's not secure. Not even close. Although there are means to ensure that the client is connected to the server from the local machine, there is not yet any concept of a "user". Any programs that run in Nailgun are run with the same permissions as the server itself. You have been warned."
I would personally like to have that fixed before putting it into production...
Nailgun 很好用,Netcat 也很好用。我都用过。 Netcat适用于任何程序,而不仅仅是Java。它可用于在 LAN 上执行关闭脚本。对于 Windows,您可能只需要使用 Nailgun。
Nailgun works well and Netcat works well too. I have used both. Netcat is suitable for any programs, not just Java. It can be used to execute say shutdown scripts across your LAN. For Windows you may just have to use Nailgun.