Prev | Current Page 160 | Next

Brad Ediger

"Advanced Rails"


This variable is accessible to the Rails handler as Mongrel::Uploads. A simple Rails
action (called via AJAX) calls Mongrel::Uploads.check(upload_id) to check the status
and update the client.
Though all of this complication makes it possible to use just one Mongrel process,
most moderately trafficked applications will require multiple Mongrels. All actual
Rails requests are still serialized, so the number of requests being processed in Rails
concurrently is limited to the number of Mongrel processes. However, the sharedmemory
solution used previously does not work with more than one Mongrel??”each
Mongrel is a separate process and they have no shared memory.
The solution is to use DRb (Distributed Ruby). A background process is started as a
shared repository for upload status. Each upload handler notifies the background
process of its status via DRb as it receives blocks from the file. The Rails handlers can
then query the common backend for the status of any file, regardless of which Mongrel
handled the original upload or status request.
The upload progress gem can be installed with gem install mongrel_upload_progress. A
sample Rails application illustrating how to use the gem is located at http://svn.technoweenie.
net/projects/mongrel_upload_progress/. The official Mongrel upload progress
documentation is available at http://mongrel.rubyforge.org/docs/upload_progress.


Pages:
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172