A
A
Anton Neverov2017-10-17 04:49:00
PHP
Anton Neverov, 2017-10-17 04:49:00

How to optimize constant PHP updates?

Hello!
There is a PHP application that notifies people about the current state of the server (for example).
Now this is done with jQuery, which sends an AJAX request to the server every 30 seconds and receives a response, which it displays to the user.

The problem is that now I have a very large number of requests and this is very heavy on the server.

Question: How can we optimize the process of delivering updates to users?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
danforth, 2017-10-17
@TTATPuOT

You can deliver data to the client using websockets, you can stop generating an AJAX request on inactive tabs.
But in general, every 30 seconds is not a load at all. How many users do you need to have on the site at the same time in order to generate many requests in total every 30 seconds? Perhaps the backend itself is not optimized for you? Heavy features? Complex database queries? Not optimal algorithms?

M
marataziat, 2018-03-16
@marataziat

Bullshit. PHP for real-time alerts is NOT INTENDED! Either use normal code, or switch to nodejs!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question