What is the server load when uploading files?

It isn't a secret that Rails doesn't handle uploads in the best possible way, but what are the limits of this?

I have a site that on a typical post will contain 5- 10 picture uploads each of which will have a size of ~100 - 300 kB. The current server setup consists of a 4 unit mongrel cluster. Will Rails/Mongrel be able to handle one person uploading 10 files as well as serving 10 other simple GET requests?

If not are there any common ways around this? ex uploading each file in a separate form POST via javascript (that is the only thing that I can think of right now).

Thanks for the help.

If you’re submitting all files from one single form, you shouldn’t worry all too much, the mongrel will still be serving requests during the uploads themselves. It’s when the uploading is finished that the mongrel will be locked by the single-threaded Rails processing request.

Another option is for you to use a small merb (which is multithreaded) application on a mongrel (with its own port). Then use the apache/nginx rewrite rules to rewrite certain urls to the merb application (e.g. every url that has the term “upload” in it).

Best regards

Peter De Berdt

Thanks Peter,

That cleared things up a bit.

It's when the uploading is finished that the mongrel will be locked by the single-threaded Rails processing request.

Is it during the ImageMagick processing of the files that it is locked up for? As you could tell I was under the impression it was during the upload which is obviously a lengthy period of time, so I am little off in left field with my understanding. :slight_smile:

I have heard that Merb is a good way to upload the files. I was waiting for some good documentation and examples to come out now that things have stabilized.

Thanks again

Is it during the ImageMagick processing of the files that it is locked up for? As you could tell I was under the impression it was during the upload which is obviously a lengthy period of time, so I am little off in left field with my understanding. :slight_smile:

Yes, and ImageMagick processing can take a while. In this case, there is a third option btw, and that’s that you hand the file(s) over to backgroundrb for processing.

I have heard that Merb is a good way to upload the files. I was waiting for some good documentation and examples to come out now that things have stabilized.

Although not everything might still use exactly the same api, there are some blog posts out there that already explain the procedure:

http://www.scribelabs.com/2007/10/18/file-uploads-via-merb-inside-a-rails-application-part-1-of-3/

http://railspikes.com/2007/4/1/merb

HTH!

Best regards

Peter De Berdt

It doesn't do multiple concurrent file uploads. I'm fairly sure that's
a limitation of the HTTP protocol if you're using standard forms. To
get multiple concurrent file uploads, you'd need to use AJAX or Flex,
I reckon.

Julian.

Learn about Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) http://sensei.zenunit.com/