Database storage or flat file?
Posted: Fri Oct 31, 2008 5:21 am
Okay guys, question...
My website is owning the vps server it's on. I never expected the site to get this big (around 40k on alexa) and it receives millions of views a month... anyway I'm trying to optimize the code and everything to handle all of this.
It basically is a picture/video gallery website with a forum. It allows users to register, comment on pictures, vote on pictures, and save favorites. (voting on pictures does not require user registration)
Anyway, voting on pictures requires storing each ip address that votes for each picture so the same ip cannot vote twice. There are a total of approximately 60,000 ratings. Right now it is a mysql database table with each rating value, its corresponding ip address, and its corresponding picture id. (I totally never expected the site to get this large and contain this much data). Now each time a picture page is loaded, the database searches through the table to find if the row with the ip address for the current picture id exists. If it does, don't allow the user to rate the picture again. If it doesn't exist, allow that ip address to vote.
Now here's the problem - should I switch to flat files to store the ip address, by having a file name with the picture id in it (ex: ratingsipID.txt) and then on each line in the file store an ip address. Then when the picture is loaded search through the correct file for the specific ip address to see if they already rated the picture? Or should I just stick to the mysql database? I guess what I'm asking is the limits on using a database vs file in certain cases and what would be more efficient?
Thanks
My website is owning the vps server it's on. I never expected the site to get this big (around 40k on alexa) and it receives millions of views a month... anyway I'm trying to optimize the code and everything to handle all of this.
It basically is a picture/video gallery website with a forum. It allows users to register, comment on pictures, vote on pictures, and save favorites. (voting on pictures does not require user registration)
Anyway, voting on pictures requires storing each ip address that votes for each picture so the same ip cannot vote twice. There are a total of approximately 60,000 ratings. Right now it is a mysql database table with each rating value, its corresponding ip address, and its corresponding picture id. (I totally never expected the site to get this large and contain this much data). Now each time a picture page is loaded, the database searches through the table to find if the row with the ip address for the current picture id exists. If it does, don't allow the user to rate the picture again. If it doesn't exist, allow that ip address to vote.
Now here's the problem - should I switch to flat files to store the ip address, by having a file name with the picture id in it (ex: ratingsipID.txt) and then on each line in the file store an ip address. Then when the picture is loaded search through the correct file for the specific ip address to see if they already rated the picture? Or should I just stick to the mysql database? I guess what I'm asking is the limits on using a database vs file in certain cases and what would be more efficient?
Thanks