How to implement a real fast web chat with PHP?

前端 未结 3 1502
面向向阳花
面向向阳花 2021-01-01 00:32

How to implement a real fast web chat with PHP?

Has anybody ever wonder why Facebook chat is just so really really fast? even in IE without WebSocket.

Isn\'t

3条回答
  •  时光说笑
    2021-01-01 01:08

    You might want to consider Node.js to serve the clients in 'real time' since Long polling with PHP/AJAX may cause strain on your server. But the implementation itself is an uphill task. Just saying. Long polling with PHP/AJAX may cause strain on your server.

    My typical theoretical implementation of the same:

    1. Create a Node.js server to query a database.
    2. Send variables and/or session data from php to Node js using cURL.
    3. Parse the url in your Node.js server and use the variables to check for changes in database.
    4. Emit new data if changes occur and send to client.

提交回复
热议问题