From: Steven Stanfield Date: 2002-09-05T16:27:47+09:00 Subject: Re: Options for optimizing a large Ruby system You could try a web application server. I just released ocelot (I will be changing the name with the next release to avoid the conflict pointed out by Peter Gulutzan a few days ago, see ocelot.scarecrowtech.com). It (and I assume other app servers) work by starting up a Ruby instance and loading up your project which stays in memory for the life of the server instance (you will not have to reload your classes on each request). You can use the proxy module of Apache and a couple of rules to use it as a front end and let it handle all your static content. It does essentially what was described in an earlier post for fastcgi (I have not used fastcgi, just going on what someone else posted). The downside is you will have to modify your app to use the servlet API instead of CGI, this is not hard but will be extra work (you do pick up session management for free though). If you do not use something like fastcgi or an app server you can also run your own copy of Ruby with your app and listen for requests on a port. Then use a CGI stub app to send request to it and return them to the browser (I used this method for my first prototypes of ocelot and it works pretty well, but you are going to add overhead with all the extra connections). This is basically what fastcgi does for you so I guess all it buys is a finer level of control (fastcgi is probably more optimized for this job as well). I am pretty sure that this is the method used by Red Hat's Interchange server, so there is some precedent for using it in your situation (you should also be able to get the C code to their CGI stub app, using a C app for the stub would be a good idea since it will have to be loaded for each request). Steven Stanfield On Thu, 5 Sep 2002 07:25:33 +0900 sera@fhwang.net (Francis Hwang) wrote: > Hi everybody: > > I've written a large e-commerce system in Ruby, and it works fine but > it's slow. After poking around the code a bit, I think that the big > bottleneck comes from loading all the required files. The system is > extremely OO -- more than 100 separate classes -- and there're a lot > of classes that need to be loaded in with "require" statements before > a single line is executed. > > So now I'm looking around for ways to speed things up. Using modruby > is probably an option, but I'm unsure as to whether that'll do what I > need ... I know it keeps the Ruby interpreter in memory, but I really > need something that might keep loaded classes in memory. Does modruby > do that, or is that too much to ask? And failing that, what do people > think would be the next best option for me to pursue? > > Thanks in advance, > > Francis