Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slow / Too many requests

Status
Not open for further replies.

bdichiara

Programmer
Oct 11, 2006
206
US
I'm writing an AJAX/PHP chatting application (similar to liveperson) and I'm using the Script.aculo.us/Prototype Library for AJAX Functions.

When the page loads, I initialize the chat. During the initialization, i startup 2 PeriodicUpdaters.

1. This one updates the "chat window" when new messages arrive, it re-queries the database and displays the newest string of messages.

2. This is a typing message display. When a user is typing, it writes a 1 to the database. The user on the other end can now check to see if that 1 is in the database, and now know if the other user is typing.

So basically, I can have a total of about 4 AJAX requests running at the same time.
1. Chat Window Updater
2. Typing Message Updater
3. Typing Message writer (tells the database when I am typing)
4. Message Sender (sends the typed message to server)

The problem I'm ending up having is typing tends to get "laggy". It's not as smooth as if nothing else is going on. I've tried turning off all but 1 constant Updater, but it still gets "hung" up mid-typing, as well as my messages don't get sent very quickly. Sometimes they don't get sent in the right order, or don't get sent at all.

I am just curious if anyone has worked on this type of application and have found a better way to handle each of these tasks much more efficiently.

_______________
_brian.
 
How often are your updaters updating? Have you tried installing Firebug for Firefox and inspecting the XMLHttp requests to see how often they are being sent? That would give you a good indication of whether it's the AJAX requests that are slowing you down or not.

Other things to look into - do you have any key event handlers anywhere (such as in the input fields)? Are the handlers as efficient as they could be?

Do you have any tight loops going on at all?

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top