Most desktop chat applications probably use a specific software running on a distant dedicated box. However, is there a way a chat application could be backed by a simple PHP/MySQL web site? If so, what general advice would you give in terms of logging in and sending/receiving text?
Most desktop chat applications probably use a specific software running on a distant dedicated
Share
There are two problems with the architecture (PHP/MySQL) you propose.
1) Chat is two-way traffic. This means that you need some way to push a message to your users.
One option is to have your clients poll constantly for new messages (generating a lot of traffic).
Another way is to wait with answering a HTTP request until a message exists. This is dependent on the timeouts in the network (timeout from proxy server, timeout from HTTP server). But it would work.
2) You have to be able to communicate messages between PHP instances. When you load a HTTP page, a single PHP process is launched which transforms the PHP code into HTML. You are proposing to use MySQL as a common data store between those processes. This means that you would need to have your PHP code constantly poll the database. They also need to mark which messages have been transferred to the client and which haven’t. Maybe messages are lost along the way, there is no way to be sure.
Because of these two problems, chat programs are better left to a specific architecture.