PHP Chat System – Best Way to Create One

chatPHP

I'm into creating a php based web chatting system.
About 1000 concurrent users across the world will be using it, so what would be the best tech to deploy?

As I did some research online, mainly I found systems using ajax and jquery for chatting while there're some using web sockets. I'm not sure as to which would work the best to suit my need. I prefer a real-time chatting system. If I were to use Ajax, will that be real time and as user increases, will there be any conflict?

Also, if I use HTML5 web socket, since the users going to chat from various nations around the globe, would it be faster? Let me give you a scenario.. If I use HTML5 push method which is hosted in some server in UK let's say, and the users from countries like India, Africa and China, will they face any downtime/ delay in sending and retrieving the messages?

Thank you for your time and detailed explanation in advance!

Best Answer

Ajax has better compatibility, but web sockets are more efficient and simpler (as you won't have to deal with issues about long polling, which can be a hassle to get right sometimes). These days, relatively few browsers support ajax but not web sockets, so my suggestion would be to do it that way, simply for the sake of simplicity.

Note that efficiency isn't likely to be your primary concern here; 1000 simultaneous users is not much (i saw that many using a single-server chat system over 20 years ago, now - the server that ran it was probably less than a tenth as powerful as my phone). Make your ementation straightforward and ready to evolve as your requirements change, is the critical thing.

I would, however, recommend not doing this in php if you have the choice. This is a highly concurrent application, and the last I checked (admittedly several years ago now) php's support for concurrency was somewhat lacking. If you prefer dynamic languages like php, maybe try either python or ruby for this project.

Related Topic