This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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
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.
An IDE is no substitute for an Intelligent Developer.