Building Real-Time Messaging System

Unveil how we developed a custom messaging solution app for education industries that boosted user engagement within the client’s application.

  • Cloud Development
  • EdTech
  • UK
Building Real-Time Messaging System

Our Customer

Developing a Scalable Real-Time Messaging System

LearnCube is an online education platform that enables anyone, anywhere to access world-class teachers. It is designed as a virtual classroom with live chat and other real-time collaborations like a whiteboard.

The platform is trusted by top language schools, tutoring companies & corporate trainers like Oxford University Press, Lingoda, and many others.

The Challenges

Controlling Soaring Operating Costs

Having experienced significant growth due to the COVID-caused shift to online education, the company faced the need to optimize costs and enhance customers’ experience. A significant share of expenses was paid to the commercial third-party solutions, including a real-time messaging and collaboration solution based on WebSocket.

The Solution

Messaging Solution App for Education Industry

LearnCube chose AWS as their cloud platform to become more agile, innovative, and efficient. Based on a variety of AWS tools, Romexsoft helped the customer achieve high scalability, reliability, latency, cost and security optimization.

The client’s main infrastructure is running in AWS Cloud. Having positive experience in collaboration with Romexsoft before, LearnCube asked us to come up with a solution that had to meet two major goals: less expenses compared to the existing solution and high reliability. To resolve this issue our company suggested implementing a real-time messaging system based on API Gateway with WebSockets, Lambda, and ElastiCache services.

Amazon API Gateway is a fully managed service that handles APIs at any scale. Also, it supports two-way WebSocket APIs. Such events like WebSocket connect and disconnect are provided out of the box. So, the solution works in the following way:

  • WebSocket connection is initiated from the client-side via Vue.js and passed through API Gateway to the written in Node.js AWS Lambda function that stores connection information like connectionId, userId, and classRoomId in the AWS ElastiCache. API Gateway securely keeps the WebSocket connection in its pool.
  • The client sends a message through the opened WebSocket connection to API Gateway’s onMessage endpoint. Another AWS Lambda handler gets classRoomId from the payload, gets all stored in ElastiCache connections with this classRoomId, and performs broadcast of message body using AWS.ApiGatewayManagementApi SDK.
  • When the client exits the classroom or class is finished the disconnect event is sent to API Gatewaydisconnect endpoint. AWS Lambda handler gets message info and removes it from ElastiCache. API Gateway removes the connection from its pool.

Custom AWS Lambda authorizer is used to initiate WebSocket connections from authenticated users only. AWS ElastiCache has primary and read replicas in different availability zones to support high availability and performance. Also, ElastiCache is located in the VPC in a private subnet. So Lambda handlers are also placed in the VPC and NAT Gateway is set up to provide an external communication for AWS.ApiGatewayManagementApi SDK to broadcast messages. All Lambdas and API Gateway metrics are recorded in AWS CloudWatch logs.

Real-Time Messaging System AWS Architecture Diagram

AWS Architecture Diagram: Real-Time Messaging System for E-learning SaaS

Amazon Web Services Utilized
AWS Lambda icon
Lambda
Amazon ElastiCache icon
ElastiCache
Amazon Virtual Private Cloud icon
Virtual rivate Cloud (VPC)
Amazon API Gateway icon
API Gateway
Amazon CloudWatch icon
CloudWatch
AWS Identity and Access Management icon
Identity and Access Management (IAM)

Verified by AWS

This case study is validated by AWS. Experts and professional auditors from AWS reviewed this case study and verified that we, Romexsoft, have built a functional infrastructure and efficient cloud solution.

It showcases the value that Romexsoft, being a certified AWS Advanced Tier Services Partner, delivers cloud solutions according to AWS standards and best practices.

Check out Romexsoft’s profile at AWS Partner Network.

The Results

Cost Reduction and Enhanced Reliability

  • Decreased monthly costs for the real-time messaging app almost 3x times which was a sizable monetary value.
  • High reliability and guarantee of messages delivery to the end client.
  • Solution transparency and observability via CloudWatch logs and dashboards.

Why Romexsoft

Partner With Us to Build a Messaging System

Romexsoft is an AWS-certified Consulting Partner, trusted Software Development Company and Managed Service Provider, founded in 2004. We help customer-centric companies build, run, and optimize their cloud systems on AWS with creative, stable, and cost-efficient solutions.

Our key values

  • Delivery of quality solutions
  • Customer satisfaction
  • Long-term partnership

We have successfully delivered 100+ projects and have a proven track record in FinTech, HealthCare, AdTech, and Media industries.

Romexsoft possesses a 5-star rating on Clutch due to its strong expertise, responsiveness, and commitment. 60% of our clients have been working with us for over 4 years.

Frequently Asked Questions

How is the connection state recovered after redeployments or cold starts?

The connection state is not kept in the compute layer. WebSocket connections remain open in API Gateway, while connection and room state is stored externally. After redeployments or cold starts, new handlers continue using that store. If the state is missing or expired, clients reconnect, re-authenticate, and re-register their room membership to restore normal operation.

Can the messaging layer be scaled independently from the rest of the application?

Yes. The messaging layer scales independently because WebSocket connections are handled by API Gateway, message processing scales via Lambda concurrency, and connection state is managed in ElastiCache. As long as it doesn’t rely on core application services at runtime, the rest of the application does not need to scale with it.

How are compromised user sessions detected and revoked in real time?

Compromised sessions are detected through identity and behaviour signals, then revoked centrally. Once flagged, the session is added to a revocation list, incoming messages are blocked, and the WebSocket connection is force-closed via the API Gateway management API. Reconnection is allowed only after re-authentication.

How predictable are costs at scale with high message frequency?

Costs are predictable but message-driven. At scale, spend grows mainly with the number of active connections and messages sent, not users. API Gateway charges per connection minute and per message, Lambda per invocation, and the state store by capacity. With known session lengths and average message rates, costs can be modelled accurately; unpredictability usually comes only from unexpected message spikes or broadcast-heavy use cases.

Modernize Your Software With New Features.
Talk to Our Engineering Team

    Contact Romexsoft
    Get in touch with AWS certified experts!