Data driven or client drivenLocked
I have a web application which requires to get data from Apache server at an interval of 5 seconds. At every moment, there might be a big data written into the server, or might be just none or little.
I have 2 approaches available, but not sure which is better.
The first approach is data driven: whenever new data comes in, it will notify the client to refresh to update the data. I used a php script to keep track of any new data all time with a sleep every 5 seconds.
The second approach is client driven: the client never knows if there is any new data available. Every 5 seconds, the client will ask the server whether there is any new data.
This means the client will create a new connection to server every time it requests new data. There may or may not be new data there.
My question is which approach will better minimize the server’s burden.
By the first approach, the server will hold a connection with the client all the time, and hold the state of data before it sends to a client.
My question is which approach will be better if I want to minimize the burden of the server.
Thanks so much in advance and look forward to your detailed comments.