Quickest way to access files

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Quickest way to access files

Post by pickle »

Hi everyone.

I have a script running every 10 minutes that needs to access files on a remote server. What would be the fastest way to do this? I want as little overhead as possible. So far, I'm using the ftp commands, but would it be quicker to call scp through the command line? Thanks.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: Quickest way to access files

Post by Roja »

pickle wrote:Hi everyone.

I have a script running every 10 minutes that needs to access files on a remote server. What would be the fastest way to do this? I want as little overhead as possible. So far, I'm using the ftp commands, but would it be quicker to call scp through the command line? Thanks.
SCP is actually much slower than ftp, because it has to build the secure connection up and tear it down for each session.

When you say access, you are unclear. Do you mean read or write? If its only read, http is faster than ftp (in my experience, depending on the server setup). From a purely protocol point of view, ftp's connections are more "simple", but they do require authentication - which can often be slower than the entire HTTP GET sequence.

Plus, with http you can do caching, load balancing.. the list goes on.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I'd only be using this to download a log file from a server. Just connect, download, and disconnect.

How would I use http to download this file? Can it be done if the log file isn't in the server root or accessible by Apache (and never will be)?

Thanks.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

pickle wrote:I'd only be using this to download a log file from a server. Just connect, download, and disconnect.
Then its either http or ftp for the speed demon in you.
pickle wrote: How would I use http to download this file? Can it be done if the log file isn't in the server root or accessible by Apache (and never will be)?
Well, again your wording is tricky. It sounds like you are saying that Apache itself can't even read the file. On most systems, you can (via scripting) allow Apache access to almost any portion of the filesystem - as long as you don't use safe_mode/chroot, and other protections of their ilk.

If Apache honestly cannot get to the file, then Apache cannot serve it, so its ftp or nothing.

However, a file does not have to be in the webroot to be accessible by apache. For example, my webroot /blah/public_html/game has scripts that write to /blah/cache_dir, which is *not* in the webroot, but IS accessible by apache.

Its just a matter of telling php where to look, and ensuring the file permissions are correct.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Ok, ya. I don't want to run anything on these remote servers - just grab the file. It sounds like the only way to use HTTP to access the log file, is to do it through Apache. I don't want this log file to be accessible via Apache, for security concerns.

You've given me enough info to sate my desire for more speed. It sounds like FTP is a reasonable way to do this, so I'll stick with what I've got.

Thanks a bunch!
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply