Page 1 of 1

Server loop avoidance.

Posted: Fri Nov 09, 2018 7:04 pm
by ajperks
From experts advice here on the Forum, and what I have read on the subject, constant cycling of an idle looping server slows down everything else running on that computer.
No doubt someone has a better idea than this, or has invented it already, but what do you think?

My server could just do one pass and complete all its duties. Then run a separate program and exit.
The separate program has a wait state so it is effectively asleep for a time and then checks to see what work has come in for the server to process. In my case, if it is more than X number of files then the program loads and runs the server and terminates.
The wait state can subsequently become shorter or longer based on the flow of incoming files.
I don't know what waste or overhead restarting programs has other than the initialisation of variables, so I look forward to your advice and ideas.
Thank you.

Re: Server loop avoidance.

Posted: Fri Nov 09, 2018 9:29 pm
by dunbarx
Hi.

Are you familiar with "sending in time"? It is rarely advisable to use "wait", except in very isolated and well compartmentalized cases.

Check out the "send" command in the dictionary.

If you do use "send", then the overhead and other troubles are likely not overly onerous, at least no more so than the code you are executing.

Craig Newman

Re: Server loop avoidance.

Posted: Sat Nov 10, 2018 6:39 pm
by jacque
I agree with Craig, LC has the feature you need built in, so there's no reason to make it more complex. If you do decide to use a second app, you'll have the same problem. The wait command is blocking and can affect the rest of the server as well, so you'd need to use "send" there too.

Rule of thumb is to avoid the wait command for long, ongoing processes. At the very least, use "wait with messages".

Re: Server loop avoidance.

Posted: Sat Nov 10, 2018 9:53 pm
by FourthWorld
Use a request-and-reply protocol like HTTP and you never need to worry about how to handle this on the server.

If you choose HTTP specifically, you also get a vast universe of tooling, docs, and standardization as well.

Re: Server loop avoidance.

Posted: Sun Nov 11, 2018 4:44 pm
by ajperks
Thank you all for the well received advice.
I think that is the answer.