What are the advantages and disadvantages of using Nailgun vs netcat to provide fast CLI to a Java application?
Asked Answered
P

3

5

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.

Padus answered 28/10, 2010 at 10:4 Comment(4)
Nailgun? Great name for an old Quake fan like myself :-)Jalapa
@seanizer: Oh, yes. It reminded me of the old battles as well =)Padus
Why do people assume that versions of a software package below 1 must indicate that the package is unstable? This is probably not the right place to discuss this but version 1 should mean that all the intended features have been implemented. It is by no means a guarantee that the program is stable or secure. Besides, instead of making your own netcat-whatever, why not look at nailgun, find what it misses to meet your goals and contribute to 0.7.2 or whatever?Wentz
I find Nailgun to be a great tool; however, it worries me as well that the last release is now some 7 years old... I wonder if that is because it works flawlessly and there's nothing more to add (well, what about some simple authentication mechanism?) or whatGallinaceous
U
4

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.

Uncommercial answered 28/10, 2010 at 11:3 Comment(3)
I already implemented the proof using netcat and it works very well in terms of performance although special care should be taken to use socket's input and output stream instead of standard input/output. This was actually inspired by your comments in my previous question, so thanks a lot. I was wondering, however, why would one create a separate tool (I mean nailgun) for this, hence the question.Padus
Hello, nailgun author here. If you're comfortable writing your app as a server and handling the socket comms, and the netcat approach meets your needs, there's really no reason to go with nailgun. Some reasons to use nailgun are automatic redirection of app's System.in/out/err, return of exit code by client, transmission of client env to server, ability to run multiple apps in same VM, and ability to run existing apps in nailgun with no modification at all. It's quite stable and is used in commercial products, although there are some features I'd add if I had the time. Cheers!Joe
@MartyLamb Are you still actively developing NailGun as of today?Gallinaceous
W
3

"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...

Whereas answered 28/10, 2010 at 10:46 Comment(2)
Thanks for pointing this out. That's a serious issue and AFAICS it applies to netcat as well.Padus
I'd love to see that fixed too... At least a simple password passed to ng (same to be passed to client and server), to start withGallinaceous
R
0

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.

Retrospect answered 4/5, 2015 at 4:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.