Articles Service - Marketing And Unique Articles - Online Directory - Quick Promotion - Free Contents


   

5 Ruby on Rails Database Optimizations You Can Do Now



[Valid RSS feed]  Category Rss Feed - http://www.look4articles.com/rss.php?rss=79
By : Daniel Quitzon    99 or more times read
Submitted 2011-02-26 23:53:56
Ruby on Rails relies on it's database for just about everything it does. Typically the database performs well but it is also one of the first things that slows down a site, no matter what type of Rails hosting it is on. There are a few techniques you can use to optimize your database.

1. Move your database to a separate server

Moving your database to a separate server will let you add resources for the database itself without having to fight Rails for those resources. This can be done with most Rails hosting providers and is a good first step if you are trying to scale up your site.

2. Turn off unnecessary database features

Most databases are configured with a bunch of extra features by default. Turning off these features can save you some resources on the server. Some common things to turn off are: remote connections, unused database engines (MyISAM vs InnoDB), or optional authentication settings like LDAP.

3. Setup a database cluster

At a certain point you will need to setup a database cluster. A database cluster is just a group of servers that all have a copy of your database running. Your website will then connect to a random server in the cluster to get it's data. So if you have a database cluster with 3 servers, each server will handle 1/3 of the database traffic. The most common database cluster setup is master/slave, which means that there is one of your servers setup as the master and the rest are considered slaves. The master server is the one who is holds the original data and the slaves have copies of that data that they refresh every few minutes.

4. Separate your data to multiple databases

Depending on your site and the date it stores, it might make sense to separate your data into a second (or third) database. This can be the same database type as your main application, like MySQL, or something different like MongoDB. Common things to separate are logging or historic data. For example with an e-commerce site it might be useful to have all of your product prices in the database but you can keep your historic prices in a separate database since they aren't used as often. Ruby on Rails has support for connecting to multiple databases so it isn't too difficult to set up.

5. Use a database caching layer

The fastest way to make your database quick is to never connect to it. This is what a database caching layer does. It sits between your Rails application and the database and will cache queries to your database for a short period of time. This means that instead of hitting your database for the same record 100 times, the caching layer will hit your database once and then serve up the cached record the other 99 times. Memcached is used for this most of the time and has great performance, but you need to take extra steps to make sure that it clears it's cache correctly.

These five optimizations should help you get started on speeding up your Rails site. You don't need to do them all at once either, just pick one or two to start with and add the others later on.

Author Resource:

I didn't address this issue but the actual rails web host you are using plays an important role in your database performance. You want a host that is easy to get started with but can also help you scale up your site as you get more and more traffic. I have seen a lot of people recommend hosting Rails on Host Gator , they are inexpensive to get started with and have great support for handling large traffic sites.

Related Articles


HTML Ready Article. Click on the "Copy" button to copy into your clipboard.




Firefox users please select/copy/paste as usual


New Members
select
Sign up
select
Learn more
ASK It!
ASK It!

 
Directory Menu
Home
Login to Directory
Submit Articles
Submission Guidelines
Top Articles
Link Directory
About Us
Articles Directory Advertisement
Articles Directory Advertisement Media Kit
Contact Us
Privacy Policy
RSS Feeds


Categories

Accessories
Advice
Aging
Arts
Arts and Crafts
Automotive
Break-up
Business
Business Management
Cancer Survival
Career
Cars and Trucks
CGI
Cheating
Coding Sites
Computers
Computers and Technology
Cooking
Crafts
Culture
Current Affairs
Databases
Death
Education
Entertainment
Etiquette
Family Concerns
Film
Finances
Food and Drinks
Gardening
Healthy Living
Holidays
Home
Home Management
Internet
Jobs
Leadership
Legal
Medical
Medical Business
Medicines and Remedies
Men Only
Motorcyles
Opinions
Our Pets
Outdoors
Parenting
Pets
Recreation
Relationships
Religion
Self Help
Self Improvement
Society
Sports
Staying Fit
Technology
Travel
Web Design
Weddings
Wellness, Fitness and Di
Women Only
Womens Interest
World Affairs
Writing
 
Actions
Print This Article
Add To Favorites
[Valid RSS feed]

Copyright LOOK 4 ARTICLES FREE DIRECTORY - 2005-2012 - Powered By: HYIP