0

I have a web app running in PHP over CakePHP framework in IIS on a Windows 2008 server machine.

Now, this application is polling every 6 seconds per connected user to refresh part of the screen and this is causing tends of requests to the IIS server and slowing the whole system down when the Oracle database is busy.

In an attempt to solve this issue I'm thinking of using Node.js to solve this problem and using push notifications. This way every 6 seconds Node would push notifications to all active browser clients.

The problem I'm facing is that the call I'm making is making use of the logged user session. (to call the DB, and once I get the data, to update the session).

I've read Redis can be a solution for this and I've seen posts explaining how to share the session. But there's something I don't get yet:

How could I have the session of the logged user? Should I iterate over all active sessions?

I want to create a setInterval in node to query the DB for each logged user.

Community
  • 1
  • 1
Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • why not have your php and browser talk via web sockets and have the php push the data to the clients instead of clients doing pooling? I'm not familiar with php sorry, but in node we use web sockets and its pretty easy. I mean... thats what websockets are there for. and I am guessing that php should support web sockets as well. that way, you can leave your backend consolidated. – sagie Oct 14 '15 at 11:18
  • @sagie there's nothing like `setInterval` in PHP. PHP runs only when the user makes a request. Otherwise you would need a cron or scheduled task, which of course, won't have access to the sessions either. (and in windows the minimum time to fire it is 5 mins) – Alvaro Oct 14 '15 at 11:25
  • ok got you, so you might have to look how php stores the session in the redis and extend the express redis session store to read that format. the issue is that many middlewares like to write stuff on the session so your extend redis session store will have to take care of that. – sagie Oct 14 '15 at 11:38

1 Answers1

0

I can understand you issue i implemented a similar kind of structure for web chat . With redis or memcache you can create you own data structure to hold users session it will be loaded into ram ,really fast and it will work like global session will be accessible to all users session and for any node or ajax request from browser you will access redis and return response back to user rather than sending request to Oracle database and than back to user .

rameez931
  • 21
  • 3