Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I defer processing during apache / mod_perl page rendering?

I have an apache2 / mod_perl website. On one page, I need to do some server/server communication via SOAP.

The results of this communication are not required for the rendering of the page (but user input is required to trigger this communication).

The SOAP communication is very slow.

So what I want to do is process and print the page for the user, then do all the SOAP stuff behind the scenes.

What's the best way to achieve this? start some fork? write the job to a file and have a cronjob pick it up?

Thanks

like image 575
aidan Avatar asked Dec 18 '09 16:12

aidan


1 Answers

There are two types of solutions: First you can do what Randal Schwartz suggested here. Second you could use a Message Queue like Beanstalk or Gearman. Beanstalk has a Perl Client and is now persistent and is ideal for lightweight stuff. Gearman on the other hand has more features, more worked on. There is also TheSchwartz - use it if you can do without too much documentation. cron is ideal for systematically repeating tasks. For the kind of application you have, it appears that Schedule::At might be more appropriate if you prefer a more generic "message-queue"

Also see an old StackOverflow Thread here

like image 152
Ya. Perelman Avatar answered Nov 04 '22 20:11

Ya. Perelman