Yii Framework Forum: Real-time web apps in PHP - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Real-time web apps in PHP Rate Topic: ***** 1 Votes

#1 User is offline   tedd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-November 10

Posted 07 July 2011 - 06:42 AM

Hi guys!

Currently I'm developing a web app for online collaboration. One of the key features is real-time responsiveness - i.e. when someone posts something, others get the new post instantly.

I do not consider old-school stuff like setting timeout on a client. At the moment I think that socket.io is pretty much what I need. But I have a doubt whether the tandem "php+socket.io" is viable. For example, how do I make them communicate with each other? How do they share the auth session?

Does anybody have experience in this field? Your experience is very valuable to me.
0

#2 User is offline   Weavora Team 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 06-December 10

Posted 07 July 2011 - 06:53 AM

Hi tedd,

To communicate between php and web sockets I suppose you will need some comet solution. We did it on this way:
1. Have Redis (pub/sub feature) to send/retrieve messages (channel No is user ID)
2. Have PHP to send notifications into Redis when something happen
3. Have Node.js app listen all channels and send notification to web sockets

How to identify user:
1. After user login we added to Redis hash pair: sessionID => userID
1. After user connected to socket, it send auth command to node.js with session ID.
2. Node.js check hash in Redis for sessionID and get userID.
3. Node.js subscribe connection to userID channel
3

#3 User is offline   tedd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-November 10

Posted 07 July 2011 - 07:19 AM

That's very interesting, thanks!

Just to clarify: do you use pure Node.js or Node.js plus socket.io (or something)?

How stable the whole system is? How many simultaneous connections it can handle?
0

#4 User is offline   tedd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-November 10

Posted 07 July 2011 - 07:32 AM

Also, do you proxy your nodejs server?
0

#5 User is offline   Weavora Team 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 06-December 10

Posted 07 July 2011 - 07:34 AM

 tedd, on 07 July 2011 - 07:19 AM, said:

Just to clarify: do you use pure Node.js or Node.js plus socket.io (or something)?

Node.js + socket.io

 tedd, on 07 July 2011 - 07:19 AM, said:

How stable the whole system is?

Have no serious problems.

 tedd, on 07 July 2011 - 07:19 AM, said:

How many simultaneous connections it can handle?

Honestly, can't tell you exactly because we haven't opportunity to run with highload yet. But I assume we wouldn't have any problems with ~100 connections (or maybe even with 1k, because node.js + redis is very fast).

Also please note, that you could easy to scale node.js application by just copping to another node. Redis also is fast & scalable engine. So I don't think that any deadlock issues will come. But this technology is still "beta" and no guaranties here.
0

#6 User is offline   Weavora Team 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 06-December 10

Posted 07 July 2011 - 07:36 AM

 tedd, on 07 July 2011 - 07:32 AM, said:

Also, do you proxy your nodejs server?

We no need to use proxy, so we connect directly to nodejs (we use 3001 port for this). Also nodejs didn't call any php code (for example, through fastcgi) and so on. To keep it fast as possible.
0

#7 User is offline   tedd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-November 10

Posted 07 July 2011 - 07:49 AM

Many thanks for answers! You really clarified things.

As for proxying nodejs - I've heard that it is recommended to proxy nodejs by a stable web server (nginx for example) for security reasons. Have no proofs though.
0

#8 User is offline   trileletri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 12-January 12

Posted 01 October 2012 - 01:31 AM

I'm planning on building a small web server using nginx and node js, since I need it for building a real-time web application (with Yii, of course), as soon as my dedicated computer arrives.

I was thinking of nginx to process php and nodejs to send database queries and updates.

I will post my development results and experiences here, when I get them ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users