Speed on Rails
Wow, long time no post :) I was busy at work and had taken a pause in following all the hypes _du jour_ on the web.
Meantime, I managed to improve my rails photo album (see mapopescu.com index page). After a couple of tries and (finally) a successfull installation of fastcgi on my Win XP machine, I decided to focus on the code and speed of the application rather on its deployment.
So I got back on using webbrick (the default webserver installed by rails). It is single threaded and more suitable for development, but still…
For the code, at first it was kind of weird, I had a feeling of panick because the Ruby code was still a stranger to me. Even if I advanced on full speed (using my “Agile Ruby on Rails programming” guide) , the code was just too easy and it didn’t “felt” right. So I bought the “Programming Ruby” book from PragmaticProgrammers.com. Now it starts to lighten, I begin to understand some wierd things (like blocks) etc. After a week or so of studying, I began to see my code was not so clean and dandy, so I splitted some classes, added some code from the controller to the model. I still don’t understand exactly how a model “finds” another class, which is not in it’s controller, neither in its appplication controller. I guess it will come in time. I must be too used to the “unit” view of Delphi … oh well :)
Then I improved my RMagick code, put the thumbnails in the database (this was a great improvement on the overall speed). Today I found another speed hack, I added a secondary index on some photos fields which are searched very often and mainly before serving a page to the client. Another big push (and obvious too, doh!).
Now I am much more confident in Rails, the whole deployment adventures kind of discouraged me. There are some things not very clear. I tried to add caching on the images being sent to the client, using caches_page, and I got a lot of .html pages looking weird (I guess they contained the images). The problem was that they weren’t served so well to the clients … I had crashes, plenty of errors on the development.log etc. I was still using fastcgi, don’t know if this can be related. So I rolled back this change for now.
For the whole deployment adventures I think a smoother path for the newbies (on ruby, rails, but apache too) it would be great to have some kind of server ready to deploy, multi threaded if possible, I don’t know, kinf of webbrick but serving more ports, or a windows app (service?) calling multiple cgi instances, or the SCGI for rails implementation … Something IS needed.

