开发者

Ruby and rails perfomance issue, server

开发者 https://www.devze.com 2023-02-16 23:30 出处:网络
I\'m running a deployed rails webserver, and i\'m experiencing memory issues. I get an Errno::ENOMEM error each time i try to invoke sendmail. When i run \'top\' on my server, it shows me that 2 ruby1

I'm running a deployed rails webserver, and i'm experiencing memory issues. I get an Errno::ENOMEM error each time i try to invoke sendmail. When i run 'top' on my server, it shows me that 2 ruby1.8 processes are running, each digesting around 40% of memory. Is this caused by a leak in my code, or have I launched two simultaneous ruby processes?

Both processes are run by my deployer account, and following that they are invoked when I push to my production git repository (using pushand). I'm trying to开发者_开发问答 find out if this is natural (ie. server needs to be upgraded) or if I have some kind of fault in my setup. I upgraded my RAM from 256 mb to 512 mb recently, and didn't have this problem before.

The problem is preventing visitors from creating a user, because the application throws an error when they should get an activation email.

Note that I'm running rails 2.1.0 on an ubuntu setup, with apache and passenger.


Ok guys, I guess this was one of the cases where I had to help myself, and I'm actually pretty glad I did. I Didn't use any of the tools I linked to.

I logged in my server via. ssh and ran two commands in two screen windows: top and tail -f /var/www/mysite.com/log/production.log.

I looked in the live log file and noticed a page request that took a long time to load – a page where a user can get his/her images shown, where each user is identified by their name, via. acts_as_taggable_on. It took 6 seconds for this single request.

And it kept popping up. I think I saw it 6 or 7 times, and I decided to investigate it further. It was always the same user id, so I decided to look up the user. It turns out, the user had a blank name, "", and the tagged images is found by

Asset.tagged_with(@user.name, :on => "users")

Now in my app, there are 10s of thousands of assets, and Asset.tagged_with("", :on => "users") would return ALL of them, thus eating up my memory.

Now I've handled the case where a user has a blank name, and has it required for all new users. Even though no one helped, I still feel some gratitude towards stackoverflow, because sometimes its as simple as asking the questions to solve the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号