allinurl/gwsocket

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

sp213 opened this issue · 5 comments

sp213 commented

demo

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

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

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

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.

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

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.