Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

should I load product info into memory or keep in db?

 
Henry Sun
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am going to develop a b2c shopping website with jboss-tomcat bundle. Now I must make a decision on whether I should load product info into memory or just keep it in table. If load into memory, the performance of customer browsing and searching will be good; but I am afraid of the memory capacity and issues like, when I want to update the product price or description, I need to refresh the memory objects. This shop has about 500 products and we will develop this application into Dell server with 1GB memory. Can anyone who has ever developed such e-commerce website give me some suggestions?
Thanks.
Henry
 
Paul Lester
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Henry: Considering that you have only 500 items, any database, including M$ Access should be able to give you nearly instantaneous access to any record; therefore, you won't notice much difference between hitting the database and caching the records.
Caching should be done only after careful consideration. One of the biggest problems, as you mentioned, is how to refresh the objects as well as how often to refresh them. Then there are the memory constraints, etc. I would steer away from caching your entire product line. If the number of products continue to grow then you are going to start having issues with memory.
Keeping the information in the database allows you to update or remove items easily and without an application restart. Further, if you determine that it is too slow you can add indexes, get faster hardware, etc.
Lastly, deciding whether or not to cache, in the design stages, is a bit premature. You should come to that decision AFTER you've done some profiliing of the application and found that the DB portion is indeed the bottleneck of the application.
Regards,
Paul
 
Henry Sun
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Paul. I prefer keeping the pruducts in database instead of memory. I'll do some profiling, just like you said, then make the final decision.
Henry
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18161
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the best bits of advice I can give is not to worry about efficiency more than you need to. It's not like there's only one "right" way to do things.
I've found that it's a good idea to keep the design "loose" so that mods can be made as needed rather than to try and anticipate problems that may never occur. Especially if solving these non-problems is going to lock you out of being able to address the problems that do occur.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic