Thursday, November 30, 2006

Thai Ordering and Development Mode vs Production Mode for Rails Apps

A while back, I wrote a little rails app for Thai food ordering at my work. My colleagues place orders using the system and then bring money to the nominated orderer of the week. Once all orders are in and paid for (this is also tracked in the app), the orderer rings up our favourite Thai restaurant (Laddas) and places the order.

I have the app running from fairly cheap shared hosting. At peak times during the ordering, I guess that they'd be 15 or so people simultaneously using the app. We've used it many times without problems. Thus, I was quite surprised and displeased (as were my colleagues), when my hosting account was suspended and we couldn't see what had been ordered this morning. A hasty email to my hosting provider revealed that my account had been suspended due to high load and "ruby flooding". They were kind enough to un-suspend my account and we completed the ordering process.

I remembered seeing something about production mode in 'environment.rb'. Some googling confirmed my hunch - in development mode, rails apps are much more resource intensive. Caching is not used, and every single file needs to be reloaded every time it is required. After changing my app to production mode, it seemed to run noticeably faster. Michael and I ran 'top' and it looked like each request used less CPU.

So, should you be in a similar situation, this is how to change your app to production mode on fast-cgi Apache shared hosting:
  1. Confirm that 'database.yml' in your app's 'config' directory has a section for production mode, and that it has up to date database connection details.
  2. Edit 'environment.rb' in your app's 'config' directory.
  3. Add this line:
         ENV['RAILS_ENV'] ||= 'production'
  4. Run 'ps -u [your_user_name]' to find if you have any 'dispatch.fgi' processes running.
  5. If so, kill all of them (they'll restart and use your new config settings).
  6. Browse to your app, it should now run faster.

20 comments:

Santiago Carmo said...

Thanks for help me!

profitable home based business said...

Thanks for posting, definitely going to subscribe! See you on my reader. Please come visit my site work from home business give me any valuable feedbacks.

enterprise contract management said...

Hello, What enticed you to post this article. It was extremely interesting, especially since I was searching for info on this subject last Thursday. Please come visit my site contract administration when you got time.

Anonymous said...

cialis tadalafil information page
caverta
sexual health drug cialis dysfunction information
cheapest tadalafil online
order cialis soft
viagra soft tabs
cheap pharmacy viagra cialis levitra
viagra soft tab
order tadalafil ups online
viagra soft tab
zenegra
number vardenafil prescriptions
tadalafil information

Unknown said...

hello fellas, I just want to emphasize the good work on this blog, has excellent views and a clear vision of what you are looking for.
Buy Viagra

Antiques Guide said...

Hello mate, I want to thank you for this nice blog. Would you mind telling me some secrets for a succesful blog ? Which could attract some visitors than it normally does. Please come visit my site guide to antique give me any valuable feedbacks.

Estate And Planning said...

What a facinating article. I’m looking for a marketing expert to help with a project, could you help? Please come visit my site Trusts & Estate Planning when you got time.

Anonymous said...

vendita farmaci italia
vendita cytotec online
levitra en ligne
kamagra en pharmacie
trandate vendita italia
costo farmacia
vendita farmaci online
cialis super active bestellen ohne rezept
farmacia senza ricetta
costo farmacia
pharmacie achat
sinequan ohne rezept kaufen
acheter paxil france
viagra super active en pharmacie
accutane vendita senza ricetta
levitra vendita on line
viagra en ligne
zyban sr italia
cialis super active rezeptfrei kaufen

Anonymous said...

Precio cialis Espana
lioresal Sin Receta
clomid Online Rezeptfrei
kamagra oral jelly Online Rezeptfrei
Achat inderal en ligne
Comprar strattera Internet
Vendita clomid Senza Ricetta
augmentin Online Rezeptfrei
augmentin Rezeptfrei
Comprar viagra Internet
Acheter cytotec France
zithromax Online Rezeptfrei
minocin Rezeptfrei Kaufen

Unknown said...

I just couldnt leave your website before saying that I really enjoyed the quality information you offer to your visitors... Will be back often to check up on new stuff you post here!
New Jersey Discrimination & Civil Rights Attorneys, New Jersey Divorce & Mediation Services, New Jersey Divorce Attorneys, New Jersey Election Law Attorneys, New Jersey Eminent Domain & Condemnation Attorneys, New Jersey Employment & Labor Law Attorneys, New Jersey Entertainment & Sports Law Attorneys, New Jersey Environmental & Natural Resources Attorneys, New Jersey Estate Planning & Administration Attorneys, New Jersey Expert Testimony Services, New Jersey Family Law Attorneys,

Unknown said...

Tennessee insurance agencies and brokers. Tennessee car insurance, home owner insurance, health insurance, life insurance and more.

Tennessee
Accident & Health Insurance
, Tennessee
Aircraft & Aviation Insurance
, Tennessee
Auto Insurance
, Tennessee
Bail Bonds Referral Services
, Tennessee
Boat & Yacht Insurance
, Tennessee
Business Insurance
, Tennessee
Business Interruption Insurance
, Tennessee
Casualty insurance
, Tennessee
Churches Insurance
, Tennessee
Contents insurance
, Tennessee
Corporate Insurance Adjusters
, Tennessee
Credit Insurance
, Tennessee
Crime insurance
, Tennessee
Dental Insurance

Unknown said...

Your article was quite intriguing and the information quite useful. Will check your site often to see other great posts you make! Regards
Massachusetts mobile home insurance, Michigan mobile home insurance, Minnesota mobile home insurance, Mississippi mobile home insurance, Missouri mobile home insurance, Montana mobile home insurance, Nebraska mobile home insurance, Nevada mobile home insurance, New Hampshire mobile home insurance, New Jersey mobile home insurance, New Mexico mobile home insurance, New York mobile home insurance,

Unknown said...

As a Newbie, I am always searching online for articles that can help me. Thank you
North Carolina mobile home insurance, North Dakota mobile home insurance, Ohio mobile home insurance, Oklahoma mobile home insurance, Oregon mobile home insurance, Pennsylvania mobile home insurance, Rhode Island mobile home insurance, South Carolina mobile home insurance, South Dakota mobile home insurance,

Anonymous said...

If you had some way of rating posts I would for sure give you a high rating my friend!
Florida
Disability Insurance
, Florida
Earthquake insurance
, Florida
Estate Planning Insurance And Legal Services
, Florida
Farm, Crop, & Livestock Insurance
, Florida
Financial Guaranty & Life Insurance
, Florida
Fire Insurance
, Florida
Fleet Insurance
, Florida
Flood Insurance
, Florida
Foreign Insurance
, Florida
Franchising
, Florida
Government Insurance Carriers
, Florida
Group Insurance
, Florida
Health Insurance

Anonymous said...

Your summaries are always top-notch. Thanks for keeping us apprised. I’m reading every word here.
Your summaries are always top-notch. Thanks for keeping us apprised. I’m reading every word here.

Anonymous said...

Your article was quite intriguing and the information quite useful. Will check your site often to see other great posts you make! Regards

Drug
Rehab Center Oregon
, Dallas
Family Dentist
, Las
Vegas Family Dentist
, earring
wholesaler
, wholesalers china, Alcohol And Drug Rehab Connecticut, Pool
Table Moving Philadelphia
, Alcohol
And Drug Rehab Illinois

Anonymous said...

As a Newbie, I am always searching online for articles that can help me. Thank you Alcohol
And Drug Rehab Kansas
, Alcohol
And Drug Rehab Ohio
, General
Dentist Chicago
, Alcohol
And Drug Rehab Michigan
, Alcohol
And Drug Rehab Oregon

buy an essay said...

I like this post veru much!

pay per head service said...

You are a Great while writing in the blogs it is awesome I liked it too much good and informative thanks for the sharing.

Anonymous said...

Some time again, Buy Diablo 3 gold I had written somewhat tracks practical application regarding Spanish foodstuff ordering inside my perform. My personal peers place requests using the technique and after that bring cash to your selected ordererBillig Gw2 Gold of the week.