Long Polling performance with PHP, Mysql and Ajax

8

I'm developing a PHP site, and using Long Polling techniques for real-time notifications.

I'm getting the script to wait 50 seconds for a response, and not getting one, in 2 seconds it asks again, to give greater turnover of connections, as the big sites do.

I have already tested some active connections on my machine, opening different tabs and browsers at the same time, and each opens a different process on the server.

The doubts are as follows:

1 - is each such process an active user?
2 - Does this method pull too much of the server's capabilities if you have a lot of active users?

I ask this because the hosting only releases me space for up to 30 active users at the same time, and if that is the case, I will need something that goes well beyond that.

    
asked by anonymous 29.04.2015 / 21:36

1 answer

2

Unfortunately long polling and PHP are not good companions.

For each browser that is in long polling requesting a request, a PHP process is running. This means you not only have one process per user, but you can have multiple processes per user if you have multiple tabs or windows open on your site.

Even though the PHP configuration is optimized to not succumb to many features, it is not easily scalable, especially in shared hosting. Even with the limit of users, each long polling process will prevent another user from accessing the site if you reach the limit of 30.

    
30.04.2015 / 12:47