title: Performance troubles with SignalR in an Azure Cloud Service
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>For sending the messages the function I use after an Event is stored in the database looks like this:</p>
  
  <pre><code>    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&lt;Devices&gt; 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&lt;Pin&gt; list = new List&lt;Pin&gt;();
              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);
          }
      }
  </code></pre>
  
  <p>In the Javascript client, I receive the messages like this:</p>
  
  <pre><code>connection = $.connection('/Index');
  connection.received(function (data) {
      if (isSismosShown) {
              setPoints(data);
      }
  });
  
  connection.start().done({transport: 'longPolling'}, function () {
      console.log('connection ready');
  });
  </code></pre>
  
  <p>I don't know if I can try the <a href="https://github.com/SignalR/SignalR/wiki/Performance" rel="nofollow">Performance tuning</a> 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?</p>