简体   繁体   English

在开发环境中加速Rails应用程序?

[英]Speed up Rails App on development env.?

I have huge Rails app on development right now, which run VERY slow on -e development. 我现在有大量的 Rails应用程序正在开发中,它在-e开发上运行非常慢。 I use Mongrel as web server. 我使用Mongrel作为Web服务器。 Is there any way to speed up a little bit everything? 有什么方法可以加快一点点的速度吗? Because i have to wait 3-10 sec. 因为我必须等待3-10秒。 to reload a page. 重新加载页面。 Thanks. 谢谢。

This is the answer to all of your woes: 这是你所有困境的答案:

https://github.com/thedarkone/rails-dev-boost https://github.com/thedarkone/rails-dev-boost

The best way to make development faster is installing gem named active_reload . 使开发更快的最佳方法是安装名为active_reload gem

To install this gem , you can enter command, 要安装此gem ,您可以输入命令,

gem install active_reload

And, in your rails project gemfile, add 并且,在你的rails项目gemfile中,添加

gem 'active_reload'

Then, restart your server and you will find development mode much faster than it used to be. 然后,重新启动服务器,您将发现开发模式比以前快得多。

A very simple way to get a speed boost is to turn on class caching in development mode... 获得速度提升的一种非常简单的方法是在开发模式中启用类缓存...

In config/environments/development.rb: config.cache_classes = true 在config / environments / development.rb中:config.cache_classes = true

That means Rails won't reload all the models/controllers/etc. 这意味着Rails不会重新加载所有模型/控制器/等。 on every request, so it'll go a lot faster, but it means you have to stop/start your server to see changes to anything except views. 在每个请求上,所以它会更快,但这意味着您必须停止/启动您的服务器以查看除视图之外的任何内容的更改。

If you're on windows, use some mingw builds of Ruby http://rubyinstaller.org/downloads/ 如果您在Windows上,请使用Ruby的一些mingw构建http://rubyinstaller.org/downloads/

If you're on linux, this might be helpful for running tests 如果您使用的是Linux,这可能对运行测试很有帮助

http://github.com/candlerb/snailgun/tree/master http://github.com/candlerb/snailgun/tree/master

如果你需要3-10秒来在本地渲染一个动作,也许有些事情需要进行一些优化。

I think if you're on Vista, Mongrel has performance issues when bound to all addresses (0.0.0.0) 我想如果你在Vista上,Mongrel在绑定到所有地址时会出现性能问题(0.0.0.0)

Bind to 127.0.0.1 or your real IP (mongrel -b 127.0.0.1 -p 3000 -e development) and see if it makes a difference. 绑定到127.0.0.1或您的真实IP(mongrel -b 127.0.0.1 -p 3000 -e开发),看看它是否有所作为。

Also, if you have a connection intensive software currently open, like bittorent with a lot of open connections, your network interface might reach a maximum number of connection and slow down Mongrel. 此外,如果您有一个当前打开的连接密集型软件,例如具有大量打开连接的bittorent,您的网络接口可能会达到最大连接数并减慢Mongrel的速度。 Closing bittorent, then maybe even rebooting, might fix your problem. 关闭bittorent,然后甚至可能重新启动,可能会解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM