Designing an instant messaging system / Facebook Messenger / WeChat

How to design a scalable messenger system like Facebook Messenger / WeChat / WhatsApp?