Webservice vs FTP service

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
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Webservice vs FTP service

Post by kendall »

I am building a service in which I need to tranfer a binary file from one server to the next and back when finished.

My questions is...which is more effective/ faster/ effcient to use?

1) use xml-rpc to encode and pass the file binary data to the server
2) use php ftp to transfer the file...
3) use the file_get_contents() to get the file
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Webservice vs FTP service

Post by John Cartwright »

A download will typically be several times faster an than upload, so the file_get_contents() would be the fastest.

I would probably use the FTP functions since is probably the most flexible method out of the box.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: Webservice vs FTP service

Post by kendall »

thanks for the tip
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Webservice vs FTP service

Post by josh »

rsync, more secure ( operates over ssh ) more efficient.. or scp, sftp, etc..

John I'm curious why you say a download will be faster? Won't the server still be doing uploading no matter what method is used? I thought it took 2 to tango, a client and a server
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: Webservice vs FTP service

Post by kendall »

josh wrote:rsync, more secure ( operates over ssh ) more efficient.. or scp, sftp, etc..
ok whats rsync? I was hoping not to implement any more libraries...just installed that pecl upload progress extension...So i'm going to try that.
josh wrote:John I'm curious why you say a download will be faster? Won't the server still be doing uploading no matter what method is used? I thought it took 2 to tango, a client and a server
I am also curious...what are you trying to say...whose faster? ftp, file_get_contents or xml-rpc?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Webservice vs FTP service

Post by josh »

http://www.samba.org/rsync/

Under a few large files being transferred protocol will play little to no effect. It is when you are moving 999999 small files ( like a web crawler ) the minor differences in libraries will play a larger role.

At your linux command line type 'man rsync', most systems already have it, its as common a command for some as 'cp' or 'mv', scp is the same kinda deal ( a utility /command for network copying over ssh that all linux machines have now adays ). Rsync has the advantage of really good efficiency in terms of copying only differences. ( SCP would copy a whole folder even if nothing changed, rsync would copy just 1 byte if thats all you changed in a 100MB file )

http://www.samba.org/rsync/features.html
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Webservice vs FTP service

Post by s.dot »

file_get_contents() will use memory mapping techniques
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Webservice vs FTP service

Post by josh »

scottayy wrote:file_get_contents() will use memory mapping techniques
"file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance. "

I would read that line with a grain of salt just because loading an entire file into memory isn't always the "preferred" way to read a file, like if the file is larger then available memory on the system. It's probably true for "average" file reading situations, but without more details as to # of files, size, transfer frequency, available bandwidth, etc.. etc... its hard to recommend a single "Best" option
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: Webservice vs FTP service

Post by kendall »

I went ahead and installed the uploagprogress PECL extension. I have decided to go with $_POST...and then probably FTP the file back...Did not like the fact that I had to transfer the file 3 times...What are your thoughts on using $_POST for this sort of thing?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Webservice vs FTP service

Post by josh »

Uh it'll work just not as portable ( max filesizes, and other configuration changes ), not as reliable as something with resume
Post Reply