Pseucode:
function getjson() {
$.getJSON('link_in_my_server_unique_for_each_user_json', function(data) {
if (data.variable) {
do_something();
}
});
}
setInterval(getjson(), every_second)
Is it expensive to have 1000 users retrieving json file in my server every second and check if that file has some variable?
First, you don’t need to guess. You can measure.
Once you have a baseline measurement, you can think about optimization — do you need it and how big a problem do you have on your hands? Some of the usual solutions:
Finally, if the performance you want seems very out of reach, you’ll need to consider an architectural change. Using WebSockets would likely be a very different code path, but could conceivably result in far better performance. I’d have to know more about what you’re doing with
link_in_my_server_unique_for_each_user_json.