none
[E2010] [EWSMA] [C#] [Windows]: Curious GetUserAvailability performance fluctuations RRS feed

  • Question

  • We're using the EWS Managed Api v2.2 to connect to Exchange 2007 - 2013 to collect user availability and when testing the performance at our test environment (Exchange 2010 with latest service pack) and also at a customer's live environment (same Exchange version), we're experiencing weird performance fluctuations. Simple calls to collect a week of availability for two users 'normally' take only around 140 ms, but now and then the exact same calls take over 4 seconds and it happens very regularly, there's some sort of pattern even...

    We've already disabled throttling for the user in both environments. We've tried some settings on the ExchangeService (code) side, but to no avail. The code we're using is:

            private static int TimeInMillisBetweenTests = 10000;
            private static int TotalNumberOfTests = 50;
            private static DateTime PeriodStart = DateTime.Today;
            private static DateTime PeriodEnd = DateTime.Today.AddDays(7);
    
            static void Main(string[] args)
            {
                ExchangeService exchangeService = new Microsoft.Exchange.WebServices.Data.ExchangeService(Microsoft.Exchange.WebServices.Data.ExchangeVersion.Exchange2010);
    
                exchangeService.Credentials = new WebCredentials(User, Password, Domain);
                exchangeService.Url = new Uri(ServiceUrl);
    
                IList<AttendeeInfo> attendees = new List<AttendeeInfo>()
                {
                    new AttendeeInfo(EmailAddress1),
                    new AttendeeInfo(EmailAddress2),
                };
    
                for (int i = 0; i < TotalNumberOfTests; i++)
                {
                    GetUserAvailability(exchangeService, attendees, PeriodStart, PeriodEnd);
    
                    Thread.Sleep(TimeInMillisBetweenTests);
                }
            }
    
            private static void GetUserAvailability(ExchangeService exchangeService, IList<AttendeeInfo> attendees, DateTime startDate, DateTime endDate)
            {
                Stopwatch sw = Stopwatch.StartNew();
                GetUserAvailabilityResults results = exchangeService.GetUserAvailability(attendees, new TimeWindow(startDate, endDate),
                    AvailabilityData.FreeBusy, new AvailabilityOptions() { RequestedFreeBusyView = FreeBusyViewType.FreeBusy });
    
                sw.Stop();
    
                Console.WriteLine("Time in millis: " + sw.ElapsedMilliseconds);
            }

    The output we're getting is:

    What could be the reason for this strange behavior? Is there any setting on the Exchange side or in the code to fix this? We've also tried version 1.2 of the Managed Api, same results. The strange thing is that the results are very similar in the live environment at the customer, also spikes of over 4 seconds.

    Thanks in advance!

    Edit: the server itself is only used for testing Exchange and no mailboxes or users are connected. The live environment at our customer is in use at the time of testing.

    • Edited by jcc_colin Tuesday, October 7, 2014 8:14 AM
    Tuesday, October 7, 2014 8:10 AM

All replies

  • Apparently there's no obvious answer to this issue, unfortunately. We've looked into it a little more and found out the following:

    - Executing the exact same test code on the Outlook 365 web service does not result in the 4 seconds spikes, it's a very consistent 100-200 ms.

    - Using fake email addresses that are not in the Exchange database results in the same 4 seconds spikes, so the performance issues apparently don't have anything to do with actually collecting availability.

    - We've actually replaced the GetUserAvailability method with another random method (GetRoomLists) and it results in the same 4 seconds spikes, so it's actually a generic EWS thing apparently, not something to do with GetUserAvailability at all.

    - We have enabled tracing on the client side, but this only shows the requests and responses that are sent and received and they show no errors. The Trace time of request and response are actually over 4 seconds apart, so assuming those are the times of actually sending and receiving requests, the delay must be on the Exchange server side.

    What would be a next step we could try? I was thinking about checking IIS logs, but according to (http://msdn.microsoft.com/en-us/library/office/dn720300(v=exchg.150).aspx), this is only helpful if you're getting HTTP errors, which is not the case. Something else I've found is tracing on the Exchange server (http://blogs.msdn.com/b/vikas/archive/2011/06/23/draft-how-to-take-ews-owa-etl-trace-to-troubleshoot-exchange-web-services-issues-exchange-2007-amp-2010.aspx). Would this be the only way to tackle the issue? Because in that case, we need a Microsoft engineer to find out the results.

    Is there any other way to find out where the 4 seconds delay comes from? It's strange that we and our customer are both experiencing this in Exchange 2010, but I can't find any related issues and Exchange 2010 has been out for quite a while now.

    Monday, November 3, 2014 10:55 AM