General discussion

Locked

Data driven or client driven

By bytj ·
Hi, gurus,
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.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Data driven or client driven

by andrew In reply to Data driven or client dri ...

A lot depends on the number of clients you have concurrently using the app, the number of servers you have, the amount of data...but here's my opinion:

I think approach 2 (client) is preferable. Holding a connection open for long periods of time is expensive. Web servers are designed to accept requests from clients and open connections; they're good at it. I also think your coding will be simpler since you're working with the normal HTTP flow (request) rather than trying to implement a push scheme.

I've done similar things (applets that get fresh data, page that use SetTimeout to reload hidden frames...) and haven't had any problems with performance or scalability.

Hope this helps.

Collapse -

Data driven or client driven

by bytj In reply to Data driven or client dri ...

Poster rated this answer

Collapse -

Data driven or client driven

by Jay Eckles In reply to Data driven or client dri ...

The (over?) simplistic answer is that the server push method will put the least burden on the server. In any case the server is going to have to send all new data to the client, but if every client is checking in every 5 seconds, that's a TON of unnecessary requests that the server has to handle.

I do agree with the previous poster than HTTP is probably not the way to do this; HTTP is a stateless protocol and manintaining session in HTTP applications is often difficult. Usually the methodsthat are easiest to work with (Session variables in servlets, JSP, and ASP, for example) are very resource intensive. Others like cookies and URL-encoded session IDs are programmer intensive.

Good luck.

Jay Eckles
www.jayeckles.com

Collapse -

Data driven or client driven

by bytj In reply to Data driven or client dri ...

Poster rated this answer

Collapse -

Data driven or client driven

by bytj In reply to Data driven or client dri ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums