Using comet with PHP?

后端 未结 11 1402
星月不相逢
星月不相逢 2020-11-22 03:09

I was thinking of implementing real time chat using a PHP backend, but I ran across this comment on a site discussing comet:

My understanding is that

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 03:59

    PHP

    I found this funny little screencasts explaining simple comet. As a side note I really think this is going to kill your server on any real load. When just having a couple of users, I would say to just go for this solution. This solution is really simple to implement(screencasts only takes 5 minutes of your time :)). But as I was telling previously I don't think it is good for a lot of concurrent users(Guess you should benchmark it ;)) because:

    1. It uses file I/O which is much slower then just getting data from memory. Like for example the functions filemtime(),
    2. Second, but I don't think least PHP does not a have a decent thread model. PHP was not designed for this anyway because of the share nothing model. Like the slides says "Shared data is pushed down to the data-store layer" like for example MySQL.

    Alternatives

    I really think you should try the alternatives if you want to do any comet/long polling. You could use many languages like for example:

    • Java/JVM: Jetty continuations.
    • Python: Dustin's slosh.
    • Erlang: Popular language for comet/etc.
    • Lua, Ruby, C, Perl just to name a few.

    Just performing a simple google search, will show you a lot alternatives also PHP(which I think on any big load will kill your server).

提交回复
热议问题