« Previous Next »

Thread: Chat Ajax Application performance on IIS6 W2003 (CLASSIC ASP)

Last post 06-13-2009 12:16 PM by cesarmello. 0 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (1 items)

Sort Posts:

  • 06-13-2009, 12:16 PM

    Chat Ajax Application performance on IIS6 W2003 (CLASSIC ASP)

    Hi People.

    First of all I would like to excuse form my bad English. I´m a Brasilian (Yeah, we have internet here too. And I´m not writing this as I fight off a giant snake. Never seen one. Althoug I´m married to a typical beautiful brasilian women like those you see in the movies. That part about Brazil IS true.)

    I´ve been mostly reading this forum and got some good ideas, and solved some problems.

    So Iwould like to start this topic to dicuss an application and how to configure the server to better serve it.

    I have an ASP CHAT application. In fact it´s an module in a bigger application.

    Since it´s a free service, sometimes I have many users connected using the service.

    The firt structure i designed was this:

    Client -

    In the javascript I run an XmlHtttpRequest that would every 1 second send to the server the current chat ID and the last message ID.

    Server -

    Would query the Database and see if there was new messages. If so, returned the messages.

    ------

    As you wold expect, soon the system became popular, the SQL Server ate up all the memory and the server would return HTTP 1.1 New Session Failed.

    I solved this by limiting the maximum memory allocated for the Sql server.

    Still sometimes the server would became so slow that it would timeout.

    I solved this by making subdomains for each function of the server and using a different AppPool for each.

    That solved many performance problems, since it isolated the system functions.

    Still the chat sometimes becomes slow.

    I tried to increase the time for each request from 1 second to 2.5 seconds. It did´nt solved the problem (only allowed more concurrent chat sessions) and the response time of the service became poor.

    So, I thought on a solution that many people may Use.

    It goes like this:

    Client:

    Wen a new message is sent to the server, or a new chat session is created, I save the new message ID in an Application("chatid") variable.

    In the javascript I run an XmlHtttpRequest that would every 1 second send to the server the current chat ID and the last message ID it has reveived.

    Server.

    Now, instead of searching the SQL SEVER I have a function that cheks if the  Application("chatid") > Request("messageid")

    So, it checks if the last message the system has reveived is major than the las message the cliente has received.  

    If so, I return "1" to the cliente.

    Cliente

    If the server response is 1 then send a new XmlHtttpRequest requesting the new messages

    Server

    Get the new messages from the SQL SERVER.

    ---------------

    At first glance, seens that the server is making more work, but it isnt true.

    That´s because every second the client checks with the server if there is a new message, and it does so just by comparing with the Application Variable. It doesn´t connect to the Sql server. It doesnt create a new variable.

    Since this action ocurrs every 1 second for each cliente conected and people don´t send a new message every second on a chat session (it´s more like a message ever 10 seconds) you can imagine the number of querys to the Database that I save by doing this.

    There´s a problem thougth.

    Since I´m using the Application() Variable, I have, every hour to run an script that destroys the application object that is not going to be used anymore.

    THE RESULT:

    The resulting impact in the server is this:

    1 - Dramatically decreased the memory used by SQL SERVER. I have free memory all the time now.

    2 - ASP Response Times dramatically increased.

    3 - Number o ASP Requests Queued - Never above 20 since the change.

    OK.

    Now comes my question:

    Problem: This chat sessions are using up my TCP connections.

    But since we now that:
    This Xmlttprequest doesn´t have to keep Open When it return 1 or 0 it´s job is done.
    I don´t use Session() variables since the users are not logged in or anything, and I can save the variables on the HTML or javascript.
    This service is running in it´s own AppPool, so the configuration on this website doesn´t influence on the rest of the website.

    What would be the best configuration for this website to serve up the maximum amount of this simple requests, closing them soon after they completed?

     

Page 1 of 1 (1 items)
Microsoft Communities