I have VirtualBox with Ubuntu 11.10 on Windows7.
I run Rails 3.1 on webrick (rails s) and go to VirtualBox's IP adress (192.168.2.xxx:3000) from browser on Windows.
At this moment I face troubles - page loads very very slowly, on Rails console i see how slowly it responses files (css, js, images): up to 5 seconds for each!
But: if I go 0.0.0.0:3000 inside Ubuntu - it works perfect.
Where is the problem? Where to look for a solution?
As mentioned above, it appears this is a duplicate of another issue, though that issue specifically mentions webrick and a remote desktop connection, neither of which was I looking for, as I didn't know it was specific to webrick.
So I think it should be noted that this is NOT a misconfiguration of the virtual machine or BIOS settings or anything like that. This is strictly a webrick issue. Other services work just fine if they aren't trying to do reverse DNS lookups.
The problem stems from Webrick's default setting to try and do a reverse DNS lookup, which has issues when the lookup fails, as it tends to do consistently for me on my local machine.
There are a few ways to fix this.
Hack /etc/hosts
The first is to hack /etc/hosts so your client machine has an entry. Hacking /etc/hosts is semi-advanced, but basically amounts to figuring out what you host machine's IP address is and adding a line to your /etc/hosts file. This requires root-level permissions.
Get your IP address - this will be seen in the Rails console when you make a request, and will look something like this: Started GET "/" for 10.0.2.2 at Tue Aug 21 11:33:23 -0700 2012 - in this case, the IP address is 10.0.2.2.
Add a line to /etc/hosts to identify that IP address: 10.0.2.2 Nerdmaster
All should be well!
Disable daemon
This seemed to work for some ubuntu users:
service avahi-daemon stop
Given you're killing a service, there may be other apps which have issues. This is probably best as a temporary measure, not a permanent one, but I know very little about the service, so avoid taking my word for this one :)
This also requires root-level permissions.
Hack webrick
I really despise hacking core Ruby code that I have to re-hack on every update, but this is what a lot of people do:
Find your webrick/config.rb
It may be in /usr/lib/ruby/[version]/webrick/config.rb if you're running a normal Ruby
If you use RVM, you'll have to find the appropriate ruby directory, e.g. /home/username/.rvm/rubies/[version]/lib/ruby/[version]/webrick/config.rb
I don't know jack about other options like rbenv
Worst-case scenario, try find / -type d -name "webrick"
Edit in your favorite editor (obviously this would be vim)
Look for :DoNotReverseLookup => nil.
Change nil to true.
If you don't see this setting, you may have to use the /etc/hosts hack above.
If you aren't using rvm or something similar, this will require root-level permissions.
Don't use webrick
I don't think this is a real solution, as webrick is sometimes your best (or at least quickest) option, but you can try a different server. Thin and mongrel seem to have good support and, based on what others with this problem are saying, appear not to do a reverse DNS lookup. I haven't tried these approaches, so I don't know for sure how good they are.
This can be done without root-level permissions.
Edit your Gemfile to add:
gem 'mongrel'
bundle install
rails s -> will use mongrel instead of webrick and be lightning fast.
For me the slowness of Rails 4 (1 second+ for each asset 304) on an Ubuntu guest VM turned out to be Virtualbox shared folders. Found that cause in this thread, moving away from shared folders fixed the speed issue for me.
I am using windows10 home edition with 8 ram, 250g ssd, when I run Rails4.x (thin) on Virtual box with ubuntu server 16, I found the render time is extreamlly slow, mostly up to 4 - 5 seconds, finally I moved rails project from host shared folder to Virtualbox vm inside, it's become quite faster now.
Try turning off your firewall or antivirus on Windows.
I liked Scott's answer of just switching to mongrel, but if you're using a modern version of ruby (> 1.9.1), mongrel is no longer supported. (Install Mongrel in Ruby 1.9.3)
I switched over to thin - http://code.macournoyer.com/thin/
sudo gem install thin
thin start
and it's super snappy for me.
Related
I have the following config
Ubuntu server 10.04 running on a VirtualBox VM (RAM and cpu usage are low)
ruby 1.9.3
rails 3.2.12
webrick
If I do any of the things below the system seems to wait for about 15 seconds before executing the command
- rake taks
- rails s
- navigating to a new page in the app
Things I have looked at
- this is before the sprockets section, and does the same with rake, so at the moment I am not looking at things such as dev-tweaks
- I have changed the webrick config.rb to have the line :DoNotReverseLookup => true
- I have host entries for my host machine on the VM. ping is very fast between both machines
- I have tried Thin and experienced the same issue. I haven't tried mongrel but am thinking I will see the same
But still it is excruciatingly slow.
Any thoughts?
Michael
If you're using VirtualBox shared folders (vboxfs), disk I/O is probably the issue.
vboxfs is really slow, and Ruby on Rails does a lot of files operations in development mode (checking if any files changed etc.).
If you're not using Windows, sharing folders with NFS is the way to go.
Check this link:
http://meta.discourse.org/t/shared-folder-performance-on-vagrant/2443/14
I had this issue using VirtualBox shared folders. As soon as I switched to NFS, I couldn't really make a difference between running natively or in the VM. I imagine Rails autoloading in dev mode is the culprit here. See here on how to configure vagrant to use NFS: https://coderwall.com/p/uaohzg
If you can't setup NFS properly (on OSX 10.7 I had to install NFS Manager to make it work), you can always script away and rsync your rails folder every time you modify files locally in your editor. You don't want to run rails on a VirtualBox shared folder.
I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?
Also, this will be an internal app, so performance isn't my number once concern.
Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :)
Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems.
From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems.
Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details.
Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set.
You might run into some gems (such as BackgroundRB) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine.
Just grab the Bitnami RedMine stack.
Or the Bitnami Ruby on Rails stack.
Redmine ran fine on our Windows build server from the command line, sans IDE, using Mongrel and SQLite. Granted, ours isn't a VPS, but at any rate Linux isn't required for this app.
The BitNami Redmine Stack is a free, up to date Windows installer package for Redmine on Windows, Linux, OS X... give it a try. You can also download a VMWare Virtual Machine as well
I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times.
You might also try ruby stack or flash rails, though I've not used either personally.
You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible.
Try using a Rails distribution like: http://instantrails.rubyforge.org/wiki/wiki.pl
One download install for rails+ruby+mysql on Windows.
Would some of the more advanced rails developers please share what they have found to be the most productive combination of OS, IDE, etc. (i.e. the set-up that gives the least of amount of compatibility issues, headaches)? Also, what is the most commonly used setup?
I presume the common setup is common because it is thought to be the best compromise between all the options.
And that common setup is:
Mac OS X
TextMate
rvm
There's a lot of nuance to your question, for example you'd probably want to take into account what you already have, what your appetite is for spending money, etc. This is before even coming to the minefield of personal preference. :)
Here's a starter list:
Operating System
In my experience on both, Mac > PC for Rails programming because it creates fewer unforeseen/annoying problems.
IDE
Depends on how 'rich' you like your environment to be. Some people who like light environments simply use Notepad++; others use richer options like TextMate (Mac only) or RubyMine.
General Set up
Rails 3.1, MySQL
Local Server
Webrick and Mongrel are fairly popular.
Hosting
Heroku is extremely popular for Rails apps. It's free for low traffic and they're beautifully designed for Rails. If you want to avoid the server reloading problem (webpages take a while to load if no one has requested them in a while), you can set up NewRelic or Pingdom to ping the app and keep it active.
Performance Monitoring
NewRelic
I moved from Windows for Rails 3 to a Ubuntu 11 virtual machine running on Windows via VMWare player.
I'm using Gedit along with GMate (source here) to make Gedit more similar to TextMate for Rails Development.
I've found the setup to be way faster running on the virtual machine than it was on Windows directly. It took some time to get set up but once done, I just transfer the vm image from machine to machine. The setup was all free too (besides my laptop and the copy of Windows 7 on it).
The most common development environment I suspect you'll find among the Rails illuminati is probably:
Mac OS X (though some use Linux)
various Ruby versions/gemsets in RVM
TextMate or MacVim as the IDE (gvim or vim for the Linux folk, usually, though some prefer Emacs)
SQLite or MySQL for development database
Webrick, Mongrel, Thin, or flavour-of-the-day lightweight local webserver
My app is in development and I do all my testing using WEBrick (I like the terminal output).
On the production server it will run on Phusion Passenger.
I'm running Snow Leopard and wish to test the app in an environment similar to the production environment.
Can I use Parallels to run a Debian install with Apache and Passenger and configure Capistrano to deploy to that?
Thanks!
I have been using VMware for that sort of thing. Its really easy to deal with network wise. I have recently switched to Virtualbox which is much nicer to actually work in (at least for me), does the same things, and is free. Download the Debian iso and create a new VM that uses it as its CDrom. Thats about all you need to do. Good luck.
This may not be the answer you're looking for but I've found it very straightforward to just run passenger locally for development. You can always tail the development.log, it's really just as easy as watching the terminal output from webrick.
Dev setup is made all the easier with the drag and drop ease of the phusion passenger pref pane.
http://www.fngtps.com/passenger-preference-pane
Seems like it would be easier than setting up the VM and all. Though yes, there could still be differences if your not hosting on OS X server I suppose.
I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?
Also, this will be an internal app, so performance isn't my number once concern.
Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :)
Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems.
From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems.
Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details.
Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set.
You might run into some gems (such as BackgroundRB) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine.
Just grab the Bitnami RedMine stack.
Or the Bitnami Ruby on Rails stack.
Redmine ran fine on our Windows build server from the command line, sans IDE, using Mongrel and SQLite. Granted, ours isn't a VPS, but at any rate Linux isn't required for this app.
The BitNami Redmine Stack is a free, up to date Windows installer package for Redmine on Windows, Linux, OS X... give it a try. You can also download a VMWare Virtual Machine as well
I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times.
You might also try ruby stack or flash rails, though I've not used either personally.
You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible.
Try using a Rails distribution like: http://instantrails.rubyforge.org/wiki/wiki.pl
One download install for rails+ruby+mysql on Windows.