Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
AJAX and XML to increase efficiency
Old 08-07-2008, 12:44 PM AJAX and XML to increase efficiency
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
I have a web-based chat script that is similar to IRC. I am trying to increase its efficiency. Right now it uses AJAX to query a database every 250ms to see if there has been any chatting and if there has been it updates that clients window. The problem is that the more clients the more often the server is hit. The server is also queried every time a user speaks. This ends up being resource heavy.

My plan was to use XML to increase efficiency. Tell me what you think. Instead of using a database when a user speaks AJAX just updates the XML document and changes the timestamp to the time of update. Then every 250ms the users client checks the XML document and if the timestamp on the document doesnt match the timestamp they have the user reloads the XML. I am thinking that this should put more of the strain on the user and take it off the server allowing the server to handle a higher number of users.

Anyways tell me if you think that makes sense or if you can think of an even more efficient. Thanks!
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE

Last edited by Truly; 08-07-2008 at 03:52 PM..
Truly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-07-2008, 01:16 PM Re: AJAX and XML to increase efficiency
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
Try using a cache around your data layer.
Updates can hit the cache, a background thread can keep it in sync with the database, and queries will bounce off the cache.

Updating a file will get expensive as the file grows
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 08-07-2008, 06:35 PM Re: AJAX and XML to increase efficiency
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
I have never done any work with caches before. Is it very difficult? Can you maybe point me in the right direction as far as good tutorials on the subject.
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Old 08-08-2008, 09:24 PM Re: AJAX and XML to increase efficiency
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
My favorites are:
Ehcache and OScache
Ehcache is used by hibernate by default.

but, I do most of my dev with java. There are caching solutions for most languages if you use something else.

For example, with hibernate. You ask hibernate for an object, it first checks the cache to see if it has it. If not, it queries the database and stores the object in the cache before returning to you. You can make lots of changes to the object (you just have a ref to the object in the cache). Other requests can ask for the object and get it out of the cache. Hibernate has a background process that syncs the objects in the cache with the database.

So, you could potentially have a 100 changes to the object and only one SQL UPDATE get executed (with the latest version). It's one of the reasons why working with a library like hibernate can have such high performance.

Of course, there options to explicitly flush the cache (sync cache with the database) when working in a transaction dependent environment.
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 08-08-2008, 10:28 PM Re: AJAX and XML to increase efficiency
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
Hmmm I guess I am not fully grasping the concept of a cache. If I am caching data in the user's browser how does that help me with my problem?

Because wont the browser still need to request updates just as often. I guess I can just limit the amount of information that is transfered at a time. Is that what you are thinking?
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 01:21 PM Re: AJAX and XML to increase efficiency
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
Sorry, I wan not referring to caching on the browser. Browser caching would break your application

I'm talking about caching data between the database and your application code. This keeps the application from hammering the database so hard.
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 05:16 PM Re: AJAX and XML to increase efficiency
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
Nice that makes alot more sense, I will give that a try and see how it works out.
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to AJAX and XML to increase efficiency
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31087 seconds with 12 queries