I call AJAX to check the database if there is a new notif every 3 or 10 seconds with the same request from 4 different browsers at the same time. But at some point after the 100+ cycle, the server returns Error 508 (Loop Detected). This is a simple site, so I donβt think I need a VPS server.
I added the timestamp in SELECT as the query differential, placed unset, flush, mysqli_free_result, pause, mysqli_kill, mysqli_close, but the error still occurs. Input processes reached 20/20.
Script
var counter = 1; var notiftimer; $(document).ready(function() { ajax_loadnotifs(); }); function ajax_loadnotifs() { $.ajax({ type: "post", url: "service.php", dataType: "json", data: { action:'loadnotifs' }, success: function(data, textStatus, jqXHR){ $("div").append($("<p>").text(counter++ + ": succeeded")); notiftimer = setTimeout(function() { ajax_loadnotifs(); }, 3000); }, error: function(jqXHR, textStatus, errorThrown) { console.log(jqXHR.responseText); } }); }
service.php
$link = mysqli_connect('localhost', 'root', 'root', 'testdb'); $notifs = array(); $query = "SELECT id, message FROM notifs LIMIT 20"; if (!$temp_notifs = mysqli_query($link, $query)) { die(json_encode(array("errmsg" => "Selecting notifs."))); } while($notif = mysqli_fetch_assoc($temp_notifs)) { $notifs[] = $notif; } mysqli_close($link); echo json_encode($notifs);
cPanel - Resource Usage Overview

When input processes reach 20/20, I get error 508. How to maintain low server login processes? ( Tested using 4 different browsers, run them until the 100+ cycle on shared hosting is started. No problems on the local computer )
ajax php hosting shared-hosting
Jeaf gilbert
source share