allinurl / gwsocket

fast, standalone, language-agnostic WebSocket server RFC6455 compliant
http://gwsocket.io
MIT License
745 stars 67 forks source link

Why not just use a shell and php to echo it out? #10

Closed sp213 closed 7 years ago

sp213 commented 7 years ago
demo

I think my way is much easier. Sorry, but I didn't see any advantages of using gwsocket.

jirutka commented 7 years ago

ROFL, this is quite good trolling, sir. At least I hope that it's trolling, it would be really very sad otherwise...

allinurl commented 7 years ago

There are a lot of advantages of using a WebSockets over AJAX or Long Polling, it depends on what you are building though.

Doing it your way, you will need to either refresh your php page to get the latest entries from the log or do an ajax call every certain time to fetch the data. Again, depending on your needs, polling may be ok. A shortcoming of sending HTTP requests (e.g., via ajax) is that even when data hasn't changed, you are still wasting those requests.

There is a lot of content out there about when it's good to use WebSockets.

Hope that helps.

sp213 commented 7 years ago

Yeah, you are right. 👍

Actually, in my company, we are using shell, namely tail, then put the contents into influxdb and use grafana to show the real-time logs.

allinurl commented 7 years ago

Just adding to my previous comment and since you mentioned a DB. If you don't have a good mechanism to cache those queries, then you may cause a significant load to the DB.

For instance, if you have many clients connected to a query-rich dashboard and each client is fetching data via ajax/long polling, etc, then each client will be repeating the same queries to the database. Instead you could avoid hitting the DB multiple times and then push those results out via gwsocket to all clients.

sp213 commented 7 years ago

Yes, we have hundreds of servers. We only pour the data into the database from one instance's logs, since we are using load balance.