Background
I'm running a Ruby on Rails application that has to serve a lot of static files as well.
My setup currently is:
Debian Linux Lenny 5.0
Apache 2.2.9
Passenger 2.2.10
The problem
Everything runs fine. I see apache process spinning up, passenger instances get created and everything works fast and snappy.
Then, after some time Apache does not respond to requests any more. Clients do get a connection and are "waiting for a response", but none comes.
I cannot manually reproduce this problem. Sometimes it occurs a few hours after a restart, other times it takes a few days to happen. Here's what I found:
Apache process are up; Passenger is there, but it does not have any instances spun up (probably because instances die after a period of inactivity)
No error messages or problems in /var/log/syslog, /var/log/messages, not in apache's access and errors logs, not in my Rails production log. Nothing.
When I stop and start apache everything is back to normal.
Does any one have any clues what's happening here? And how it can be resolved?
Due to an enormous load on static files we decided to host static files on separate server (later Amazon S3+CloudFront) for performance reasons.
My current guess is that Apache couldn't cope with the large number of requests on static files and also doing Passenger. The current setup is Nginx+Unicorn for the Rails application and S3+CloudFront for static files.
Related
I am trying to upgrade jruby. Went to a latest version 9.1.12.0, didn't work. Tried one version up (9.1.0.0) and same issue
The issue is it takes a very long time to boot on tomcat. Once tomcat starts the application it becomes unresponsive. Browser hangs forever and then eventually times out. Tomcat log shows that the request came, was served reply and closed (everything normal). No errors show up in tomcat log.
Tomcat is sitting behind apache, connected though AJP. I tried switching to http(s) and neither worked. Going directly to tomcat yields the same results.
I worked on solving this issue for quite some time. Not sure why it hangs and doens't throw any errors. Tried changing configurations on rails/tomcat/apache and could not find why it doens't work.
Any help tracking down this issue would be greatly appreciated
Current stack:
Rails 4.1..15
Jruby 9.0.5.0
Tomcat 6
Java 1.7.0_131
Apache 2.4.7
sounds like an enthropy depletion might be going on,
export JRUBY_OPTS=-J-Djava.security.egd=file:/dev/./urandom
or in your case :
export CATALINA_OPTS=-Djava.security.egd=file:/dev/./urandom
explanation is this' questions answer: After Upgrade To JRuby 9.1.9.0, Rails CookieStore Very Slow When Handling Encrypted Cookies
... the next jruby-openssl release should hopefully handle this better
I'm running my Rails application through thin on Windows OS.
thin start -e production
Since the number of users grew, now around 10 people using the app simultaneously, there are times when a same page takes a while longer to load.
Are there other configurations that I need to set when running the server on production?
I'm quite sure that it has to do with the server since the slow down happens on pages that normally loads fast.
The Thin webserver is not meant to production environment. Instead of this you should use a different webserver and application server like Nginx/Unicorn, Nginx/Passenger.
I would recommend Passenger to run your rails app as fast as possible in production mode.
The thin webserver is very fast for few requests, but if there are simultaneously requests, thin gets very slow.
The following document describes about how to deploy rails application in windows. I haven't done this personally but, believe the latest versions should allow that. Please check the below link to see how it can be done
http://weblog.rubyonrails.org/2006/5/11/deploying-rails-on-windows-servers/
Is it possible to hot deploy Ruby just like PHP?
Normally I used FTP to upload the PHP file, then it will be available automatically.
Can Ruby hot deploy its file like this?
Your comment welcome.
Are you talking about a ruby on rails application ?
If so, when deploying a rails application in production mode, the all application gets loaded in memory. So changing the files won't affect the running application.
For hot restarting a rails application you will need to use solution such as:
Unicorn
Puma
Passenger
For a first time, Puma is the easiest way.
However if you are looking for a zero-downtime, either Unicorn or Passenger enterprise are what you are looking for.
EDIT
Unicorn
Free
Complex configuration
zero-downtime when hot restarting. when hot-restarting unicorn, it keeps the old threads working until the new ones are fully functionnal. So if the new ones fail to start, nothing happens. The old ones just keep going.
Puma
Free
Simple configuration
hot restart but no zero-downtime. When hot-restarting puma, it shuts down the old threads and starts the new ones. Puma keeps the sockets open, so the client are not disconnected, but are waiting to get a response while the new threads restart. However if the new threads fail to start, Puma can't restart the old ones. So connections are lost and the server is down.
Passenger
Free edition
Free
The configuration is easier than unicorn
hot-restart, but no zero-downtime. Like Puma.
Enterprise edition
$29/mo
The configuration is easier than unicorn
zero-downtime when hot restarting. Like Unicorn.
Last night I made a revision to [app-root]/config/initializers/refinery/core.rb and the touched [app-name]/tmp/restart.txt. Then I tried to reload the app to find it totally hanging. The other two RoR apps I'm running on the same server were also hanging. Per curl -v there was no response at all from the server.
Everything was working fine before I touched the restart.txt file. The following morning, seven or eight hours later, the sites are working again and my minor edit (the site name) is showing up.
Rails 3.2.16 on a hostmonster linux server.
The instance of Passenger is not running under my user so I wonder if my hang horned any other user's RoR sites?
I can't restart apache (of course) since this is a shared server. Any suggestions for how to deal with this if it happens again? I have no budget for Heroku or a VPS.
UPDATE: Did the same steps again this morning, revised the core.rb and asked for a restart by touching restart.txt and it restarted in less than a minute. The question remains valid I think - what can a person do to address a hanging Passenger or prevent it from happening?
I currently have a rails app deployed on a virtual private server.
I use Capistrano, Nginx and passenger to run my rails app on the server.
For some reason I can never get the updated code to display on the site after i have done a cap deploy:update.
The deploy happens fine and the code is even seen on the live server via Vim but if I navigate to the live site it won't display.
My current workaround is rebooting the server, starting nginx and passenger after the server boots back up.
my concern is if someone is logged on to the site when i deploy and restart, it will knock them off the site.
Does anyone have any ideas
If you run touch tmp/restart.txt from your rails root directory, passenger will restart the app. You shouldn't have to restart nginx. After the timestamp of the restart.txt file changes, Passenger will restart for the next request. If your app takes a while to boot, you may want to force this by making a request immediately after touching the file.
You don't need to worry about kicking someone off the site, it won't restart the server if there is a request in process.
If you are still facing the problem you can use Monit gem, in capstraino it works really well.