Page 1 of 1
Webservice vs FTP service
Posted: Wed Sep 23, 2009 2:42 pm
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
Re: Webservice vs FTP service
Posted: Wed Sep 23, 2009 3:03 pm
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.
Re: Webservice vs FTP service
Posted: Wed Sep 23, 2009 3:29 pm
by kendall
thanks for the tip
Re: Webservice vs FTP service
Posted: Thu Sep 24, 2009 9:22 pm
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
Re: Webservice vs FTP service
Posted: Fri Sep 25, 2009 9:02 am
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?
Re: Webservice vs FTP service
Posted: Sat Sep 26, 2009 9:37 pm
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
Re: Webservice vs FTP service
Posted: Sat Sep 26, 2009 9:42 pm
by s.dot
file_get_contents() will use memory mapping techniques
Re: Webservice vs FTP service
Posted: Sat Sep 26, 2009 10:17 pm
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
Re: Webservice vs FTP service
Posted: Tue Sep 29, 2009 6:33 am
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?
Re: Webservice vs FTP service
Posted: Tue Sep 29, 2009 6:55 am
by josh
Uh it'll work just not as portable ( max filesizes, and other configuration changes ), not as reliable as something with resume