I have a simple java app, that was developed on a single server and works perfectly on it, but when it is deployed on the cluster(it is the test environment before production, the cluster contains two nodes) it creates duplicates of HTML blocks.
Problem: Servlet returns JSON object that looks like this:
{"data":[{"ip": 192.168.0.1;192.168.0.2},{"dt":"12-12-2018;13-12-2018"}]}
The IP and date JSON objects are SQL query results. My HTML block that uses that JSON data is created dynamically. When the app is deployed on the cluster I see duplicates of HTML blocks and the main differenc in time. Seems that every cluster node runs the servlet method that executes the SQL query and returns a JSON with different dt.
How can I avoid this problem? How to execute the servlet method only once or only on one node? Or what should I do? I haven't got any ideas.