Chat system-about PHP do chat room

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.