Realtime Messaging Services Design

Functional Requirnments

  1. one to one / group chat
  2. support for multimedia – text / images / video / loccation
  3. Read receipt / Message status
  4. Last seen
  5. Push notifications

Non Functional Requirnments

  1. No latency / No lag
  2. HA ( high availibilty ) + Fault tolerent
  3. scalablity ( 2 billion users , 1.6 Monthly ative users )
  4. traffic 64 billion msgs / day
  5. Administrative requirnments – GDPR so on

Design Expectations

  1. Partition tolerance to handle a large amount of data using clusters.
  2. To create trust, reliability and consistency are critical as miscommunication will drain user confidence in the application.
  3. Resilient to recover from failures.
  4. Security and Privacy : End to end encryption on SSL
  5. Analytics and monitoring

The User Application system could have user profile , messaging service and alerts / notifications .

A transistent data store handles unsent messages before expiry. The transient message are temporarily stored and once send to user., deleted .

The frontend tech for the various mobile and desktop agents could be

  • Android: Java / React Native
  • iOS: Swift / React Native
  • Web client: JavaScript/HTML/CSS/ with web frameworks such as Angular or React JS
  • Mac Desktop app: Swift/Objective-C
  • PC Desktop app: Electron , C/Java

Message Format

from :  alice x.x.x.x
to : bob y.y.y.y
metadata : 
    timestamp : 12 dec 2017 3:09:13:6678
    type : text 
msgPayload : "Hi How are you " 

“Message Read ” Format

from :  bob y.y.y.y
to : alice y.y.y.y
metadata : 
    timestamp : 12 dec 2017 3:09:13:9070
    type : seen
msgPayload : 

Primary Keys

  • User
    • UserId
    • Username
    • UserprofilePic
  • Groups
    • GId
    • UserId1, UserId2…
  • Messages
    • ToUserId
    • FromUserId
    • Ts
    • MediaUrl
  • Sessions
    • UserId
    • MsgServerId
  • LastSeen
    • UserId
    • Ts



  • SendMessage(senderUId, receiverUID, msg)
  • GetMessages( UserId , count , timerange)

Accout API

  • registerUser ( APIKey , phoneNumber, UserId)
  • loginUser ( APIKey , phoneNumber , UserId , OTP)
  • validateAcc

Group API

  • createGrp (APIkey , groupInfo) return GrpId
  • addUserToGrp ( APIKey , UserId, GrpId)
  • removeUserFromGrp (UserId, GrpId)
  • createAdmin( APIKey , UserId , GrpId)

Other API should provide

  • authentication
  • monitoring
  • Load balancing
  • caching
  • request hsaping
  • static responses

Messaging protocol

HTTPHTTP Long Poll / short Poll by Client Websocket
slow as server closes connection after each req client polls the server requesting new informationpersistnet connecion
Server Push
unsuitable to for realtime msgingunsuitable to for realtime msgingsuitable

High Level architecture (HLL)

The overall high level architecture consists of interfacing websocket handler layer isolated from core messaging service and msg handler.

Session Management

Dedicated / Private Chat Sessions : SessionId = <UserId1 + UserId2>

Group / shared Chat Session : SessionId < prefix + randomId >

SessionMessages schema can have its primary key : <SessionId + timestamp>

Fan Out Message / Send to All

Routing Service -> Messaing Group -> Push Notification

Push Notification

  • APNS – apple Push Notification Service used for iphone
  • GCM ( Google Cloud Mesageing ) / FCM ( FireBase Cloud Messaging )
  • WNS ( Windows Notofcaton Service )

Mobile Agent talks to its PNS with its device ID to get a pus notification token

The push notifcation token will be then used by Messaging platform to send a push notification to recipint .

Handling Load

External Load Balancers for Websockets Handlers and User agents

High load shared by multuple Message servers and PAI gateways behind Internal Load balancers in Dmz zone ( demilitirized zone).

Distributed Datastore : API gateways to distribute requests accross servers using consistent hashing

Sharded by GroupId as Primary Index and UserId as seconday Index

Distributed cache : write through Mechanism : Redis Clusters

Stream and Log Analysis : Kafka + Hadoop


Assume 1 billion users active per month and 40 million at peak

server required = message count per second * latency / server limit for concurrent messages per second

servers required = 40 million * 20 ms / 100,000 = 8 servers


  1. If receipient of Message is offline / unavaible the message delivery is tried indefinately
    • Solved using transiset message satore to hold undelivered messages untill user is able to take the message or message is expired .
    • Transisnet DB can be FIFO
  2. Server Failure
    • Replication of Messaging Server for ongoing sessions in 2f+1
    • client to automatically be handed over to new server when exsting server crashes


  1. Replication of Transient Storage and CDN for media ( images / Videos )
  2. To fetch new messages – use the last msg as pointer to read the message that was last read and fetch all message with greater sequnece
  3. Random Authentication and Challenge
  4. Proactive server restore and key refresh to prevent brazentine attacks
  5. Integration with SMS gateway

Rich Communication suite

I I have discussed more Addon Features for IM in terms of RCS ( Rich Communication Suite )

RCS ( Rich Communication Suite )

RCS ( Rich Communication Suite ) For the past few weeks, I’ve been trying to find the answer to this one. After much information gathering, I understood that majority of communication platform provider’s mostly OTT such as iMessage from apple, RBM(RCS Business Messaging) already supports these features. And it is partially a term coined by Google…

RCS ( Rich Communication Suite )

RCS ( Rich Communication Suite )

For the past few weeks, I’ve been trying to find the answer to this one. After much information gathering, I understood that majority of communication platform provider’s mostly OTT such as iMessage from apple, RBM(RCS Business Messaging) already supports these features. And it is partially a term coined by Google to bring smart communication features in Android and other smartphones. In essence, RCSe is a part of the broader IMS architecture published by GSMA.

Update: after 2019 plenty of carriers also already provide RCSe as a replacement for SMS. OEM providers like Samsung also have RCS feature inbuild in phones.

Rich Communications should be viewed as technology upgrade that will transition SMS and voice capabilities from Circuit Switched technologies into the all-IP world, including VoLTE. RCS and VoLTE are build over IMS technology. The RCS wil benifit from Standardization of the technical environment, shared by all industry players, to offer these services on a wide range of handsets

The Rich Communication Services programme is a global initiative to deploy inter-operator services within an industry ecosystem. Marketed by the GSMA under the brand name joyn,  RCS is an upgrade that marks the transition of messaging and voice capabilities from Circuit Switched technology to an all-IP world.Wider and large scale IMS deployment, interoperability between different terminal vendor RCS clients and RCS service interworking between operators are the key aims of the RCS Initiative.

What is special about RCS ?

In the face of new and innovative over the top messaging applications, mobile operators are experiencing declining SMS usage. With the launch of WiFi and VoIP enabled voice calling applications, similar declines in voice revenues are increasing, RCS presents and opportunity for telecom providers to rebrand their messaging solutions as a better product to compete against the growing influence of “Over-The-Top” (OTT) communications services providers.

  • Enhanced Phonebook: service capabilities and enhanced contacts information such as presence and service discovery.
  • Enhanced Messaging: enables a large variety of messaging options including chat, emoticons, location share and file sharing.
  • Enriched Calls: enables multimedia content sharing during a voice call, video call and video sharing (see what I see).

Rich Communication Suite (RCS) and RCS-e aim to seamlessly unify the communications experience by integrating traditional mobile telephony with new interactive services such as presence, instant messaging and content sharing enabled by the enhanced address book of the mobile phone. RCS leverages the 3GPP IMS architecture and uses SIP signalling to establish sessions to exchange instant messages, presence information, video and files

RCS releases

Five releases of the RCS specifications have been made to date. Each release expanded the scope of its predecessor.

  • Release 1 : Offered the first definitions for the enrichment of voice and chat with content sharing, driven from an RCS enhanced address book.
  • Release 2 : Added broadband access to RCS features: enhancing the messaging and enabling sharing of files.
  • Release 3: Focused on the broadband device as a primary device.
  • Release 4: Included support for LTE.
  • Release 5: The most recent release, global interoperability is a key aspect of these specifications.

As the team developed a web client for making and receiving SIP calls over websockets through a proxy SIP server , I felt its an  achievement big enough. To integrate it with RCS ( Rich Communication Suite ) stack appeared as a very complicated job .

I began by adding RCS specific standards modules one by one instead of importing the whole stack / library all together. The modules for XCAP for buddylist, MSRP for file transfer, geolocation  mapping , cloud sync of phonebook and message book have begun taking shape . In essence following features set are expected out of a RCS enabled Client ( short outline ) Provisioning

  • OAUTH integration with operator customer portal
  • RCS HTTP Auto-Configuration
  • Manual IMS credentials, typically reserved for testing / troubleshooting

RCS services

  • Service Discovery
    • OPTIONS and Presence supported
    • Address book polling
  • Delivery & display notifications o Message composing indication
  • 1-1 Chat
    • IMDN
    • Is-Composing
    • Store & forward / deferred message and notification delivery
    • Hotfixes compliant
  • Group Chat
    • Hotfixes compliant
    • Is-Composing
    • IMDN
    • Geo-location Push
    • Start and end a group chat session
    • Add or remove participants
    • Broadcast / Send messages to all participants
  • File Transfer
    • Send file via URL or as MIME attachment o Accept or Reject file transfer
    • MSRP based
    • HTTP based
    • Store & forward
    • Geo-location push via FT
    • vCard sharing
    • Thumbnail support
  • Voice & video
    o Best effort voice
    o Transcode
  • Network Address Book Support
    • Synchronization to SyncML based network address book
    • Contact import from Google, Facebook etc.


Pblished under Joyn in GSMS RDC Developer documents. There are many individual RCS APIs available. Brief details are as follows.

1. Log user in and out of the RCS server : Allows address book contacts to receive periodic updates of user availability for chat, file transfer and other services. This is essential for use of the RCS services.

2. Subscribe application to server-originated notifications :This is one of the most important aspects of RCS as events are asynchronous; the notifications channel is used by your application to know how an API call is proceeding and to receive updates from other users such as messages, files and status updates. You can subscribe to certain types of notifications if your application is focused on particular RCS services.

3. Network address book access and management : RCS provides each registered user with a server managed address book. Though the other APIs are not restricted to contacts in the network address book this makes it much more convenient to connect with other users. The network address book can have contacts added, removed, attributes changed, and is available to any application the user signs in to.

4. Chat API : Unlike SMS, which is broadly a ‘fire and forget’ service, the RCS chat services allow much more sophisticated messaging services to be built. Depending on user configuration you can check out whether the user has received the message, and displayed it.

RCS chat also allows feedback to other parties when a user is composing a message. There are also group chat services allowing multiple parties to collaboratively message. RCS provides API features for setting up a group chat session, adding or removing chat participants.

5. File Transfer : These APIs allow applications to send content between users – whether this is a picture or a document, and whether it is stored originally on the user’s device or elsewhere located on the Internet. They allow the recipient to receive information about the file separately from the file itself so the recipient can choose whether or not to accept the file.

6. User capabilities API : Enables the application to retrieve and amend system managed common capabilities of the user.

At this stage I will also put in a bit more about RCSe.

RCSe ( enhanced )

What is the difference between RCS-e and RCS?

RCS-enhanced (RCS-e) is the currently available version of RCS, developed to speed time to market. It offers enhanced features such as instant messaging, live video sharing, and file transfer across any device on any network operator

RCSe Features

  • Focus on advanced communication
    chat , file transfer , video sharing
  • Easy to Use
    zero touch from end user perspective
    minimal setup for subscribers
    Interoperability across devices , infrastructure components and service providers
  • Low barrier to entry / simplify networks
    Capability discovery using SIP OPTIONS
    Less impact on network elements and handset battery
    Lack of presence server reduces cost and time to market
  • Universal
    Allows implementation in lower range devices
    One common device specification

RCS-e Customer Value Proposition

New IP Communication Services, Profile Sharing, Native Device Integration


RCSe Characteristics

  • Dynamic Capability Discovery
  • User Perspective
  • network detects when user attaches with RCs e device
  • detection triggers network provisioning and client configuration
  • Security
    • authentication by network
    • SSO / GIBA in 3G coverage
    • SIP Digest in Wifi
    • Encryption for Wifi access
    • TLS for SIP and TCP media or IPsec
    • SRTP for UDP or IPsec
    • NAT traversal and Keep-alives

RCSe Releases

  • RCS-e (1.2.2) : RCS-e defined the initial IM/Chat functionality, File transfer, Image Share and Video share functionality over mobile packet switched networks, trusted and untrusted broadband networks.  It has gained wide acceptance in Europe as an initial deployment to be followed by future deployment phases.
  • RCS 5.0 is completely backward compatible with V1.2.2 specifications and adds new features such as best efforts IP video calls, Geo-location exchange, Social Presence, Standalone Messaging, and a network based blacklist. Global interoperability is a key aspect of these specifications, and as a result this version supports both OMA CPM and OMA SIMPLE IM, which are more widely requested in North America.
  • RCS 5.1 is also backward compatible with the V1.2.2 and 5.0 specifications.  It introduces additional new features such as Group Chat Store & Forward, File Transfer in Group Chat, File Transfer Store & Forward, and Best Effort Voice Call.

WebRTC/RCS Client

WebRTC Communication Client can meet the requiremnets of RCS and serve as a telco based platform for using TSP backened network to provide call and messaging to web users.

REST and SOAP Based Client
Integration with RCS features like MSRP, XCAP
Cloud Hosted Solution
Technical Expertise in HTML5,J2EE,SIP,WebRTC & IMS

WebRTC RCS Add-on Features

  1. Integrated charging: Users already have mobile service. WebRTC with session-based charging can be added onto existing service plans.
  2. Bundling: Messaging APIs can augment WebRTC apps with RCS and other messaging services developers
    Already know and implement.
  3. Reliability: QoS can provide assurance to users and priority services (enterprise, emergency, law enforcement, eHealth) that a WebRTC service will work as well as they need it to.

IMS integartion with RCS

RCS solution is required to bear its Net-Net session border controller (SBC) deployed at the access border of the SIP or IMS service network. SBC should provide critical control functions to deliver interactive communications services—voice, video and multimedia sessions—over the IP 3G RAN.

 Development paths

  1. RCS e-stack ( Orange Labs ) – installed and testing the originally present features with android 4.2.2
  2. RCS oenapi ( GSMA ) – registered with developer license to use the non commercially API’s , attempts to run the same

Challenges in RCS intergration
There are technical challenges and requirements for RCS IP interactive communications:

  • Service reach: Deliver service to handsets and clients on networks with differing or conflicting network characteristics such as IP addresses, signalling and transport protocols and encryption.
  • Security: Protect network resources from attack and overloads and ensure the privacy of communications.
  • Revenue and cost optimization: Protect against theft and abuse of service and capture session data for billing, traffic management and planning.
  • Regulatory compliance: Enable emergency service routing and lawful intercept to comply with government regulations for VoIP and interactive communications.
  • SLA assurance: Handle latency-sensitive traffic with high priority and maintain service availability during abnormal busy periods.

Monitizations with RCS

Standards-based network services, such as GSMA OneAPI and Rich Communications Suite (RCS), along with service provider’s OSS/BSS “back-end” capabilities enables numerous features that gives application developers the ability to monetize communications, context, commerce and control. They can deliver their services more intelligently, by providing them with real-time information such as Data Connection type, tariff, roaming status, and device capabilities integrate innovative API such as integral Payments Engine.

RealTime Notifications: RCS gives choice of notifications such as sms, email, and push notification messages via Android, Apple or MS notification service. Device-level ad targeting can be by
•Time of Day
•Frequency Capping
•Direction of Travel

Context based communications

The suite of rich communication services with context-based capabilities have numerous applications too. For example integrating directly into business applications such as Field Service Management. The advantages of contextual commnication communciations is that it interact more intelligently and effectively with their customers, for example delivering targeted, contextually relevant marketing promotions, offers and coupons. Some application of RCS from user front is that it allows the user to describe issues in detail by allowing multimedia formats in tickets or complaina or even request higher Quality of Service temporarily for the delivery of, for example, High-Definition video content.

Smart Self care application using RCS

One of the possible applications using RCS-based advanced communication features can be smart self-care. This can include platform support and API integration to check real-time consumption, validity alerts, payment history, check available promo/discounted plans & period as well as Pay-online using sms/MMS. Self-care is a popular concept among many service/product providers and is developed for mobile applications on smartphones, and web portals on the internet. This is similarly integrable via SMS or Toll-Free number using IVR/USSD.

Realted Terms


  • File Transfer using  MSRP (or Message Session Relay Protocol) is an instant messaging or chat protocol, defined by the IETF in RFC4975. MSRP is a text-based, connection-oriented protocol for exchanging  arbitrary (binary) MIME content, especially instant messages.


UC(Unified Communications) and Unified Communications and Collaborations ( UC&C )

The rapidly changing scene of telecoms operations brings to light many challenges faced by telcos and service providers as they cater to the end-users, with swift and innovative services, while at the same time keeping surcharge operational costs at bay. Today a customer(B2B) expects converged orchestrated harmonized applications bringing call control and customizing features, all under one roof.

What is Unified Communication ? 

Unified Communications solutions bring together voice, messaging, video, and desktop applications to enable companies to quickly adapt to market changes, increase productivity, improve competitive advantage and deliver a rich-media experience across any work space.

Unified Communications (1)
Unified Communications

Components of Unified Communications

The latest UCC solutions are based on open standards such as  SIMPLE/XMPP protocols or and REST webservices

  • Communications: Voice, data, and video
  •  Messaging: Voice, email, video, and IM
  •  Conferencing: Online, audio, and video
  •  Presence: IP phone, desktop clients, and call connectors
  •  Cloud / Virtualization : Network Provisioning , Virtualized Applications
  •  Mobility: Allows users to access UC&C services from any device, anywhere, and at any time.
  •  Integration with other business tools: CRM, ERP, and management tools.
  •  Security and compliance: Ensures that all communication and collaboration is secure and compliant with industry regulations and standards.

Video feature of UCC further has many aspects

  • Codecs : H323,H264,vp8/vp9 for video
  • Scalable Video Coding (SVC)
  • Usecase : Call , conference , Broadcasting , Livestreaming

Audio aspects

  • Codecs like OPUS, AAC
  • Service like : voice Mail , IVR , auto attendant with Voice XML

What is Unified communication and Collaboration ?

Currently the mode of communication across various users differs such as emails , SMS, VOIP call , GSM call, message on other platform etc .These random forms of communication cannot be tracked thus hamper fast decision making .



  • Voice and Video call support
    • Video conferencing up to 5 participants
    • Supplementary service support ( Call Hold, Call Wait)
    • Support orientation/ rotation changes
    • Tabular layout
    • SIP Preconditions
  • Integrate existing VAS and legacy services
  • IR.92/IR.94 support and IMS network Integration
  • User Capability exchange
  • UCS for Presence capabilities
    • Subscription and Publish during Login and Logout
  • Multiple Registerations
    • Device switching
    • Same MSISDN can be registered with Multiple devices
    • Configured with multiple accounts to receive and send messages.
  • Message over IP
    • Support for RCS 5.1 specific features (enhanced messaging/phonebook/call)
    • Message synchronization for all client’s registered UA
    • Scrollable list in chat window
    • Share files and chat at the same message box format
  • Visual Voice Mail
  • Cloud Address Book
    • Address Book synchronization
    • Synchronized contacts list
    • Edit Contacts and sync with all devices
    • Dialing from contacts, call logs
  • Geo location with map
    • Share your location with others as well as view theirs on a single map.

Additional Features

  1. Register with your credentials to explore new functionalities and VAS ( Value added Services).
  2. Make a Audio/Video call or chat with a friend- all at once with one click ( no bridge setup )
  3. Send and receive voicemails seamlessly.
  4. Send offline messages to your friends on Social networks (facebook, gmail, or yahoo) with just a click.
  5. Enhancement in GUI of the WebRTC client for better interaction with the user by adding Message Box, Drop down list on Call Control Box to initiate call directly.
  6. Oauth with Facebook and gmail enables logging in through thord party credentials too.
  7. Notifications for voicemails as per calendar.

Challenges with Unified Communications

  • Adds complexity in to already complex infrastructure
  • Lack of standardization
  • Organization Infrastructure and Bandwidth Limitations
  • Integration of services from different application platforms like emails
  • migrating existing communication infrastructure like desk phones
  • Interfacing of telephony applications with Business Applications such as CRMs

Types of UCC solutions

There exists broadly two types of UC&C solution – On-premise and cloud based . The fundamental difference is the location of the backend infrastructure supporting the communication system . Some more differences are outlined in table below:

On -premiseCloud Based
Mostly in SaaS nature ( software as a service )

– Hosted by the consumer / business unit itself
more customizability and flexibility
more investment and maintenance

Service provider offers his infrastructure to the consumer as a service bills monthly / yearly etc
quick setup
lower upfront payment
billing is either per user basis or on consumption .
– data is synced to cloud servers for storage and can be fetched from there when required such as cloud synced Call-logs or contact-book

Device / Platform Agnostic

The UCC clients are designed keeping mobility in mind . Thus UC  Solutions are made compatible with online provisioning / portal system , native mobile apps like android /ios , Desktop app for linux, mac, windows etc .

Unified Communications


UC&C models integrates with Enterprise and Customer Relation Management Systems (CRM). Therefore provides unified messaging across teamspace/workspace/workflow management systems . It is trackable and can be used for realtime notification and analytics .

SRS TFX service suite (2)
SRS TFX service suite
SRS TFX service suite (1)

This directly ensures boost in sales and profitability by quick communication between customers / partners / eco-system / sales-rep / developers / field agents and others part of the communication system.

SME adopt UCC solutions

SME ( Small and Medium Enterprises) are first to adopt UC&C due to absence of  already setup traditional communication infrastructure like PSTN lines , desktop phones , special handsets etc .

Factors that enable SMEs to adopt UC&C solution much faster and readily. :

  • quick setup
  • low budget of UC&C solutions
  •  BYOD ( Bring your Own Device ) to work

The advantages

  • (+) All information is stored in one place therefore easier to retrieve
  • (+) Increased Productivity
  • (+) Greater flexibility
  • (+) Faster Response and Information delivery

 Future of UCC

  1. Context Driven + Real Time Analytics
  2. Monitization by cross vertical integration
  3. Integration with IOT
  4. Automation for Billing and Operation – OSS/BSS
  5. Machine Learning
  6. Big Data Management

In conclusion UC&C is aimed at providing inter operable communications with ubiquitous coverage for applications and devices such as desktops , IP phones , smartphones, smart watches , kisosk etc. It means web, native apps and IP phones having the ability to create, share and participate in integrated multimedia ( like audio, video , desktop, files ) collaboration.