FTP hangs Rails!

Hi! I’m running a Rails app on Apache/FCGI, with a single handler
process on the server.

At one point my application needs to FTP a bunch of files to a remote
server. When it starts doing this, the server apparently freezes and
doesn’t allow anyone else to do anything. Plus, after about twenty
seconds, my nice status page vanishes from the browser, even though
the FTP’ing is continuing on the server!

Is there an easy fix for this, or have I run into a bigger problem here?

Thanks,
Raymond

On 22/03/06 11:36 -0800, Raymond B. wrote:

Thanks,
Raymond

Hi Raymond,

That doesn’t seem like a rails problem. More of an OS or FTP daemon
problem. What do the resource stats on your machine look like when
you’re FTP’ing the files?

Regards,
Jason

On Wed, 2006-03-22 at 11:36 -0800, Raymond B. wrote:

There could be a memory leak somewhere that causes this. It’s hard to
say without some more specific information about the tasks being
performed and the logs that are being generated.

-Robby


/**************************************************************

  • Robby R., Founder & Executive Director *
  • PLANET ARGON, LLC | www.planetargon.com *
  • Ruby on Rails Development, Consulting, and Hosting *
  • Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 *
  • blog: www.robbyonrails.com | book: www.programmingrails.com *
    ***************************************************************/

On Fri, Mar 24, 2006, Raymond B. wrote:

Thanks Jason and Robby for your responses!

What was happening was this. Using Apache and apparently a single FCGI
process. Which seems weird in and of itself. This is on a shared host
which already had some glitches to be ironed out before Rails would
even work. Running a shared host serving Rails apps must be one of the
hardest jobs in the world, for real!

I think you can tune the number of processes it starts, but I’m not sure
how.

Anyhow, there’s this ftp routine that copies a bunch of files, and the
HTML page that’s rendered beforehand just shows a spinner kinda thing.
After all the files get copied, you’re redirected to the home page.
This works fine for me on Lighttpd, Webrick, and Apache also on my OSX
box. But on the server, everything freezes while FTP is taking place.
Literally, no-one else can use the system. Plus, the web browser
decides to crap out after about 15 seconds or less, throwing a blank
page or a network error!

Were you spinning off a new thread (in ruby-land) to do the FTP? If
not, perhaps you should try that and see if it fixes your problem.

Ben

On 3/24/06, Ben B. [email protected] wrote:

I think you can tune the number of processes it starts, but I’m not sure

Were you spinning off a new thread (in ruby-land) to do the FTP? If
not, perhaps you should try that and see if it fixes your problem.

Don’t waste your time spinning a new thread. Ruby has green threads, so
they are per interpreter instance only. You’re best bet is to fork the
call
to FTP so that it is it’s own process, this way you don’t have to worry
about it aborting mid way, or hanging up an FCGI process.

Ben

Thanks Jason and Robby for your responses!

What was happening was this. Using Apache and apparently a single FCGI
process. Which seems weird in and of itself. This is on a shared host
which already had some glitches to be ironed out before Rails would
even work. Running a shared host serving Rails apps must be one of the
hardest jobs in the world, for real!

Anyhow, there’s this ftp routine that copies a bunch of files, and the
HTML page that’s rendered beforehand just shows a spinner kinda thing.
After all the files get copied, you’re redirected to the home page.
This works fine for me on Lighttpd, Webrick, and Apache also on my OSX
box. But on the server, everything freezes while FTP is taking place.
Literally, no-one else can use the system. Plus, the web browser
decides to crap out after about 15 seconds or less, throwing a blank
page or a network error!

For now I just moved the app back to TextDrive, since the problem was
not exhibited there. However, TextDrive is running lighttpd with four
fcgi processes, so I’m not sure if the fifth user to try this FTP
thing would be locked out or what. It’s weird. Moving to TextDrive has
spawned other problems however, such as a memory ceiling that nearly
every RMagick call hits. Oops!

So this is just to clear it up… If you’re running an app with any
kind of serious needs, Apache/FCGI is really inadequate. This has
surely been said many times before! Furthermore, shared hosts have
their own host of problems, no matter what. Lighttpd solves most of
them, in my experience, but some remain. For example, the RMagick
problem I may be able to solve by moving to MiniMagick but haven’t
gotten there yet. We shall see.

In conclusion, I would love to see someone come up with a real
dedicated Rails hosting system. It will be tough but I think you could
charge a bit more for it, provided many of these kinks were ironed
out. I know TextDrive is trying to do this, but whoever does it first
deserves to make a good living!

As an aside, I hear the brilliant Pragmatic Programmers are coming out
with a book specific to Rails deployment. Is this true? Or is it just
a rumor? If it’s true, I’m the first in line!

Cheers and thanks again,
Raymond