Answer the question
In order to leave comments, you need to log in
How to update dynamic data received via UDP?
Good evening. I'm learning PHP MySQL, I've only just started.
For experience, I decided to develop server monitoring. You need to train somewhere.
Essence:
20 servers are displayed on the page.
When a user enters the site, information about 20 servers is simultaneously received via UDP directly, without caching, etc. Refreshes the page again with fresh data. Because of this, the page takes a very long time to load, especially if the server is located somewhere in the USA.
I came to the conclusion that you need to somehow store the data in the database. Let's say every minute. And on the full information page of the server, you can also display information with a direct request, because one server will load faster.
Here is the part of the array that I get:
Array
(
[Protocol] => 17
[HostName] => Panda-Community.com #16 | 2Fort
[Map] => ctf_2fort
[ModDir] => tf
[ModDesc] => Panda-2Fort
[Players] => 24
[MaxPlayers] => 24
[Bots] => 0
[Dedicated] => d
[Os] => l
[Password] =>
[Secure] => 1
[Version] => 4516743
[ExtraDataFlags] => 177
[GamePort] => 27165
[SteamID] => 85568392920041083
[GameTags] => respawntimes,alltalk,2fort,anime,best,best ping,brony,community,ctf,ctf_2fort,eu,fastdl,gametracker,panda,panda community,panda
[GameID] => 440
)
[HostName] => Panda-Community.com #16 | 2Fort
[Map] => ctf_2fort
[Players] => 24
[MaxPlayers] => 24
[GameID] => 440
Answer the question
In order to leave comments, you need to log in
Since you understand that you are writing a training bike, look at an existing monitoring system like zabbix. Briefly, its structure is as follows: a separate monitoring server is executed, which polls the hosts at a specified frequency, and adds the results to the database. And a web-muzzle is executed separately, which takes data from this database and displays them in accordance with the established filters.
1. A separate script periodically queries the servers and updates the data in the database. The user receives data only from the database.
2. You can cache requests.
For example, when querying the status of a specific server, you save data about this server and the time of the request to the local database.
On the next request, you check how long ago the request was made to the server. If more than xx minutes ago - repeat the request to the server. If less - take the cached data from the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question