General discussion

Locked

multiple rcp commands in parallel

By les ·
I have multiple hosts on my network. All can communicate with rcp. I have certain files to send out to all servers on a regular basis. These can be quite large (5mb). I can easily have a script to do it one by one, however i have 25 servers to send out to and 5mb can take up to 15 minutes on our network. Hence the whole process will take some time to complete.
So how can i run the same rcp command in parallel to all servers at the same time?

This conversation is currently closed to new comments.

10 total posts (Page 1 of 1)  
Thread display: Collapse - | Expand +

All Comments

Collapse -

multiple rcp commands in parallel

by TimTheToolMan In reply to multiple rcp commands in ...

Hi,

You will almost certainly find that if you try to copy to 25 servers at once, the copy will be significantly slower than copying to one at a time.

The bottleneck is almost certainly going to be the network itself - which will be at a high utilisation rate for even a single copy and when you perform additional copies simultaneously, you will cause collisions and retries.

This will be worse and worse with increasing amounts of concurrency.

It sounds like you have a 10Mb network. You would do FAR better to upgrade it to 100Mb! Often people dont actually have a reason to upgrade to 100Mb - for normal user traffic, the difference between 10 and 100Mb is virtually unnoticible.

You do have a reason. Frequent, large file copies justify the upgrade.

Cheers,
Tim.

Collapse -

multiple rcp commands in parallel

by les In reply to multiple rcp commands in ...

Poster rated this answer

Collapse -

multiple rcp commands in parallel

by cpfeiffe In reply to multiple rcp commands in ...

I agree with the first answer and don't recommend copying the files at the same time. But if you must or want to try just once, you can write a script as you said to do these one at a time, but at the end of each line put an "&" (minus the quotes, of course). This will background your process and allow the next line of your script to run. Its a very simple way to get all 25 going at the same time. But, once again, I think this will make matters worse. I would focus on the network. I want to share something that I've discovered at a client of mine recently and will do so with an attached comment.

Collapse -

multiple rcp commands in parallel

by cpfeiffe In reply to multiple rcp commands in ...

You say 15 minutes for 5 MB. That is 3 minutes for 1 MB. Further math tells you that you are getting one Mb (8 Mb in one MB) every 22.5 seconds. That is very poor. Even on a 10Mb network you should be getting about 5 Mb per second or around 112.5 times faster. A 100Mb network would make this scream. Therefore, I don't think your biggest problem is 10Mb or 100Mb. It sounds like you are having a lot of collisions, regardless of your infrastructure. You may need to ask networking some questions so here are some thoughts. Are you using hubs or switches - hubs are more prone to collisions. Now onto what I've learned at my client. The network team had all of the switches set to Auto Negotiate on a 100Mb network. The Ops team had all of the servers (Unix, Linux and Intel) set to Auto Negotiate. In some cases both sides Negotiated 100FD. In other cases one side would go 100FD and the other would go 100HD or 10HD. This caused extremely poor performance, much like what you are seeing. Auto Negotiate is never guaranteed to work right between two devices. There are just so many things that can be different are go wrong. Some devices would be fine one time and the on a reboot they would go to 10HD. After convincing both NW and Ops to force each connection to 100FD performance really picked up. Even forcing to 10FD was better than the mis-match. The mis-match causes collissions and makes things way worse than they should be. In Linux you can set the speed of an interface with ndd.

ndd -set /dev/lan instance 0
ndd -set /dev/lan adv_100fdx_cap 1
ndd -set /dev/lan adv_10fdx_cap 0
ndd -set /dev/lan adv_100hdx_cap 0
ndd -set /dev/lan adv_10hdx_cap 0
ndd -set /dev/lan adv_100T4_cap 0
ndd -set /dev/lan adv_autoneg_cap 0

This sets the interface 0 for the module lan (assuming your network interface is lan0 - you can change this as needed). Then it sets 100FD to on and turns everything

Collapse -

multiple rcp commands in parallel

by cpfeiffe In reply to multiple rcp commands in ...

In Linux you can set the speed with ndd.
ndd -set /dev/lan instance 0
ndd -set /dev/lan adv_100fdx_cap 1
ndd -set /dev/lan adv_10fdx_cap 0
ndd -set /dev/lan adv_100hdx_cap 0
ndd -set /dev/lan adv_10hdx_cap 0
ndd -set /dev/lan adv_100T4_cap 0
ndd -set /dev/lan adv_autoneg_cap 0

This sets the interface 0 for the module lan (assuming your network interface is lan0 - you
can change this as needed). Then it sets 100FD to on and turns everything else off. By turning off Auto Negotiate last, you allow the machine to auto negotiate to 100FD first, since it is the only available option, besides the Auto and then turn Auto off, thus not causing the interface to drop a connection to renogiate the speed again. Do not do this without talking to networking first. You need to make sure that the network is 100FD or whatever it is and you need cooperation. They will have to set the switch at the same time you set the server. A mismatch (100FD on your end and Auto on the switch) will cause the same problem. You can put these commands in a start script (recommend /etc/rc2.d/S70net.speed) to make them permanent with each reboot.

Collapse -

multiple rcp commands in parallel

by les In reply to multiple rcp commands in ...

Poster rated this answer

Collapse -

multiple rcp commands in parallel

by SeanWalton In reply to multiple rcp commands in ...

If you are on a trusted network that supports multicasting (the routers must have this feature enabled), you can use a tool I built for my book "Linux Socket Programming". This program takes a file and pushes (tossfile.c) it out to the network on amulticast address. Those servers which are listening to that address/port with the listening program (catchfile.c) get the file in pieces.
This program was designed for distributing very large files (like CDROM ISOs). It is resumeable and minimizes network impact. You can get the program from "http://www.linuxsocket.org/tools/applications/index.shtml". Let me know if you need any help adapting the program to your specific needs.

Collapse -

multiple rcp commands in parallel

by les In reply to multiple rcp commands in ...

Poster rated this answer

Collapse -

multiple rcp commands in parallel

by les In reply to multiple rcp commands in ...

The server i am sending from has a 100mb nic card, connected to a 100mb switch. All remote branches are connected on their own dedicated frame link. However a good majority of these are only connected on 10mb hubs, hence the speed is only 10mb.
What i would probably do is set the script to do say 5 servers in parallel then wait for them to finish, then do another 5 etc. This way instead of taking 65 minutes to do 5 servers in a row, 5 servers could be done simultaneously in 13 minutes. Grantedthat running the simultaneous command will slow things down a bit.
If i set 4 commands to run in the background how can i check to see if they are finished? (without putting in a sleep 9000 or something like that)?

Collapse -

multiple rcp commands in parallel

by les In reply to multiple rcp commands in ...

This question was closed by the author

Back to Linux Forum
10 total posts (Page 1 of 1)  

Related Discussions

Related Forums