PHP jquery: chat system, what is the ideal basis for this?

I want to implement a chat system for my site. Functionality will be very similar to facebook chat. Chats will be individual.

I know how to create a chat system using PHP, MySql and using jQuery. But I am worried that it will not scale for a large number of users in the long run.

Using jQuery, I will make requests every second to update the chat window or if the user sends a request in the chat with another user. This will cause additional load on the server, as the user base will increase the overtime.

I was told using PHP because it is not an ideal solution that I should learn comet programming that I have never tried before.

My question is, are there any pre-build structures that I could use, or a better approach to creating it?

I heard about NodeJs and APE, but they are not supported by my server.

Thanks guys.

EDIT: after I talk to the guys from my server, I can change my OS so that I can run NodeJS. How well is nodejs a scalability term and will it satisfy my needs?

+6
source share
2 answers

PHP and comet are not mutually exclusive. A comet is just a server push technology, so you don’t need to poll at any time. You embed the comet in PHP and JS, it is not a separate programming language.

Although : I do NOT recommend programming the chat yourself unless you need very specific features. time and error prone. Use one of the ready-made solutions, for example:

http://www.phpfreechat.net/

or java chat IRC. Google more.

+5
source

As Rok Kralj says, the comet is a paradigm and can be applied to various technologies. The PHP question and the comet are a good place to start if you want to learn this.

It is generally believed that PHP does not scale well, like real-time technology. Facebook, which is the home of PHP (although it has finished compiling its PHP to C (or perhaps C ++) for efficiency ). The most common solution is to use a special real-time technology for your real-time communication and save it outside your web server.

In terms of technology choice, I would consider WebSockets , as they have become standard for real-time bi-directional communication. Some Comet servers use WebSockets as a transport and return to the less efficient HTTP or HTTP Long-Polling stream for older browsers.

If you want to use the hosted service and don’t want to get attached to the chat features, at some point you will need to add real-time notifications, visual collaboration or games, and then http://pusher.com I work for offers a real-time hosted instant messenger in which you can easily implement your chat features.

+3
source

Source: https://habr.com/ru/post/896595/


All Articles