I am developing a website that implements a feature for posts like Stackoverflow’s +1 for question or facebook’s like button. I’d like to know which strategy can offer the most efficient solution to do this? Should I use database or file system (or any other strategy)? Onother use of this strategy can be the total number of visitors for my website. Should I really open a connection to my database and update one field for every page load or is there another solution that I’m not aware of? Thank you.
I am developing a website that implements a feature for posts like Stackoverflow’s +1
Share
Once you consider the cost of opening a file for read/write, reading/writing to the file, then closing the file compared to opening a db connection, reading/writing to the db, then closing the db connection, you’ll probably find that there isn’t a huge difference in either method.
The db is the more efficient option when using persistent db connections (always a good idea) since that means that you don’t have to open and close the db connection. For reporting purposes, it would be mush easier and faster to show the +1’s, etc if they are stored in a db, also.
Unless your site is going to have a crazy number of people visiting and clicking the’+1′ button, it honestly won’t matter much in terms of speed. So, really it depends on your needs and which method will solve your specific issues