A lot of applications have a middleware layer. In some ways,
ActiveRecord or Mailer is thought of as a middleware.
But, for example with J2EE, you can run background servers and threads.
Can this be done with Ruby and how?
A lot of applications have a middleware layer. In some ways,
ActiveRecord or Mailer is thought of as a middleware.
But, for example with J2EE, you can run background servers and threads.
Can this be done with Ruby and how?
Berlin B. wrote:
A lot of applications have a middleware layer. In some ways,
ActiveRecord or Mailer is thought of as a middleware.But, for example with J2EE, you can run background servers and threads.
Can this be done with Ruby and how?
I take the code I need to run separate from rails and set it up as a
system daemon. I put all of these in my lib/standalone/
directory. Example:
/var/www/myapp/lib/standalone/report_generator
/etc/init.d/report_generator start|stop|restart
My rails app communications via Unix sockets to my report_generator.
Zach
That is interesting. I like that approach. How does the ruby client
code work. Basically, does it timeout or cause a lot of issues.
Berlin B. wrote:
That is interesting. I like that approach. How does the ruby client
code work.
The client just opens a Socket connection to the server, and sends it
instructions. The server takes the instructions, and the
server process creates a new thread and does whatever it needs to do
based on instructions. We make the following assumption:
Basically, does it timeout or cause a lot of issues.
A handful of times it was reported that it didn’t correctly generate the
report for the end user, however, it was hit half a
million times in about 2 weeks and it’s hard to prove a handful of times
something not working. Although I am investigating. =)
The biggest issue we’ve seen is memory consumption. We use this tactic
for generating CSV reports from a database. Some CSV
reports which include 45,000 or greater (upward of 275,000) records can
really suck up the memory. We have avoided this as being a
huge problem by doing two things:
There are some changes I am making to my system to fix these initial
issues, if interested contact me off list…
Zach
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs