We’re using XMPP (eXtensible Messaging and Presence Protocol) because it’s a well-defined, open standard, real-time protocol. We could use HTTP for messaging, but it requires cumbersome workarounds for its request/response design to get real-time behavior. Because XMPP was designed as an event-driven messaging system, it also features presence, discovery, and strong security.
Status events, or presence in XMPP, are broadcast to interested parties as they happen, so there’s no need to frequently poll components for their current state. When you sign off of your instant-messenger, a presence event is broadcast to your friends, notifying them of your change in status.
But presence is much more than just changing your buddy icon from green to red. For example, servers can broadcast changes in their capacity and load to other components, which can then route work to idle systems.
Each component on an XMPP network can discover the features and capabilities of every other component. Your chat client can ask your buddy’s program if it supports file transfers or video chat. A web application can dynamically discover the location of back-end message queues to send tasks to. Being able to learn about other components on the network allows systems to scale and more easily adapt to failure.
XMPP has flexible SASL authentication baked right in. It also mandates the use of TLS encryption on connections to the server. In fact, our Vines server doesn’t support a plain-text, unencrypted mode. All client connections must be encrypted.
An XMPP domain is a closed system, in the sense that messages can only be sent between two authenticated users in the same domain. This prevents spam and unwanted messages passing through the server. Although XMPP servers can be federated to allow multiple domains to talk to each other, it’s up to you to decide which domains to allow to connect.
XMPP is more than just instant-messaging. It’s a mature protocol that can be used to connect components in any scalable web application. Take a look at our open-source Vines XMPP server. We’d love to hear what you think!
- David Graham
01 Jul 2011