I am implementing an open connection that continually pushes data from server to client.
My second option was using Flash sockets to connect to remote hosts. That would take the payload off the server and put it on each client. This would be a great idea, but the remote hosts need to have a cross-domain-policy file in effect for me to connect to them ( which they won't ).
My third option is to run AJAX requests. This doesn't save me as much as I'd like because it would still have to run though my server... but I don't think it'd be as bad on my server as my first option of running the "while(true)" loop per each request. Problem with this is if the data comes in from server side... I'd have to wait til my next AJAX request to find out about it ( unless I can push it from the server? Is that possible? ) Second is that it would just be making a lot of requests.
Fourth option might be to run AJAX requests to a "while(true)" loop for 30-60 seconds at a time? I'm not sure if this would help any, but it seems like giving the PHP a break every so often might be better than letting it run constantly?
I guess my questions are:
- How bad is running the persistent PHP data to the site? Even if it's not constantly receiving data.. sometimes just sleeping, but still running the process.
- Is it possible to push data from the server to the client via AJAX so I don't have to wait 'til my next request to find out about it?
- Is there a 5th option here that solves my problem?
The ideal solution would be the Flash sockets so I can pass the workload off to each individual user instead of having everyone channel through my server. I want to channel through like ICQ/GTalk, but they don't have cross-domain policies for me to use.
Anyone have some ideas?