Results 1 to 7 of 7

Thread: asynchronous requests a lot faster then synchronous requests!

  1. #1
    smies is offline Senior Member
    Join Date
    Oct 2005
    Location
    Urmond, Netherlands
    Posts
    51
    Rep Power
    9

    Default asynchronous requests a lot faster then synchronous requests!

    I just finished with my adapted version of the ZmCsfeAsynchCommand and after running a couple of tests I came to the conclussion that asynch communication is a lot faster then the synch communication.

    Here are the test results.

    synch roundtrip: 1400 - 1600 ms
    asynch roundtrip: 203 - 1000 ms

    So asynch can be about 7 times faster then synch. It fluxtuates for some reason.

    My tests aren't designed for benchmarking, but besides that, it looks a lot faster. In near future I will do some serious benchmarking because I find this really important to now before I create a real application with ajax and zimbraTK.

    Here you see the debug messages returned from the roundtrip. I used the same soap command and the same data with both versions.

    Code:
     
    Code:
     REQUEST
    
     ------------------------------------------------------------------------
    
     <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
    <FindPersonById xmlns:n1="urn:ActionWebService">
    <id>
    1
    </id>
    </FindPersonById>
    </soap:Body>
    </soap:Envelope>
    
    ------------------------------------------------------------------------
    
     REQ. HEADER: Content-Type - text/xml; charset=UTF-8
    
     REQ. HEADER: SOAPReturnFormat - JSON
    
     REQ. HEADER: SOAPAction - /client/api/FindPersonById
    
     ROUND TRIP TIME: 1437
    
    
    
     RESPONSE
    
    ------------------------------------------------------------------------
    
     Body: {
      birthdate: "1982-04-22",
      email: "info@smies.com",
      firstname: "Maurice",
      group_id: 5,
      id: 1,
      lastname: "Zeijen"
     }
    
    ------------------------------------------------------------------------
    
     ASYNCHRONOUS REQUEST
    
    ------------------------------------------------------------------------
    
     <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
    <FindPersonById xmlns:n1="urn:ActionWebService">
    <id>
    1
    </id>
    </FindPersonById>
    </soap:Body>
    </soap:Envelope>
    
    ------------------------------------------------------------------------
    
     Found free Rpc Context in cache
    
     Have callback
    
     REQ. HEADER: Content-Type - text/xml; charset=UTF-8
    
     REQ. HEADER: SOAPReturnFormat - JSON
    
     REQ. HEADER: SOAPAction - /client/api/FindPersonById
    
     ReadyState changed
    
     ready state = 1
    
     ReadyState changed
    
     ready state = 2
    
     ReadyState changed
    
     ready state = 3
    
     ReadyState changed
    
     ready state = 4
    
     status = 200
    
    
     ASYNCHRONOUS REQUEST RETURNED
    
     ASYNCHRONOUS ROUND TRIP TIME: 203
    
     RESPONSE
    
    ------------------------------------------------------------------------
    
     Body: {
      birthdate: "1982-04-22",
      email: "info@smies.com",
      firstname: "Maurice",
      group_id: 5,
      id: 1,
      lastname: "Zeijen"
     }
    
    ------------------------------------------------------------------------

  2. #2
    KevinH's Avatar
    KevinH is offline Expert Member
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,789
    Rep Power
    18

    Default

    Yes we've discovered this too. In fact you'll see more use of async in the next release. We've converted most of our code to use async calls to the server.

  3. #3
    pshah is offline Zimbra Employee
    Join Date
    Sep 2005
    Location
    Sunnyvale, CA
    Posts
    269
    Rep Power
    9

    Default

    Just curious, are these results based on FF or IE?

  4. #4
    rdargahi is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    49
    Rep Power
    9

    Default

    Great post smies We have actually deprecated ZmCsfeAsynchCommand and modified the ZmCsfeCommand.prototype.invoke method to also support asynchronous calls (basically there is a callback parameter that if populated will result in the call being asynchronous). Among other things, we have also added the ability to cancel outstanding requests so that it is possible to allow the user to cancel operations if so desired.

    As Kevin mentioned, we have made a first pass at moving all of our network calls to using the asynchronous model (there are a few we have not gotten to, and couple we cannot convert because of some interesting interactions with the browser). We have just about completed the work and will probably do another pass at flattening the codes callback structure in the near future.

    We first used the synchronous model, because a couple of years ago when we were new to AJAX and trying to code the client, we first discovered the synchronous model and it was most expedient to just use it (since we were dealing with lots of other variables at the time). We have been badly wanting to convert for the longest time, but because of product requirements and release schedules, we have just not been able to get to it (and it is one of those things that the longer you wait the more painful it becomes to convert! )

    My advice to you is to use the asynchronous model unless it makes no sense for your particular application. However, be aware that it can make your code more complex. You will by nature have to deal with callbacks which can be quite inconvenient and disruptive to the call flow since you basically lose the call stack and may have to cart state around - again this can be minimized if you start out with the async model in mind. For example, consider using a notification mechanism (such as the one provided in the AjaxTk) to indicate when operations are completed. For example, if you are using MVC, then a model would notify all interested listeners, such as controllers, that a modification has occurred to its state.

    If you are careful, it should be possible to keep your callback depth to a couple levels in most cases. Also remember that if your app permits, it is possible to have multiple outstanding requests which may complete out of order, so your code should be robust enough to handle such a scenario. Also, you need to be aware of when to block the UI to prevent user interaction and when to allow the user to continue using the UI despite the fact that multiple operations may be executing in the background.

    I am sure there are other issues, they just don't come to mind right now But good luck with your application!

  5. #5
    smies is offline Senior Member
    Join Date
    Oct 2005
    Location
    Urmond, Netherlands
    Posts
    51
    Rep Power
    9

    Default

    Thanks for all the tips, but they strange to me. I was already planning to use asynch as often as possible. The main reason is that sync communication can let the browser stall when there is something wrong on the server or a request/response just takes very long. Now I have some more reasons to use async communication .

    I am also happy to hear that Zimbra is being converted to async communication. It's just better in a lot of cases.

  6. #6
    czaveri's Avatar
    czaveri is offline Former Zimbran
    Join Date
    Feb 2006
    Location
    Pune, India
    Posts
    294
    Rep Power
    9

    Default Sending Email

    Would it not be possible to use asynchronous requests while sending email? Some users on my server were asking me about this. They were comparing Zimbra with Outlook wherein they can still do other things while the email is being sent.
    Regards,

    Chintan Zaveri
    (Yet another ZIMBRAN!)

    "Dhundhne par Bhagwan bhi ..."

  7. #7
    Ericx is offline Loyal Member
    Join Date
    Jul 2006
    Location
    Virginia Beach, VA
    Posts
    97
    Rep Power
    8

    Default Zimbra Callbacks

    Can some one explain how to best use callbacks. I'm trying to do something I think is very simple. I have a zimlet, when I drag and drop an email an object is created. I can extract values like to, from, email id. But the body is in plain text. I want the fromat to be in html.

    I'm trying to think in classes, but the concept of callbacks is preventing me from loading the objects in a manner that I'm accustomed to. I feel like everything is stored in parameters that I can't see or find. And callbacks are calling callback handlers all over the place. The argument types required by the functions are also very difficult to hunt down. I've started to make some headway by breaking apart the ZM_mail_all.js (not sure if that's the exact name but close), but that is not easy to follow either. I just feel like I'm missing some piece of information that will tie it all together, or there is some IDE or plugin that I could be using that will expose my options?
    EricX

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •