Long Polling performance with PHP, Mysql and Ajax

Asked

Viewed 1,129 times

8

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

I’m making the script wait 50 seconds for an answer, and not getting one, in 2 seconds it comes back to ask, to give greater rotation of connections, as the big sites do.

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

The doubts are as follows:

  1. each process of this is equivalent to an active user?
  2. this method pulls much of the server’s capabilities if it has many active users?

I ask this because hosting only allows me space for up to 30 active users at the same time, and if that’s what it is, I’m going to need something that works better than that.

1 answer

2


Unfortunately long Polling and PHP are not good companions.

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

Even if the PHP configuration is optimized to not suck many resources, it is not easily scalable, especially in a shared hosting. On top of the user limit, each long Polling process will prevent another user from accessing the site if you reach the 30.

  • Got it... anyway using PHP I run this risk right. I think I’d really have to use some other method of Websocket

  • 1

    @Isaiaslima Yes, there are other things that adapt better to this type of programming than PHP.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.