# Processing uploaded XML file

**URL:** <https://www.ruby-forum.com/t/processing-uploaded-xml-file/156052>\
**Category:** Rails\
**Created:** [December 19, 2008, 8:40pm UTC](https://www.ruby-forum.com/t/processing-uploaded-xml-file/156052 "2008-12-19T20:40:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@marc](https://www.ruby-forum.com/u/marc)\
**Post date:** [December 19, 2008, 8:40pm UTC](https://www.ruby-forum.com/t/processing-uploaded-xml-file/156052/1 "2008-12-19T20:40:22Z")

</div>

Hi all

Sorry if this seems silly, only been learning Ruby and Rails for 2  
weeks, though I have been programming since the Commodore 64 came out.

I need to process an XML file once it is uploaded (currently using  
paperclip).  
The problem is that the files can be quite slow to process, up to 30  
seconds for some. Once this processing is done, I need to save that  
data to the model to which the file is attached.

So my question is, where is the best place to call the processing  
function from?  
Will the processing block mongrel? Should it go in a new thread? If  
so, how do I do that?  
And is there any speedier Library than REXML for processing XML?

Thanks for your help  
Marc

---

<div class="post-metadata">

**Author:** ![marc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@marc](https://www.ruby-forum.com/u/marc)\
**Post date:** [December 20, 2008, 12:51am UTC](https://www.ruby-forum.com/t/processing-uploaded-xml-file/156052/2 "2008-12-20T00:51:48Z")

</div>

Hi Marc,

Yes, the processing will block mongrel, but you should have more than  
one  
mongrel (either using Passenger, or straight apache load balancing). The  
bigger question is can your user wait 30 seconds for the response? There  
are ways to run the process on a separate thread, but I haven’t had to  
do  
that yet.

Yes, libXML is _much_ faster than REXML. We are in the process of  
changing  
our code, but the XML code is entwined so far through our app it is a  
big  
job.

Cheers  
Simon

---

<div class="post-metadata">

**Author:** ![marc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@marc](https://www.ruby-forum.com/u/marc)\
**Post date:** [December 20, 2008, 6:55am UTC](https://www.ruby-forum.com/t/processing-uploaded-xml-file/156052/3 "2008-12-20T06:55:00Z")

</div>

Thanks for the info Simon.

As far as the users waiting goes, thats easy… They will wait as long  
as I tell them to as long as I give them something to look at and a  
reason (Spinning CD and a “Please wait, Reticulating Splines” message  
perhaps). In fact the entire process isnt really a vital part of the  
program, it is simply to display some extra information for other  
users who may want to download it. So if that information was updated  
say 5 minutes later, it wouldnt really matter.  
In any event, I am having a look at starling and working to start a  
threaded process in the background and update the record whenever it  
finishes. If however libxml is as fast as you say, perhaps I simply  
need to do some load balancing and make them wait.  
Of course a major problem is that I still dont know where to call the  
processor from. Rails can be extremely frustrating when you are still  
learning it.

Thanks for the info Simon  
Marc
