?
Solved

Pushing data from server to client ? Ajax / PHP ?

Posted on 2009-04-21
3
Medium Priority
?
2,771 Views
Last Modified: 2012-05-06
I am implementing an open connection that continually pushes data from server to client.

My initial thought was to include a frame of PHP sockets connecting to remote hosts that runs on a " while(true) " loop, then sends Javascript calls to the parent. Two problems with this is that the page is always loading so the icon is continually spinning, and that after a bunch of visitors connect to my site... I feel that it'll bog down with so many open connections. The first one doesn't seem like a big issue, more of an appearance thing... but the bogging down from too many persistent open connections seems like it will get really bad, really fast.

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?
=[

Open in new window

0
Comment
Question by:MattKenefick
2 Comments
 
LVL 3

Accepted Solution

by:
hard2u2001 earned 2000 total points
ID: 24201925
0
 
LVL 4

Author Comment

by:MattKenefick
ID: 24201928
Sounds like COMET is the way to go.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question