Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

round robin query

Status
Not open for further replies.

scrsadmin

Technical User
May 3, 2004
62
US
I need to write a script that will send data to two different servers in a round robin style. I’m not sure what method I should take and wanted some other opions.

I could write it so that it queries a file that will either have a 1 or a 0 string in it.

And if it has a 1 then send the data to server “A” and writes a 0 in the file replacing the 1 that I’m using to query.
Then the next time the process sees it has data to send it would query the file and see that it has a 0 string and sends the data file to server “B” and then write a 1 in the file that it queries and so on.

Any ideas?
 
Do you need the script to be scheduled or will the script be running all the time?

If it needs to be scheduled then you could either try what you are suggesting or use the presence of the file. If the file is present, delete the file and send to server A. If the file is absent, create the file and send to server B.

If it is running all the time then just use a local variable. There are lots of techniques for flipping. You could use a logical flipper
Code:
dim serverA

serverA = true
....

' to flip
serverA = not serverA
if serverA then
   ' do server A
else
   ' do server B
end if
...
or an arithmetic flipper
Code:
dim serverA
serverA = 1
...
' to flip
serverA = 1 - serverA
if serverA = 1 then
   ' do serverA
else
   ' do serverB
end if


 
The script will be called by another process. The process hands off a data file that is sent to another server for processing. The server that does the processing is so busy that we thought to create two servers and have the script send the data file alternating between the two servers.
 
In that case a file semaphore should work fine. The only thing is I don't know whether it is more efficient to open a file, read it and change its value or to delete it and recreate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top