We are now making a watch live products, have chat room function, similar to Sina this: http://video.sina.com.cn/l/pl/globallive/1327915.html, his that use is jetty, I would like to know if the PHP platform is similar to the right thing to do chat room, thank you!
We now use the traditional nginx+php+mysql do, because a PHP-FPM process to account for dozens of M of memory, a server can only open hundreds of php-fpm process, barely bear thousands of people online.
Reply content:
We are now making a watch live products, have chat room function, similar to Sina this: http://video.sina.com.cn/l/pl/globallive/1327915.html, his that use is jetty, I would like to know if the PHP platform is similar to the right thing to do chat room, thank you!
We now use the traditional nginx+php+mysql do, because a PHP-FPM process to account for dozens of M of memory, a server can only open hundreds of php-fpm process, barely bear thousands of people online.
Http://cevin.me/archives/realtime-msg.html
Chat this thing first to consider the browser-side and server communication. such as Ajax polling, comet, or WebSocket (which also involves browser compatibility issues). The three methods on the server implementation are very different.
If you don't want to toss it yourself, you can see Ratchet.
In the simplest way, the front-end Ajax polls the request, and the backend caches should be fine.
Chat content should not be put into storage, directly with the list structure of Redis, and limit list length such as 10,000, after all, online chat no one will see so many chat records. This mainly solves the problem of reading.
If you must save all chat records, add a queue to smooth the storage. The problem of writing can also be solved.
You must proactively start a program, resident memory, open several threads and listen to several ports.
PHP can not do, because the PHP request is passive, can not actively run into daemon, nor multithreaded. It's good to do such a high load.