locked
Self-hosted SignalR and WebAPI - Unexplained CPU usage RRS feed

  • Question

  • User1325410084 posted

    I have a Windows service that is self hosting SignalR and WebAPI using OWIN.  This is a very simple example, runs fine, serves requests, great.

    I noticed though that for some reason, the service will suddenly go from 1-2% CPU usage to 12-13%.  For no apparent reason.  Even when there are no requests against it, suddenly it will just jump up and stay there for a while.  Then just as inexplicably drop back down eventually.  It will go back and forth if I watch it long enough.

    Making calls against it doesn't force the CPU usage up, it seems unaffected by that whether high or low, and it continues to operate just fine throughout this.

    SignalR would be my first guess as the most likely to have something going in the background.  Does anyone have an idea what might be causing this?  10% of the CPU is a pretty good sized chunk for something to take.

    Tuesday, May 30, 2017 3:31 PM

All replies

  • User1967761114 posted

    Hi Underground,

    You couldn’t worried about it.

    When the service is running, SignalR need to do more operations, such as listen on the endpoint, accept the clients connection, receive from clients, send to clients, check whether the connection connected and so on ,and also with the increase of the client, the CPU usage will also increase.

    In your case, it only takes under 15% CPU usage, and it doesn’t always consume more CPU, that’s a normal situation.

    If you have any other questions, please feel free to contact me any time.

    Best Regards

    Even

    Wednesday, May 31, 2017 6:43 AM
  • User1325410084 posted

    Of course, but it's doing that all just fine at 2% usage.  And there are 0 clients when this occurs, so it's definitely not load related.

    If it was momentary I might understand, but it will hit 12-13% usage and stay there for a while.  That's a big jump for no apparent reason.

    Wednesday, May 31, 2017 1:15 PM
  • User1967761114 posted

    Hi Underground,

    Even if there is no client, SignalR still needs to work,it needs to listen on the endpoint to accept client connection at all time, that will takes some not fixed CPU usage.

    For more details about how SignalR works,you could refer to the following link:

    https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/introduction-to-signalr#connections-and-hubs

    If you have any other questions, please feel free to contact me any time.

    Best Regards

    Even

    Friday, June 2, 2017 9:51 AM