This cycle is redundant. It can run many thousands of times per minute, even on a moderate server, and it generates high CPU utilization even for a real-time application. Add a counter and view the iteration counter. I think this creates an even greater burden than processing each AJAX request.
First of all, determine the granularity in which you need information. Suppose you decide to have 3 seconds of granularity (for example, sweeping a database every 3 seconds) - this number may be too high for you, but it illustrates that you are not losing much. When AJAX pulls every second, you CAN see some counters that need to crawl continuously to scan back once or twice. (Will you really see that this depends on the nature of your counters.)
If your counters are based on data in the range of seconds (for example, showing the sum of elapsed seconds or the sum based on $ / sec), then secondly, the AJAX pull will not provide continuous counters. (Sometimes it skips the second or updates to the second second for network reasons).
Regardless of the granularity you choose, your final statistics will be fine, because they are based on absolute timestamps - no matter how late they are estimated.
If the second time, AJAX polling is used to implement a smooth counter, than you can do much better than this: the count should be done on the client side (for example, sending values with their second step: revenue: <span data-inc="25">14432</span> and counting using JS). The only AJAX tool to monitor the status of stop / reseller counters. Then you only need to determine how long the alert can be late (for example, 10 seconds), then the counters will skip for max. 10s - return to the expected value. In this case, you should not clean the database more often (for example, half the interval). This allows, for example, for a 3-second sleep in your cycle, which drastically reduces the load.
If you can easily add the addition of a timestamp for the expiration of each chat to the database (either in the record or fixed) with an index that will speed up the reading of bits (and additionally allow expiration rules).