I want to write an application which monitors a few URLs (like a couple hundred) of all branches of school. By monitoring, we mean that it sends requests to those URLs at regular intervals (Interval for each URL is defined by user), and on the basis of the response to those requests, it makes some changes to the web page. This process goes on forever.

Now there were two ways to implement this:

Approach 1. Load the web page into the browser. First get the urls data from the server. Then group together all urls which have the same value of interval. This results in a few groups of URL's (say 10 groups). Then for each group, at regular intervals whose value is defined by the value of interval field, I send an AJAX request to my own local server, which does all the processing and then returns a response to browser. On the basis of the response I make changes to the DOM.

In this case, the first AJAX request for all groups should be fired at (almost) the same time, and then should be fired at the defined intervals. This goes on IN PARALLEL, forever.

I implemented this by using Javascript's timer functions like setInterval() and setTimeout() etc, which are asynchronous and execute at regular intervals; as well as AJAX which is asynchronous.

Approach 2. The above method seems to be overhead for browser and conceptually speaking, reading data in client-side (browser) from the server and then sending it back to server for analysis and then getting a response of analysis on client-side and then on the basis of the response, making changes in the look of the webpage, JUST DOES NOT FEEL RIGHT.

Rather I should keep the analysis-at-regular-intervals thing at the server, and then insert the results of analysis in database, and then from the browser periodically send requests to my server to read the results of analysis from database, and on the basis of response of this periodic request, make changes in webpage DOM.

For this, I tried to use PHP, but PHP does not support multi-threading and solutions like opensource Asynctask class become overly complicated (unable to enable pcntl extension, no support for pcntl in windows environment); I have considered Java, as it supports multi-threading and creating a separate thread for every group will be simple.

So which approach is correct or better? What programming language should I use - Plain Javascript for the approach 1, or PHP or Java for approach 2.

  • Golang has proved to be an incredibly good language for long running processes, which is exactly something you want. If you are able to run that, perhaps it would be good idea to look into that.
    – Andy
    Aug 17, 2018 at 8:24
  • If the update interval for one group is 1 minute or longer and two users open the site 30 seconds apart, should they see an update at the same time, or 30 seconds apart from each other? Aug 17, 2018 at 9:47

1 Answer 1


The answer to this is fairly clearly to implement it server-side, at least if you still want the monitoring process to continue even if somebody closes the browser - and I'd say that's a requirement for any "professional" solution.

Which language you choose server-side is mostly irrelevant: it's a question of what you (and your team?) are most comfortable with. Java/C# would work, Node would work, Python would work, many other languages would work as well.

  • Python has a single threaded model like PHP. So why will it work? We need to start the monitoring process for all requests simultaneously. So we need multiple threads right?
    – Shy
    Aug 17, 2018 at 8:00
  • Python has asyncio, Python has threading ("threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously"), Python has multiprocessing. I know it's not the Python way, but TIMTOWDTI. Aug 17, 2018 at 8:06
  • 1
    You're never going to literally process hundreds of connections at the exact same time*, so you may as well just set up a list ordered by next run time and run it on one thread Aug 17, 2018 at 13:17
  • *- in a small application like you want to build that wont have a server dedicated to it Aug 17, 2018 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.