views:

408

answers:

4

Can anyone give a concise set of real-world considerations that would drive the choice of whether or not to use inetd to manage a program that acts as a network server?

(If inetd is used, I think it alters the requirements around networking code in the program, so I think it's definitely programming-related and not general IT)

The question is based around an implementation I've seen that uses a control program managed by inetd to start a network listener that then runs forever and takes constant and heavy load. It didn't seem like a good fit with the textbook inetd usage profile (on-demand, infrequently used, lightweight) and got me interested in the more general question.

Thanks,

A: 

What alternative strategy are you considering?

inetd is a good way of ensuring your server starts when the OS boots in the appropriate run level. Even if you do design your server to have some other management mechanism, inetd could still wrap all the commands quite simply. It's only shell scripts after all.

Cogsy
Well - the alternative strategy would be to run the network program directly I guess, started from an rc.d script
Brabster
Actually, so maybe Windows/UNIX compatibility is a reason why you would choose inetd
Brabster
seeing mcrute's response just shows me how little I know about inetd. However many apps I've used/developed runs a daemon, then scripts are added to inetd to start/stop them. I guess the equivalent in windows is to install as a service.
Cogsy
+2  A: 

Hooking into inetd will make your service slightly easier to manage from an operational point of view as inetd allows a sysadmin to control practically all of how network communications with your program happens. However it will require you to make a few code changes to your program. Also, it may not be as efficient as just making your program run as a daemon to begin with.

EDIT: I personally never use inetd and always opt to write server processes as standalone daemons.

mcrute
+2  A: 

It depends on the usage pattern for your service. If the startup time for your daemon is low, and you expect it to be used infrequently, then inted might be a good fit. It reduces or even eliminates the need to write any additional networking code.

If your daemon is more heavyweight or more frequently used, you're probably better off writing it standalone. You can just as easily write an init.d script and some conf.d configuration to go with it and it will be no harder for an admin to manage. Most programming languages these days have easy to use socket libraries so in many cases the networking code may not even be that difficult.

I've found in my experience that few admins these days are familiar with inetd. Most daemons just provide their own init script. In fact, of the few hundred systems which I manage I can't think of a single one that launches anything through inetd at all. That's something worth considering.

Kamil Kisiel
A: 

I think another factor worth considering when deciding to use inetd is how much memory the process handling the request consumes on an average? If this is fairly high, then under high load you risk running out of memory (since inetd forks). The same server might be implementable in a multithreaded or select-poll manner possibly allowing for higher load / less memory per connection.

codelogic