views:

22

answers:

2

Hi, I need to build a website where we display data that is refreshed every 5minutes in a text file with a | separator.

I currently use Java to do this.

What I do now: I grab the textfile for every request through the website and process it and then display the data to the end user, this works fine, since Java can go through like 5000 lines of data fast, and when I filter it it is still extremely fast.

However now the management wants the following: They added 3 textfiles with the | separator to it, and now want me to also read those files and match the information on certain fields, and if there is a match also display that information to the end user.

I think soon enough, although Java is fast, I will run into trouble when 10 people want that information and I have to run through 4 total files matching the information.

What can I do to make this process super fast?

My Creative solutions so far:

-Leave it this way, since Java is fast and end users can wait (probably less then 1second)

-Have a background process that dumps new data into a MySQL database every 5minutes, since databases are extremely good at getting the same data from multiple tables.

Thank you!

+2  A: 

Both solutions are good. A few things to keep in mind:

  • If you're going to keep the user waiting for more than 1 second, consider making a landing page and showing a "loading info - please wait" message while your page loads the information (using AJAX, for example).
  • Chances are management will add more files later. Coding a database solution now might save you from hacking it now and having to do it the right way later anyway.
  • Other reasons to use the database are the DBMS extra advantages in caching, locking, joining...
Konerak
I'd get ready to add a database backend to process this data, but not implement it yet. If usage and requirements level off, you've wasted few resources; if volume continues to increase ("The Rich Man's Problem"), you'll already be prerpared for the necessary non-trivial changes.
Philip Kelley
We already see that now, we get more and more orders and more and more people tracking them, right now we have people from America, Europe and Asia tracking it.I'm just a bit worried about getting a lot of hits at once to the same database (since we have no money to expand it's just 1 computer) and i don't quite know how to cache the result for like 5minutes.
Paintrick
+1  A: 

I'm not really a Java guy, but I'm pretty sure you should be able to read these files into cache for 5 minutes... this way the data is combined and stored in memory... In addition to putting it in memory, you could store it in a hash table or some other data structure that makes searching faster (find value versus evaluate each value)...

Zachary