aspose file tools*
The moose likes Performance and the fly likes Good solution for page getting often new data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Good solution for page getting often new data" Watch "Good solution for page getting often new data" New topic
Author

Good solution for page getting often new data

Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
Hi

I've a question regarding architecture selection for my project. I need to create something like bwin.com has in live betting. Customers have a page with current options that are changed very fast, admins have a page to change the options. The question is how to implement this to achieve best performance. That's my idea:

Admin has a JSP page with AJAX stuff to add/remove/update things visible on customers side. When he changes anything, it's saved using EJB in db, but also in XML file.

Customers site reads data (every 5 secs, using ajax as well) just from XML file to make sure db is not overloaded. Only when he wants to make an action on given data, double check (with data from db) is made.

What do you thing about this? Is it the fastest solution? Other ideas? Maybe web service for getting data for client?

I think it's very interesting problem, hopefully ranchers will take part in this discussion

Thanks in advance for all tips,
Michal
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
For active changing of data on a displayed page you are certainly going to be using Javascript. This might be AJAX or it might be JSON - essentially having the web server send Javascript code for data objects. Supposedly JSON is faster on the browser side since XML parsing is not involved.

Rather than writing an XML file and having the client read it I would be inclined to have some sort of in-memory cache. On the other hand, your operating system and server may be caching stuff anyway - time for testing!

Bill
Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
Ok, you've said faster on client side, but I believe client perf. is not significant there. More important is server stress. I already have made an approach to JSON but I couldn't get it work. Does anybody knows if and if yes how much faster or less resource consuming JSON is (comparing to XML format)?

It would save me a lot of time, thanks.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
Does anybody knows if and if yes how much faster or less resource consuming JSON is (comparing to XML format)?


That depends on the details of how you are generating the XML text or JSON text. If your XML generation goes through the laborious task of creating an in-memory DOM, populating it with data and transforming it to a stream it will be slow.

On the other hand, if you devise some sort of template driven engine that plugs the current data into existing Strings, XML and JSON will be comparable in speed.

Here is an example of a template for an XML SOAP request as a collection Strings:


The routine that outputs the XML stream simply iterates through this array, watching for the "@" symbol which shows where to substitute the value (which it has in a Map.) There are faster ways to build templates but this has the advantage of being clear.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Good solution for page getting often new data