FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 19th, 2002, 01:25 PM
mcsimon mcsimon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 179 mcsimon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 38 sec
Reputation Power: 14
Send a message via AIM to mcsimon Send a message via Yahoo to mcsimon
net::ftp 2000 image files

Hi all -

How would perl handle a job putting about 2000+ files using the net::ftp module? (I don't have any number on the actual file sizes).

I want to run it as a scheduled job every so often. I have experience using net::ftp, but not with so many files.

Are there any traps to avoid when implementing this kind of program?

Thanks

Reply With Quote
  #2  
Old February 19th, 2002, 01:37 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
this will take quite some time since ftp takes several handshakes till transmission starts... regarding ping times, this can become:
1 ping takes 50ms
estimate 5 handshake-items, this makes quarter a second per transfer PLUS your actual data.
1/4*2000 = 500 seconds only for handshaking.

i have no experience using this module but log your sessions, then you can find out about the number of handshakes...

do they all go to the same server or different ones?

anyway,
send one after the other. donīt use threads or multiple processes with that many files.

some servers kill your script if it runs for too long though..

Quote:
I want to run it as a scheduled job every so often


check at the beginning if the last job has finished or donīt start. you will overload your server soon.

... any other suggestions?

Reply With Quote
  #3  
Old February 19th, 2002, 01:51 PM
mcsimon mcsimon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 179 mcsimon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 38 sec
Reputation Power: 14
Send a message via AIM to mcsimon Send a message via Yahoo to mcsimon
All the files are going to the same server.

I was thinking about using multiple processes, because of the server possibly killing a single long executing process. Though,I don't know how I could use multiple processes creatively or effectively for this type of application.

Why did you suggest not using multiple process?

Very helpful feedback.

Reply With Quote
  #4  
Old February 19th, 2002, 01:57 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
if you want to use several processes, dont spawn one for each transfer!! this is what i meant.
if you are not on an ultra-sparc 10k, more than a few 10 processes at the same time will kill your CPU and Network power.

Reply With Quote
  #5  
Old February 19th, 2002, 02:23 PM
mcsimon mcsimon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 179 mcsimon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 38 sec
Reputation Power: 14
Send a message via AIM to mcsimon Send a message via Yahoo to mcsimon
Quote:
if you want to use several processes, dont spawn one for each transfer!! this is what i meant.

That would be way crazy. LOL. But it would probably be fun to see how the CPU reacts ...

Anyway, how would somebody use multiple processes to tackle this? I was thinking about splitting the file transfers into 2, 3, or 4 optional processes. But I'm still in the learning stages with multi-process programming. And I'm learning it on windows, which doesn't help since I'm more comfortably with *nix.

Windows technology involved

Reply With Quote
  #6  
Old February 19th, 2002, 02:24 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
it is not that much different. i am no perl pro, but fork() should be available in perl...
be careful with parent/child processes. you need to "disown" somewhere so the forkīed process wonīt be killed if the parent process is...

Reply With Quote
  #7  
Old February 19th, 2002, 02:53 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 81
Send a message via AIM to Hero Zzyzzx
What kind of boxes are to transferring from/to? You might be better served with rsync, which can work over SSH.

Rsync is a very smart client- it will only upload files that have changed, and even then only the PARTS of the files that have changed. It's very, very fast as a consequence.

If you're transferring to a linux/*nix box running SSH, you can most definitely use rsync and cron to do this.

Reply With Quote
  #8  
Old February 19th, 2002, 03:50 PM
mcsimon mcsimon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 179 mcsimon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 38 sec
Reputation Power: 14
Send a message via AIM to mcsimon Send a message via Yahoo to mcsimon
transferring from windows 2000 to windows 2000.

fork() is available in Perl. It doesn't, unfortunately, work quite the same way for both windows and *nix.

NET::FTP might not be the right solution.

Reply With Quote
  #9  
Old February 19th, 2002, 09:45 PM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 14
Tou guys are talking about stuff way to much ;p. Unless it takes 300+ seconds to transfer one image (in which case you've got bigger problems then the ones discussed here) a typical ftp server wont time you out. Just split up the images and run multiple copied of the script at once (since fork( ) doesn't work in windows), or use threads to have one script do multiple things at once (you might be able to do an interesting thing with setting up a 'queue' for threads to read from -- just read all the files you need to upload into an array (the filenames of course, not the file content itself) and have each thread grab/upload that file, then grab the next one).

Also, if you're worried about getting timed out of the server -- Net::FTP will let you know if you can't upload a file for some reason:
Code:
unless($ftp->put('myfile.jpg')) {
    # something went wrong, it will tell you in $!
    # perhaps re-establish your connection with the ftp server
}
__________________
Jon Coulter
ledjon@ledjon.com

Reply With Quote
  #10  
Old February 20th, 2002, 09:24 AM
mcsimon mcsimon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 179 mcsimon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 38 sec
Reputation Power: 14
Send a message via AIM to mcsimon Send a message via Yahoo to mcsimon
I greatly appreciate the feedback.

I like JonLed's suggestion. I read about and tested fork() on windows 2000 with perl > 5.6 and it works, although, not like it's documented in Lincoln Stein's "Network Programming". That's another threaded discussion.

So, trying the queque thing and forking the job sounds cool.

Reply With Quote
  #11  
Old February 20th, 2002, 09:58 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 81
Send a message via AIM to Hero Zzyzzx
You haven't begun to live until you've known the true joy of rsync via SSH for transferring files. . . Look into it next time you need to do something like this on *nix.

But, given that you're on win32, it would be a slightly larger pain the butt to accomplish, though it would be possible.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > net::ftp 2000 image files

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap