Friday, 9 August 2013

How to delay xinetd starting a process until data is received

How to delay xinetd starting a process until data is received

I maintain a server that receives data on many ports using xinetd in tcp
mode. The data is processed by a perl script. Twelve of the 16 clients
that connect to my server that way, apparently also run monitoring
software against the same ports. I see two connections every five seconds
on each of those twelve ports in addition to the one that stays connected
all the time. These extra two connections disconnect immediately as soon
as they have a successful tcp connection. The Perl script also starts up
and shuts down every time there is one of these extra tcp connections. I
assume this is causing a lot of overhead. I want to keep xinetd from
starting the Perl script on these extra connections. I figure if there was
a way to delay the starting of the Perl script for one second like using a
sleep command in a shell script to start the Perl script then that would
vastly reduce the overhead. Is there a better way to do it using an xinetd
directive? One that would delay the starting of the server until data was
received or for one second should be all that is needed.
Here is a snippet of the messages log from the test box that is very
similar to prod but only has three open ports.
Aug 9 23:27:42 box xinetd[5082]: START: adt-client1 pid=19988 from=172.x.x.x
Aug 9 23:27:42 box xinetd[5082]: EXIT: adt-client2 status=0 pid=19987
duration=0(sec)
Aug 9 23:27:42 box xinetd[5082]: EXIT: adt-client1 status=0 pid=19988
duration=0(sec)
Aug 9 23:27:42 box xinetd[5082]: START: adt-client3 pid=19989 from=172.x.x.x
Aug 9 23:27:42 box xinetd[5082]: EXIT: adt-client3 status=0 pid=19989
duration=0(sec)
Aug 9 23:27:47 box xinetd[5082]: START: adt-client2 pid=19990 from=172.x.x.x
Aug 9 23:27:47 box xinetd[5082]: START: adt-client1 pid=19991 from=172.x.x.x
Aug 9 23:27:47 box xinetd[5082]: EXIT: adt-client2 status=0 pid=19990
duration=0(sec)
Aug 9 23:27:47 box xinetd[5082]: EXIT: adt-client1 status=0 pid=19991
duration=0(sec)
Aug 9 23:27:47 box xinetd[5082]: START: adt-client3 pid=19992 from=172.x.x.x
Aug 9 23:27:47 box xinetd[5082]: EXIT: adt-client3 status=0 pid=19992
duration=0(sec)
Aug 9 23:27:52 box xinetd[5082]: START: adt-client2 pid=19993 from=172.x.x.x
Aug 9 23:27:52 box xinetd[5082]: START: adt-client1 pid=19994 from=172.x.x.x
Aug 9 23:27:52 box xinetd[5082]: EXIT: adt-client2 status=0 pid=19993
duration=0(sec)
Aug 9 23:27:52 box xinetd[5082]: EXIT: adt-client1 status=0 pid=19994
duration=0(sec)
Aug 9 23:27:52 box xinetd[5082]: START: adt-client3 pid=19995 from=172.x.x.x
Aug 9 23:27:52 box xinetd[5082]: EXIT: adt-client3 status=0 pid=19995
duration=0(sec)
Aug 9 23:27:57 box xinetd[5082]: START: adt-client2 pid=19996 from=172.x.x.x
Aug 9 23:27:57 box xinetd[5082]: START: adt-client1 pid=19997 from=172.x.x.x
Aug 9 23:27:57 box xinetd[5082]: EXIT: adt-client2 status=0 pid=19996
duration=0(sec)
Aug 9 23:27:57 box xinetd[5082]: EXIT: adt-client1 status=0 pid=19997
duration=0(sec)
Aug 9 23:27:57 box xinetd[5082]: START: adt-client3 pid=19998 from=172.x.x.x
Aug 9 23:27:57 box xinetd[5082]: EXIT: adt-client3 status=0 pid=19998
duration=0(sec)
A typical xinetd connection is configured like this:
service adt-client2
{
disable = no
port = 5070
socket_type = stream
protocol = tcp
flags = KEEPALIVE
wait = no
user = root
server = /opt/receivers/adt/hl7_receive.pl
server_args = client2
}

No comments:

Post a Comment