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
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!
Joined: Mar 14, 2006
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.
Author and all-around good cowpoke
Joined: Mar 22, 2000
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.