I've been developing RoR apps for about a month in my Windows Laptop, however everytime that I run the tests it takes forever to finish (10+ minutes).
On a MacBook Pro with similar hardware it runs in a fraction of the time (2 minutes).
Can you guys give me any tips for speeding the whole thing up? or should I consider switching my RoR environment to a Linux/Mac box?
I do most of my ruby development in an Ubuntu VM, just because it is easier to get everything together under linux (I imagine the same applies to OSX). RVM makes my life so much easier.
If your hardware can support it and you don't mind working in a VM, may I suggest you give it a try? VM development has its advantages (namely, taking daily snapshots so you can roll back environment changes) and disadvantages (you lose a bit of speed, but not much these days) but I think it is worth it overall.
Related
I am using Fitnesse as a home Wiki and running it on a Netgear NAS storage solution. The OS distribution is Linux Axentra. I'm not expecting performance to be great but there are only 2 people using Fitnesse on a casual basis and thinking I can get away with it on this under specced hardware.
I'm finding that the Netgear Stora is grinding to a halt especially when I am using Fitnesse. The only way to fix this is to remove the power and restart. Can anyone suggest where I might start looking for a solution. I have spent some time on Google and wondering if this has something to do with memory.
I'm not strong technically (it took me a fair bit of time just to get Fitnesse installed and starting) however, I'm keen and willing to try things out if I can get a nudge in the right direction.
I'm running a ruby on Rails service. Ruby 2.0 and rails 4.0 The job on heroku takes ~2x the time it does on my local machine. I would expect the processing elements to actually run faster on the big *#!# server than on my macbook air.
sorry for the lousy formatting Times are in seconds 1.00000
Herok Macbook Air delta
job_id=Job.where(id:user.id, active:true).pluck(:id)[0]___t1=0.003 _t2= 0.126_delta=0.123
{job Prep}_____________________________________t1= 0.00_t2=0.00_delta=0.00
imagedata=Jobimage.find_by(job_id: job_id, level:0)___ t1=0.349 t2=0.044 delta=0.305
image=Marshal.load(imagedata.data) _______________t1=0.374 t2=0.096 delta= 0.278_
Job processing ________________________________t1= 0.51 t2=0.328 delta=0.182
render json:answer.to_s_________________________t1=0.51 t2=0.328 delta0.182
Except for the Job -processing block, these are statements bracketed by logging statements
I'm really surprised by 4 and 6
Can anyone explain why Heroku would be getting the stuffing kicked out of it my my notebook
thanks
You're one of many (hundreds? thousands?) of people sharing that physical box, and Heroku has no incentive to make your code fast for a free instance. Your Macbook Air is doing (more or less) one thing.
I would look into the delayed_job gem. Judging by the things you have timed in your breakdown, I don't think it will apply directly to what you are trying to accomplish, but it might be useful in a different part of your project.
I have just finished a Rails-application that I now want to upload to the web. It is a re-write of an existing application and I expect some 4 000 visitors a day with peaks to 10 000 a day at times.
I know Windows fairly well (have not used Windows server though).
I hardly know anything about Ubuntu or Linux
I want things nice and easy and don't want to spend too much of my time "hacking the server". I want to spend my time developing, not maintaining.
My budget is ~50$ a month at most for this project.
The database for the project is quite static (hardly any user generated data)
I am currently using WAMP & Mysql with Rails 3.0.3 on my local installation and it works fine most of the time but crashes quite often as well.
I am considering three ways of doing that:
Using Heroku
Seems quite easy (even though I haven't gotten it to work yet)
Also seems expensive, if I need more nodes. How many nodes should I expect to need?
Using a VPS Windows server
I know Windows and it would be fairly easy to install and get it set up
My friend (who is more of a Rails expert) says that Windows and Rails is not a good match.
My crashes on my local environment makes me nervous about this option
Using a VPS Ubuntu server
Seems to be the cheapest option (in terms of paying up-front)
Seems to be the most stable option
I don't know Ubuntu and I am not too eager to learn a whole new OS to get this set up.
Could you help me with directions? Is Windows server really bad for Rails?
Quite honestly, I think Windows would be the worst choice for you. The problem with Windows and Rails is that most of the gems are never designed to work with Windows, or the versions that do work with Windows are far outdated.
Using an Ubuntu VPS is a very viable option, would be your cheapest and most stable option. We use Amazon S3 services to run most of our web servers in the cloud. Like you said, it does require you to know and understand a *nix operating system to maintain.
Maybe for you, Heroku may be the best option. Heroku is super simple to setup your project on and then deploy. There are also pages of documentation to help you along the way. In a few basic commands from the terminal, your application is running. I often use Heroku as a 'staging' server to test application updates among beta users before pushing to production on S3. You also are not required to learn a new operating system to use it.
If you are running into problems with deploying to Heroku, please post the issues and we will gladly help you.
I would advise against a windows server. From my experience, the major ruby implementations are not optimized for windows - and run slowly. For the sake of your end-users, a rails stack on Linux may provide significant performance gains (or equally decrease your server budget).
With bundler and rails 3, the amount of maintenance work on the server should be minimal. Log in, deploy, log out. (look into tools like capistrano to make this even more straightforward).
By far the easiest production I've found so far is an Ubuntu server.
On Windows Rails tends to be slower and it's far simpler to setup something like passenger on *nix. If help is needed, there are more tutorials available.
My fastest setups have been Ubuntu Server and nginx.
PS. Rails 3.0 has gone beyond 3.0.3 so think about testing the latest version 8)
Heroku is delightfully easy to deploy to. If your database load is light, you can just use their shared 20GB PostgreSQL database ($15/mo). 2 dynos will cost you ($35/mo) so there's your $50 there. 2 should be fine to handle that traffic, and you can always scale during your high traffic times. Definitely would recommend adding the memcached add-on and utilize that as well. Install the New Relic add-on and you can analyze your traffic/load and scale accordingly.
I'd heavily advise against using Windows for a rails app deployment. Some gems compile slower on Windows, and some don't work at all.
I've worked with Heroku, but there are some complications with writing files to the Heroku instance as Heroku does not allow for local file writing. When working with Heroku, people usually offload write operations like file-upload to an Amazon S3 instance or Fog. In general, Heroku is really easy to deploy to, but when configuration comes along...it may be a bit more complicated than a VPS.
The best solution for me would be to go via VPS using Ubuntu. There's been a lot of documentation done on this, and you have more options with your configurations. In actuality, it's not so much different from setting up Ruby on Rails on a local Ubuntu development machine. If you need tips on how to deploy on Ubuntu, I've just recently written a guide on how to do so.
http://www.francisbautista.com/deploying-ruby-on-rails-apps-on-a-vps-nginx-passenger-capistrano/
I have a handful of Ruby/Rails apps I'm building locally. I've noticed lately that no matter which app I'm working on, my Ruby process will build up to 90+%, the CPU fan will kick on, and there's no stopping it unless I kill the sucker. Doesn't seem to matter which app I'm working on. Any ideas? Any way to track what's wrong?
I've run the apps on Mongrel, Apache/Passenger, and POW, and every time I get the same result.
And BTW I don't have any jobs or tasks running constantly. This CPU hogging is happening without the servers being hit.
My system:
Ruby: ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Rails: Rails 3.0.4
OSX 10.6.7, MBP 2.53 GHz Core 2 Duo
Have you tried opening a terminal window and running top, or opening Activity Monitor, then running each one individually and seeing when your CPU starts to climb? Both top and Activity Monitor will let you sort by the CPU load an app is generating. Use top -o cpu and watch to see if the highest load is the app you ran or maybe something else the app is causing to run.
A Rails app will spike when it starts up but should settle down as it waits for incoming connections. If you have periodic tasks it's performing you should see those cause the CPU activity to spike again then drop when the task ends.
You're on a MacBook Pro. How much RAM do you have? Maybe your apps are running low and having to swap out too much? That would affect your overall system performance making the CPU work harder, causing it to heat up. A MacBook Pro's hard disk is designed for battery efficiency, not high performance, so if you're hitting the disk hard with a lot of database I/O, you could be heating the machine up and causing the apps to wait due to record locking or some sort of contention.
There's a lot of different things that can cause your machine and apps to slow down, and you haven't really given us a lot to work with, so those are some general ideas of what I'd look into.
I have noticed this also and was able to pin-point it.. If I run top -o cpu, and then open another terminal window and run IRB, and then close the terminal window without exiting out of IRB, then suddenly top shows a ruby process at around 90% CPU. If I do the same experiment but exit out of IRB prior to closing the window, there is no 90% ruby hog.
So, apparently we need to be careful to not close terminal windows unless we have properly exited out of ruby programs.
This might be more of a suggestion than an answer, because I don't know if it covers your issue, but it takes just a few minutes, and you might want to try it.
I have had this problem on FreeBSD, and here was my solution. Somehow, the versions of Ruby / Rails / etc were not compatible with one another, and they also did not give me error messages I could always chase down.
I'm sure you are doing this, but make sure your bundle is always up-to-date.
I switched to rvm (Ruby Version Manager), and stopped using system Ruby altogether. This was overall the best sysadmin move I made with Ruby, because Mac OS X / Macports (my dev machine) and FreeBSD / ports (my production machine) are way behind in Ruby versions.
I can see that you are at ruby 1.8.7 patchlevel 174 on Mac OS X -- the current version's patchlevel is somewhere at or above 330.
Moreover, if you are pushing to a production server that's not Mac OS X, then you're going to probably get better portability with RVM, because you can install the same versions of Ruby, Rails, and all gems, on both machines.
Say, I love Debian+mod_rails and run it on my laptop which is my development platform. Yet, I am deploying to a production server running Ubuntu+mod_rails.
Is it better in a long run if I install Ubuntu on my laptop or are the problems with deployment so miniscule I can go with whatever the hell I like on dev. machine?
Thanks.
The problems with deployment, especially between debian and ubuntu, are so miniscule you can go on without worrying about it.
However, I wouldn't do it myself, because when that miniscule problem occurs, it's really hard to find and resolve. At minimum make sure you have a staging setup that is exactly the same as the production server and perform testing on that if you don't or can't make your development machine match.
-Adam
Deployment is always a hassle with rails, but I wouldn't worry about it. You just set it up once with capistrano and it's pain free from then on. I use windows for dev, and mac or linux on a virtual host for prod.
I think this is true for any programming language, but no you shouldn't have different OS's for DEV/TEST/PROD. 99.9% of the time you won't notice a difference or problems, but that very small percentage 0.1% of the time, you'll be pulling your hair out trying to figure out what is wrong.
You're increasing the likeliness of things going wrong while you transistion between development and production.
Which means that you're just going to get more stressed out.
Which path you choose is really up to you ;)