views:

114

answers:

3

Client has a dating site and would like to have a popup (either a nice javascript overlay or a new browser window popup. we're flexible.) displayed to users when another user is visiting their page.

I'm familiar with push technology and Comet but it's quite challenging to implement this and may place serious strain on a server with over 100,000 unique visitors per day.

I'm wondering if there is a way of faking this, perhaps by not being accurate to the second. I can't really think of any way.

This is a classic LAMP environment.

Anyone?

EDIT: what about this: placing an iframe on the page that refreshes every few seconds and at each page load it checks in the db if a visitor has been logged on this profile page. if so, it shows a message. the message would be visible but the background of the iframe would blend in with the background of the site and be invisible. if the message fades in and out, it would look like a JS box "popping up".

A: 

Gather statistics as to how many visitors that user's website gets per day, and then subdivide that, so that it's a percentage chance that the user will be told there is a user on his site (even if there actually isn't), based within the timeframe he's at the part where he can receive the popup. I think this is the closest you are going to get without having some sort of notification being sent.

You could do this to minimize server usage if you wanted push: When a user visits a website, check and see if the person who would be getting the notification is online and capable of being notified, and if so, THEN do all the push stuff, otherwise forget it.

Sneakyness
A: 

The only way to "fake" comet is via polling of some sort, which is always a possibility. An iframe, xhr, or jsonp request are all possibilities for performing said polling.

You might be better off purchasing a pre-built comet server (I'll recommend, of course, the one I helped build, WebSync for IIS/ASP.NET). If you're worried about the load, you could check out our On-Demand version where we'll host it for you.

Regardless, WebSync (or whatever other pre-packaged product you might check out) would scale to a hundred thousand users a day without much of a problem, and would potentially be more efficient than polling, since it would only hit your database when new users arrived, rather than every couple seconds; that said, if you keep the "check for new users" query simple enough, and a few seconds of delay is OK, the polling idea would be the "simpler" solution.

jvenema
A: 

Check out http://en.wikipedia.org/wiki/Web_Sockets if you want to do real push. This isn't widely supported in browsers yet, but there are plenty of JavaScript and Flash libraries that provide it already.

Or a cheaper way is to record in your DB each page view. Then when any user makes a web request, check in the DB if anybody has visited their page since their last web request. If so, pop up your dialog.

This second way wouldn't popup anything if the user just left their browser sitting there, but if they were actively interacting with the site, it would achieve your goals very easily.

I would start with this second simpler solution, which is very easy to implement. If your client wants it more interactive, you can provide solutions and tradeoffs/costs for various options.

dkamins