10 Replies Latest reply on Sep 21, 2007 3:18 PM by iKnowKungFoo

    CFFTP & Multiple Servers

    mletson
      Hello,

      We have one website clustered on two servers. The servers are cf07 and cf14. When a user uploads a file on CF07 and then returns the next day to review the file, it isn't there! This is because yesterday, they were on cf07 and today they happen to be on cf14 (of course, they wouldn't know this).

      Problem: How can I initially upload the file to both servers so that the user won't have this problem?

      I've looked at cfFtp but no luck so far.

      Thanks,
      Mike
        • 1. Re: CFFTP & Multiple Servers
          Level 7
          There may be other ways to replicate files accross clustered servers.

          But the CF solution that popped into my mind is to do a <cffile
          action="copy"...> shortly after your <cffile action="upload"...> to
          replicate the uploaded file to the other server.

          While typing this, I then thought of a common file server. Is it
          possible in your network to have a common file server that both CF
          servers are aware up and this is where the files are uploaded.
          • 2. Re: CFFTP &amp; Multiple Servers
            Level 7
            Sorry I just noticed that the file is uploaded with a CFFTP not a
            CFFILE, but I think the proposed solutions work the same either way.
            • 3. CFFTP &amp; Multiple Servers
              mletson Level 1
              Ian,

              Using cfFile between different folders on the same server would be fine but, I'm talking about physically separate file servers with different IP addressess. To my knowledge, cfFile does not allow UNC path conventions (for example) so I think cfFile will not work.

              We do not have a third and common file server. Also, I am uploading the initial file using cfFile.

              Thanks,
              Mike
              • 4. Re: CFFTP &amp; Multiple Servers
                Level 7
                "To my knowledge, cfFile does not allow UNC path conventions (for
                example) so I think cfFile will not work."

                <cffile ...> does handle UNC paths just fine, I use them all the time in
                my projects. There is just a bit of configuration required for them to
                work, especially on window CF installs. By default the windows
                ColdFusion service runs under the 'localsystem' user and has no
                permissions to any network resources. To use UNC paths one just needs
                to create a domain user with the desired permissions and assign the CF
                service to run under that user. And restart the CF service of course.

                On UNIX systems CF already runs under a user account so one just needs
                to provide that user with the required permissions to the desired
                network resources.

                With this in place one can easily do things like <cffile action="copy"
                destination="\\cf14\a\directory\path\"...>



                • 5. Re: CFFTP &amp; Multiple Servers
                  Wilgeno_wnt Level 1
                  Before we had a single file server that our CF servers all accessed we used to have this problem.

                  To compensate we had code that would save the file locally with cffile and then FTP the file via <cfftp> to the other server.

                  The best solution here is a single file server that all of your cf servers can access. All four of our CF servers do this now.
                  • 6. Re: CFFTP &amp; Multiple Servers
                    mletson Level 1
                    Ok.

                    Our ColdFusion server runs under an account we created called cFusion. In order to impliment what you suggested, all I have to do is make sure the account "cFusion" has read / write permissions on the file directories in question?

                    Thanks,
                    Mike
                    • 7. Re: CFFTP &amp; Multiple Servers
                      mletson Level 1
                      Ok.

                      Our ColdFusion server runs under an account we created called cFusion. In order to impliment what you suggested, all I have to do is make sure the account "cFusion" has read / write permissions on the file directories in question?

                      Thanks,
                      Mike
                      • 8. Re: CFFTP &amp; Multiple Servers
                        mletson Level 1
                        Ok,

                        This is what I did:

                        On each server, I gave the "cFusion" account read and write permissions on the specific directory in question.
                        I then did a cfFile action = "copy". In the destination attribute, I used the computer name of the server where I want to copy the file to, followed by the complete path, including file name.

                        The template didn't throw and error and there is nothing in the logs. However, no file.

                        Thoughts?

                        Thanks,
                        Mike
                        • 9. Re: CFFTP &amp; Multiple Servers
                          Level 7
                          You seem to have a fairly robust application, is there any possible of
                          potential errors being handled by some level of exception processing code?

                          Can you try a path you know is foobar and make sure an error is actually
                          displayed?

                          Also a delay may be required. In some cases I have heard of when
                          receiving a file and then immediately trying to move or copy it, the OS
                          is not done with the first file operation before the second one is fired
                          by CF. This can have unexpected behavior. A few moments of sleeping
                          may be helpful between the upload and the copy.


                          • 10. Re: CFFTP &amp; Multiple Servers
                            iKnowKungFoo Level 1
                            We're currently in the same situation you're in. Since we don't have a SAN, my predecessor used the only shared storage he had at the time: the database. Rather then upload all the files to a folder, any uploaded document is placed in the database as a BLOB. When a document is requested, a process checks if the document exists on the file system. If not, then it retrieves it from the database and places a copy on the file system. This way subsequent requests from the same server return the file from disk and not the database.

                            Thankfully, we're upgrading our infrastructure and our new setup will have a SAN (plus CF8).

                            In the meantime, on Linux I'd have used rsync to keep the folder contents consistent between servers. After a bit of Googling, I've found one Windows program that does the same thing. Might be worth a look.