0

What I'd like to know is how much difference does it make if I try to build a chat application, using normal PHP/MySQL/Ajax and socket connections which normally makes use of XMPP or other protocols. Please let me know so that I can follow the right and a faster way to make a chat application.

2 Answers 2

1

When using PHP as an Apache-Module or fastcgi it is not recommended using a long-lasting socket connection as this quickly eats up the servers resources.

Generally speaking the socket connection is superior: You can instantly send data to the client or vice versa.
A normal AJAX request also has more overhead in establishing a new TCP/Ip connection and sending HTTP headers.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use AJAX to pull for messages from the webserver at particular time interval. This leads to a new connection for every pull and thus takes a lot of time, as establishing a new connection is a time consuming process. If you use XMPP (which is the standard protocol for implementing Instant Messaging) then you are continously connected to the server and thus you can, in realtime, send and recieve messages from the server.

However if your clients are gonna use a web browser for communicating with your server, rather than using your own app, then you have no other choice than to creatively use AJAX so the connections last as long as possible and your users feel minimum lag in their chats.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.