Search Unity

"use websockets" functionally broken?

Discussion in 'Multiplayer' started by darthbator, Sep 7, 2016.

  1. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    Is the websockets implementation in the HLAPI just functionally broken?

    Here's my server running an instance of my game with me and 7 of my friends actively playing for about 10 minutes over standard UDP



    Here's the very same server with 0 clients connected to a build that simply has use websockets checked.



    That seems just plain crazy! 99.7% CPU use when there's nothing happening? I'm assuming whatever is setup to listen on that TCP socket is a blocking process? Just for kicks I resized my instance to on with first 2 and then 4 VCPUs and it didn't seem to make a difference. Utilization just kicks all the way up and after 2 clients have connected lag becomes worse and worse until it's completely unusable. Has anyone gotten the NetworkManager implementation of websockets to work? I can't seem to be able to throw enough players at the standard UDP implementation but websockets seem to bring the server to it's knees without even having to do anything!
     
    Last edited: Sep 7, 2016
  2. y_atanasoff

    y_atanasoff

    Joined:
    Jan 17, 2014
    Posts:
    4
    I'm having the same issue with Unity 5.4. You can even see it in the Editor performance.
     
  3. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    I came across this the other night while looking for a fix for this issue

    http://forum.unity3d.com/threads/unet-server-using-web-sockets-has-performance-issue.372676/

    The response from Unity QA is absolutely comical

    However down at the bottom of the post you'll see this!

    I have to admit I don't have the slightest idea what BES is but it appears someone has been able to get something functional out of it?
     
  4. gintautass

    gintautass

    QA Minion Unity Technologies

    Joined:
    Oct 27, 2015
    Posts:
    46
    Ohh I was the one who handled that as well! Could have done a better job indeed!

    Either way, could one of you file a bug report with a project that reproduces this?(send me case id as well)
    I did a quick test with my pet project and it is nowhere near 100% CPU usage.
     
    Last edited: Sep 9, 2016
  5. y_atanasoff

    y_atanasoff

    Joined:
    Jan 17, 2014
    Posts:
    4
    Here you go, sir:
    The best way to observe it is to set the Affinity of the process to a single CPU.
    I managed to reproduce it with 5.3.5f, 5.3.6 and 5.4.
    The same problem occurs when using the LLAPI as well.
    It's especially visible on Linux machines, where you would often use a headless instance as a server.
     
  6. gintautass

    gintautass

    QA Minion Unity Technologies

    Joined:
    Oct 27, 2015
    Posts:
    46
    The case has been forwarded to developers. :)
    Issuetracker link. The link should start working within an hour or so, as the page has not been generated yet.
     
  7. temo_koki

    temo_koki

    Joined:
    Jul 14, 2009
    Posts:
    308
    Software that controls per-process CPU usage.
    here it is: http://mion.faireal.net/BES/
     
  8. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Could you please change ThreadAwakeTimeout to 5 and check results?
     
  9. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    I don't seem to be able to set

    UnityEngine.Networking.GlobalConfig.ThreadAwakeTimeout

    Is this the value that you're talking about? Should I be setting this in the editor somewhere and not by script?
     
  10. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    check please, advanced configuration check box and you will be able to change GlobalConfig parameters
     
  11. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    So this value is to be set on the NetworkManager component?
     
  12. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Yes you can. or if you prefer to do this inside script you can call GlbalConfig cnf = NetworkManager.GlobalConf; cnf.ThreadAwakeTimeout = 5; //BEFORE call StartServer or SrartClient;
     
  13. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    I get the same behavior when deploying a build after setting that parameter. CPU use on my linux instance immediately pegs at 99% performance on clients is completely unplayable.
     
  14. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    report a bug please with steps how it can be reproduced.
     
  15. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    The above bolded link is to a bug that covers the same issue I am having.
     
  16. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    I saw this bug and moreover we tried to reproduce them, no success so far, i mean it is not 100% reproducible (afaik from talking with qa), but it is for editor and manager while @y_atanasoff reported that he obtained this problem with LLAPI only (and probably it is origin of this bug, so I want to hear how i can reproduce this).
     
  17. temo_koki

    temo_koki

    Joined:
    Jul 14, 2009
    Posts:
    308
    Nothing special, you just need to enable "Use WebSockets" checkbox in network manager component.
    For me this bug even exists in editor, In clean, just created project. Without "Use WebSockets" checked editor consumes 35% of CPU and with it - 60%. Changing ThreadAwakeTimeout doesn't change anything. Here is the screen record:



    Built exe file without websockets consumes 6% of CPU and with it - 30%
     
    Last edited: Oct 13, 2016
  18. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    I think it's extremely noticeable if you deploy the server build onto a single core EC2 instance (I have only tried linux but I assume windows would present the same issue). A standard UDP socket build consumes 6-10% CPU with 4-6 players. A websockets build consumes 99% CPU without any connected clients.