简体   繁体   English

Windows上的Rails:慢?

[英]Rails on Windows: Slow?

I am doing some initial testing for a Rails app which will be deployed on Windows, but the development server in a VirtualBox is painfully slow. 我正在对将部署在Windows上的Rails应用程序进行一些初始测试,但VirtualBox中的开发服务器速度非常慢。 I've never seen anything like this in Linux (but the server platform must be Windows), even in an identical virtual appliance. 我在Linux中从未见过这样的东西(但服务器平台必须是Windows),即使在相同的虚拟设备中也是如此。

Is Rails on Windows viable in terms of speed? Windows上的Rails在速度方面是否可行?

I've tried 18.6, 1.8.7 and 1.9.1 on Window, OS X and Linux. 我在Window,OS X和Linux上尝试过18.6,1.8.7和1.9.1。 I have found the response time using Windows to be longer than using either OS X or Linux (Webbrick and Mongrel). 我发现使用Windows的响应时间比使用OS X或Linux(Webbrick和Mongrel)要长。 If I use Windows purely as a server, response time seems as OS X Linux, but much slower if I develop and render result using any browser whilst using the same computer. 如果我纯粹使用Windows作为服务器,响应时间似乎是OS X Linux,但如果我在使用同一台计算机时使用任何浏览器开发和渲染结果,则会慢得多。

I started RoR programming in Windows and yes, the server is really slow. 我在Windows中启动了RoR编程,是的,服务器非常慢。 It did not matter if Windows was running in a vbox or directly as the OS, the server was slow. 无论Windows是在vbox中运行还是直接作为操作系统运行,服务器都很慢。 I've tried several things to get it faster (one cpu core just for ruby, etc), but nothing really helped so I went to Linux as working was much faster. 我已经尝试了几个方法来加快它的速度(一个cpu核心仅用于ruby等),但没有什么真正有用,所以我去了Linux,因为工作速度要快得多。 You just can't work with a good speed if you have to wait for a server response everytime. 如果每次都必须等待服务器响应,那么你就无法以良好的速度工作。

I've been developing rails in windows for three years and the performance has been fine actually. 我已经在windows中开发了三年的rails并且性能一直很好。 My setup is relatively powerful: Dual Core 3.0 GHz, 3 gigs of ram, and it outperforms my coworker's new macbook pros by 20-30%. 我的设置相对强大:双核3.0 GHz,3 GB的内存,它比我的同事的新macbook专业人士高出20-30%。 (When running 1200 integration tests). (运行1200次集成测试时)。

That said, I have has ruby crash randomly after moving to 1.9 so I would definitely not recommend running any production server using MRI on windows. 也就是说,我有一个红宝石随机崩溃后移动到1.9所以我绝对不建议在Windows上使用MRI运行任何生产服务器。

You should strongly consider switching to JRuby if you are going to host your site on windows. 如果要在Windows上托管您的站点,您应该强烈考虑切换到JRuby。 Many production rails applications run on JRuby, and it's performance great and does not vary much between platforms. 许多生产轨道应用程序在JRuby上运行,它的性能很好,并且平台之间的差异不大。 Here's a list of some sites running JRuby: http://kenai.com/projects/jruby/pages/SuccessStories , and the home page for it is: http://jruby.org/ 以下是运行JRuby的一些站点的列表: http//kenai.com/projects/jruby/pages/SuccessStories ,其主页是: http//jruby.org/

Another option for local development (that I have used on occasion) is to run Rails inside of a CentOS VMWare instance. 本地开发的另一个选择(我曾经使用过)是在CentOS VMWare实例中运行Rails。 Though my experience has been that the performance has been about the same or slightly slower, in that environment. 虽然我的经验是在那种环境下性能大致相同或略慢。 You may see a benefit if you run rails in a multithreaded state (instead of just launching script/server). 如果在多线程状态下运行rails(而不是仅启动脚本/服务器),您可能会看到一个好处。

Good luck! 祝好运!

I on the other hand find it to be pretty stable, and don't have any kind of speed problems. 另一方面,我发现它非常稳定,并且没有任何速度问题。

I've been using Rails with Windows and Linux (still to use it with Mac OSX), and have had exactly the same sort of response times. 我一直在使用Windows和Linux的Rails(仍然在Mac OSX中使用它),并且具有完全相同的响应时间。

I prefer to use it on Linux though, because of the terminal and all the Linux goodies, but am pretty happy to use it on Windows. 我更喜欢在Linux上使用它,因为终端和所有Linux好东西,但我很高兴在Windows上使用它。

Update: 更新:

Thought it would be nice to complete saying I've used Rails both from a Windows Machine, and from a Linux Machine with a virtual windows install, and as previously stated, i had the same sort of response times. 认为完成说我从Windows机器和使用虚拟Windows安装的Linux机器上使用Rails会很好,并且如前所述,我有相同的响应时间。

为了加速,你可以尝试我的装载机调速器上部(帮助导轨在打瞌睡中跑得更快): https//github.com/rdp/faster_require也结帐spork,在打瞌睡中没有工作,jruby也运作良好。

This answer dates back to 2012, so the solution (and syntax) below refers to Windows XP. 这个答案可以追溯到2012年,因此下面的解决方案(和语法)指的是Windows XP。 Not sure if this also applies to other dated Windows versions like Seven or Vista, it might still be worth checking it... 不确定这是否也适用于其他日期的Windows版本,如Seven或Vista,它可能仍然值得检查...


I found that on a Windows XP machine running out of HDD space, Rails performance is heavily degraded when the OS automatic file compression is turned on (it is by default) it has already compressed a lot of files. 我发现在用尽硬盘空间的Windows XP计算机上,当打开操作系统自动文件压缩(默认情况下)时,Rails性能严重下降,它已经压缩了很多文件。

To fix that, first free up as much space as you can, and then decompress all the files that got automatically compressed by the OS with the following command: 要解决此问题,请先释放尽可能多的空间,然后使用以下命令解压缩操作系统自动压缩的所有文件:

compact /u /s /i compact / u / s / i

(run it from the root dir, ie "C:\\") (从根目录运行它,即“C:\\”)

(just for the record, compressed files are marked in blue in Windows File Explorer) (仅用于记录,压缩文件在Windows文件资源管理器中标记为蓝色)

In my case "rails -v" took 15 seconds before that, while after decompression (of some 54000 files...) it only took 2 seconds, as it initially did when I originally installed Ruby. 在我的情况下,“rails -v”在此之前需要15秒,而在解压缩之后(大约54000个文件......)它只用了2秒,就像我最初安装Ruby时一样。

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

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