0

I'm working on a web service that is stored in an Azure Cloud Service on a Windows Server 2012 virtual machine that uses SignalR to send messages to the clients connected to a Azure Website. To test the performance of SignalR sending the messages we designed a special endpoint that would simulate different messages being sent to the clients.

When the endpoint is accesed, a list containing 400 predefined Events objects is iterated. Each object is then stored in the database and after an object is stored a message is sent to the clients, in total 400 messages should be sent. The first message arrives quite fast but subsequent messages are delivered more slowly, taking up to 20 minutes for all the clients connected (we're testing with only 5 clients with the website opened on Firefox at the moment, which is quite a small number for it to take so long) to receive all the messages.

For sending the messages the function I use after an Event is stored in the database looks like this:

    public void SendEvent(string deviceId, Events event)
    {
        Connection conn = new Connection(url + "/Index");
        try
        {
            conn.Start().Wait();
            DevicesDao devicesDao = new DevicesDao();
            ClustersDao clustersDao = new ClustersDao();
            RegionsDao regionesDao = new RegionsDao();
            Devices device= devicesDao.GetDevice(deviceId);
            Clusters cluster = clustersDao.GetCluster(device.ClustersClusterId);
            List<Devices> devices = cluster.Devices.ToList();
            Regions region = regionsDao.GetRegionsById(cluster.RegionsRegionId);
            Pin pin = new Pin(device.Latitude, device.Longitude, event.CurrentDate, event.IMax, event.AMax, device.UniqueId, device.Alias, device, cluster, region);
            List<Pin> list = new List<Pin>();
            list .Add(pin);
            var json = new JavaScriptSerializer().Serialize(list);
            conn.Send(json).Wait();
        }
        catch (Exception ex)
        {
            Debug.WriteLine("Error " + ex.Message + " \n Inner Exception " + ex.InnerException + " \n Stack Trace " + ex.StackTrace);
        }
    }

In the Javascript client, I receive the messages like this:

connection = $.connection('/Index');
connection.received(function (data) {
    if (isSismosShown) {
            setPoints(data);
    }
});

connection.start().done({transport: 'longPolling'}, function () {
    console.log('connection ready');
});

I don't know if I can try the Performance tuning from SignalR page due to the web service being stored in Azure, I don't have that much experience using Azure. What are my options to improve the speed on which the messages are sent from the web service in Azure?

Uriel Arvizu
  • 1,876
  • 6
  • 37
  • 97
  • It's too hard to tell without *ALOT* more details where to being to start looking. I'd install the ASP.NET and signalr performance counters and taking a look there. - How many messages per second are you sending? - What are your clients? .NET or browsers? Did you bump the max connection limit? - How many connections do you have? - Are you just having a problem with latency? - What does the server and client code look like. – davidfowl Mar 26 '13 at 23:31
  • I edited my question. To iterate the list with Event objects I use a for, in each cycle I add an Event object to the database and then send a message to the clients connected to the website. Even if I remove the call to Wait() when starting and sending with SignalR, the response time doesn't change. – Uriel Arvizu Mar 27 '13 at 00:15
  • This really isn't a good question for stackoverflow as it requires lots of back and forth to understand your project structure and why this might even be happening. It's likely something environmental and not signalr. Come to the https://jabbr.net/#/rooms/signalr room and we can talk about it. – davidfowl Mar 27 '13 at 06:36
  • One possibility is that you're being affected by Azure's built-in limitation of only two HTTP connections at a time. You could try adding the following line of code in your OnStart() method in WebRole.cs: ServicePointManager.DefaultConnectionLimit = 12; – Zeb Kimmel Mar 29 '13 at 12:28
  • It seems the problem was in a query made by one of my DAOs, I removed such query and made a work around it, now the notifications are being sent in time. In the end it was a problem with EF. – Uriel Arvizu Apr 02 '13 at 22:51

0 Answers0