-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request user data taking >10000ms when using websockets #439
Comments
If you have single CPU system, then WebSocket server is eating all your CPU cycles. It´s known problem. |
Heh, I'm running it on a quad core and it is indeed using 100% CPU. How is that possibly a thing? |
So after some research it appears that by default Ratchet falls back to a loop (i.e., while(true)) if libevent is unavailable. Libevent does not yet exist for PHP7.0, thus Ratchet is always going to use 100% CPU until that changes. There is a fork of php-libevent at https://github.com/expressif/pecl-event-libevent but it generates a coredump for me on the pathfinder_websocket cmd.php. I'm not sure of a good solution for this going forward. There's another option that also appears not to work: https://bitbucket.org/osmanov/pecl-event/src/41be9821b69ce996d59b750ecdbd9c07dffe192b/INSTALL.md?fileviewer=file-view-default |
root@ap0:/var/log/pathfinder# sudo -u www-data /usr/bin/php /var/www/pathfinder_websocket/cmd.php Got the same results :< |
Yup. I'm not sure if this is a problem on Ratchet, react/event, pathfinder_websocket or the guys libevent fork either. I'll poke around with strace and see what I can hunt down tomorrow. |
@atkinsj "*update client map *" and "update client user data" are client side timings. Its just the time your web browser takes to update/sync your map with updated data.
The other 2 charts are AJAX timings. They show you how long your server takes to response:
|
@exodus4d Thanks for the explanation on the variables. The latest version with the recommended configuration is pretty much unusable. I'm running this on a 4 core 2.4GHz box with 4GB of ram. The Websocket server is using 100% CPU from the bug we mentioned above (lack of libevent support in php7.0) and redis-server is using 33-35%. The php-fpm process is also using a lot of CPU which makes me think that route calculations are not being cached but I haven't had a chance to confirm this. This is using all latest development builds of things on a Ubuntu 16.04 box. Setting CACHE to folder= and disabling the websocket server returns back to a much more response Pathfinder overall and stops smashing the CPU. |
just throwing a useless opinion around : never use any library or application which has |
@danielmack we all know that, it would be fine if you can fix it ;) |
The libevent library only has a while(true) as a fallback on systems where event polling isn't available. Unfortunately PHP7 has no event polling framework available to it, putting us in this situation. That's one of the issues with using the bleeding edge. |
@danielmack It does make sense and this isn't an issue with Pathfinder. Pathfinder uses Ratchet, a PHP library to provide WebSockets. That library uses pecl-event-libevent which implements a variety of different polling and loop mechanisms (including inotify, libevent and a fallback to a while(true) when no system libraries are available). Your busy waiting Wikipedia link is completely irrelevant FWIW. There is a fix to make pecl-event-libevent compatible with PHP7.0 that has not yet been merged at https://github.com/expressif/pecl-event-libevent. I am currently using that fork with Ratchet + Pathfinder_Websocket and it's behaving /kind of okay/. If you have issues with the implementation, take it up with the Ratchet and React PHP projects. Relevant issues are ratchetphp/Ratchet#357 and reactphp/event-loop#40. |
thats like saying it makes sense to attack a wild bear with a dull stick because your favourite supermarket currently offers no lemonade and informational hyperlinks to assault rifles are completely irrelevant |
You're welcome to submit a pull request to ratchetphp and reactphp with your no-system-library-required perfect event loop. Maybe leave this issue alone for now, though. |
I'll probably do that sometime ... and it will get rejected because hobbyists dont like software dev reality, they make up their own. |
@danielmack there is no problem to create special fork like Daniel´s Ratchet for PF community. |
Ignore the comment I just deleted; I thought this had been fixed in upstream but the second a client connects it spikes to 100% CPU. It's unusable right now -- I have hundreds of users and even though I don't mind sacrificing a core to get WebSockets, it's not able to keep up with the users. This would be a really cool feature if we could figure it out. |
Well it'd be more of a bugfix, really ... i can confirm this, my instance is permanently spamming one core with a running websocket script. |
I ended up removing websocket from our pf instance as well last week, because user where complaining about bad behavior. What is strange about it though is the fact, that they only started after I moved to the master 1.2 release. It was running just fine with the 100% one core hogging with an earlier 1.2.x dev version, but it might as well be that we just reached some critical userlevel to make it so unusable. |
I'm not sure how to begin troubleshooting this but that seems inordinately high. Update users and update map all occur in <5ms but update user data ranges from 8,000 to 10,000ms. How do I go about troubleshooting this?
The text was updated successfully, but these errors were encountered: