# Uploading 2+ files simultaneously

**URL:** <https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364>\
**Category:** Rails\
**Created:** [July 28, 2006, 4:24pm UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364 "2006-07-28T16:24:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [July 28, 2006, 4:24pm UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364/1 "2006-07-28T16:24:06Z")

</div>

I’m having trouble uploading 2+ files simultaneously (from different  
client machines)…

the upload page just hangs…

I’m running…

- ruby 1.8.4 (2005-12-24) [i686-linux]
- rails 1.1.4
- red hat el 4
- apache
- fcgi (0.8.7, 0.8.6.1)
- firefox 1.5.0.5
- httpd.conf

 FastCgiIpcDir /tmp/fcgi\_ipc/ AddHandler fastcgi-script .fcgi FastCGIConfig -minProcesses 2

thoughts/suggestions?

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 16, 2006, 3:16am UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364/2 "2006-08-16T03:16:13Z")

</div>

I am having the same type of problems. I am running apache with 2  
fastcgi  
instances. What is happening is each fastcgi instance is blocking  
during a  
file upload, so if 2 people are uploading files then both fastcgis are  
being  
blocked and no other web requests are processed. What is a solution to  
this  
problem?

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 16, 2006, 6:01am UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364/3 "2006-08-16T06:01:29Z")

</div>

Run more FCGI instances?

I believe there are also some (really excellent) solutions forming  
around Mongrel.

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 16, 2006, 12:40pm UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364/4 "2006-08-16T12:40:57Z")

</div>

I am running 2 FCGI instances and they use about 22MB a piece. I can’t  
add  
too many more without maxing out my 128MB VPS box. Anyone know how  
37signals guys handle this with backpack, etc? I’ll keep an eye out on  
Mongrel.

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 16, 2006, 4:50pm UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364/5 "2006-08-16T16:50:36Z")

</div>

Hi,

I don’t know what the solution to this problem is, however I’m having  
the exact same issues. If anyone has suggestions regarding how to  
handle this with FCGI, I would also appreciate it!

-Steven

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 17, 2006, 3:31am UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364/6 "2006-08-17T03:31:24Z")

</div>

I’m starting to feel like this is an issue that does not have a  
resolution,  
which would mean that it would not possible to create a rails app with  
multiple people uploading at the same time on anything less than a  
dedicated  
box. Is this really true?

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 17, 2006, 3:40am UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364/7 "2006-08-17T03:40:26Z")

</div>

You need to add more dispatchers. You also need to make sure you can get  
the  
file there in a reasonable amount of time… some hosts have a timeout  
on  
fastcgi so if the upload takes too long, it will just disconnect the  
client.

The solution is to scale up. Rails requests are single-threaded.

The “big guys” are running lots of dispatchers on multiple machines. I  
think  
someone on here from Strongspace mentioned that they currently use 20  
dispatchers, but don’t quote me on that.

People are working on plugins for Mongrel that offload the file uploads  
to a  
different process and then pass the file to Rails when the upload is  
done. I  
don’t know how that’s coming but perhaps someone else can shed some  
light on  
this.

Beware: this is not just a problem with file uploads… it’s a problem  
with  
requests and Rails in general. If your machine can only handle 5  
requests  
per second, then your 6th person is going to wait until someone else is  
done. They requests will queue up and you will see terrible performance  
unless you load-balance with multiple dispatchers.

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 17, 2006, 4:49am UTC](https://www.ruby-forum.com/t/uploading-2-files-simultaneously/100364/8 "2006-08-17T04:49:31Z")

</div>

Brian, thanks a ton for your excellent response!
