Live chat development for streams: architecture and implementation

Peak broadcasts expose a weak spot: messages are lost, and viewers leave for a competitor. We develop a live chat turnkey — from load analysis to handing over documentation to your team. The solution keeps latency within fractions of a second and preserves message delivery as concurrent viewers grow severalfold.

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a mobile application for FEEDME
    Development of a mobile application for FEEDME
    971
  • Development of a mobile application for XOOMER
    Development of a mobile application for XOOMER
    869
  • Development of a mobile application for RHL
    Development of a mobile application for RHL
    1289
  • Development of a mobile application for ZIPPY
    Development of a mobile application for ZIPPY
    1143
  • Development of a mobile application for Affhome
    Development of a mobile application for Affhome
    1076
  • Development of a mobile application for the FLAVORS company
    Development of a mobile application for the FLAVORS company
    677

Why live chat breaks under peak loads

Under peak load — during a giveaway, a sharp spike in viewers, or a mention from a major creator — the number of connections grows in seconds, while handler capacity stays the same.

The receive queue starts growing faster than it is drained: each new batch of messages fills the buffer, and it is serviced at the same rate. This is the first and main failure mechanism, from which the rest follow.

First, the viewer notices delivery latency: a message appears in the feed tens of seconds later, when the conversation has already moved on and replying to it is pointless.

Then message loss begins — when the buffer overflows, new batches simply displace old ones, and the feed becomes fragmented: replies hang without questions, and remarks do not line up with each other.

At the same time, connections drop. The client reconnects, each re-entry consumes new ingress resources, and the load grows avalanche-like: some viewers leave the broadcast precisely because they did not wait for an answer. For a stream, this is a direct loss of audience — people stay where they are heard.

In-stream moderation on such a profile stops keeping up.

Checking everything at entry is more expensive than selective processing, and moderators physically cannot see the entire volume — spam and abuse make it to air, and blocking comes too late, after they have already been read.

Each of these failures is the consequence of one architectural mistake: the chat was designed for average traffic, not for a spike. Let us break down how this is solved: where streams are separated, what limits the rate, and what happens to a message that did not get through.

Measurable effects: latency, delivery, downtime

Before the rework, peak on a stream looked predictable: delivery latency grew from fractions of a second to tens of seconds, some messages were lost when a viewer reconnected, and after a node failure chat history was restored over minutes.

For a platform, this is not cosmetic: the viewer writes into the void, moderation cannot see the flow, and the streamer loses audience response — the very reason chat exists.

Now we measure delivery latency not "on average," but at peak: the 95th percentile stays within one second with a tenfold increase in concurrent connections.

The share of lost messages is tracked as a separate metric — delivery confirmation reaches the client, so a connection drop does not turn into a missing remark: on reconnect, the viewer loads the missed segment of history.

Peak resilience comes not from server capacity but from architecture: the message log and subscription-based fan-out are separated via Redis, so a read spike does not block writes.

Recovery time after node failure is tens of seconds instead of minutes: subscribers switch to a standby node, history is raised from the log, and duplicates are cut by message identifier.

The entire failure class of "the message reached one but not the others" goes away.

Previously it occurred on every reconnect and was invisible in monitoring — now delivery is confirmed at the subscription level, and such cases surface as a metric, not as a support complaint.

Live chat implementation options: comparison of modes

Live chat operating modes differ not by interface but by who holds the persistent connection, stores message history, and is responsible for moderation. Delivery latency, behavior under peak loads at stream start, and the amount of work on your side depend on this.

Self-hosted infrastructure gives full control, but requires maintaining nodes with long-lived connections, a buffer for slow clients, and fault-tolerant exchange between nodes. A ready-made service removes this work, but ties you to third-party limits and rules.

A hybrid scheme is a compromise: transport is delegated to the service, while history and moderation rules remain with you.

Option When it fits Limitations
Self-hosted infrastructure Own moderation rules, history storage inside the perimeter, non-standard message logic Nodes with persistent connections, peaks at stream start, higher on-call requirements
Ready-made service Fast launch, streams up to several thousand viewers, no resources for operations Third-party limits on message rate and formats, history outside your perimeter
Hybrid scheme Need both launch speed and own rules: paid subscriptions, role-based access Failures are harder to localize: part of the chain is on the service side

Choosing a mode is choosing the responsibility boundary: what lives with you and what is delegated outside. Describe your broadcast scenario and load profile — we will return with an estimate and a plan for it.

Implementation stages: from load analysis to handover

The order of work is structured so that each architectural decision relies on numbers from the previous stage, not on assumptions. Below is the path from the first analysis to the moment when chat fully runs on your side.

  1. Load analysis. We calculate peak concurrency: how many viewers simultaneously keep chat open, how many messages per second arrive at stream peak, and what share of the audience writes rather than only reads. These numbers determine the solution class and capacity margin.
  2. Integration scheme. We determine where conversation state is stored and how chat connects to the player, authorization, moderation, and notifications. Separately, we record degradation behavior — what the viewer sees if some services are unavailable.
  3. Delivery core implementation. We build a delivery channel with ordering, retransmission on connection loss, and history recovery after reconnect — the conversation does not fragment.
  4. Load testing. We run scenarios through k6 on a profile captured from real broadcasts: delivery latency, share of lost messages, recovery time after disconnect, and moderation operation during a spike.
  5. Policy. We describe per-user limits and message rate, blocking rules, degradation schemes, and on-call actions during an incident.
  6. Handover. We provide source code, documentation, access, and train your team; we support the first releases until operations become routine.

What you receive: schemes, policies, regulations

The project lives not only during a broadcast. After handover, the client team has a set of artifacts it can use to evolve chat, onboard new engineers, and analyze incidents without contacting the code authors. Below is exactly what we hand over.

  • A live chat data flow diagram: the message path from client to viewers, buffering points, history service, moderation layer, and places where latency or loss is possible.
  • Configurations for all environments with comments: message rate limits, history size and retention, reconnect timeouts, queue parameters — and what happens when each value changes.
  • Access policies: viewer, moderator, streamer, and administrator roles, read and write rights, access grant and revoke procedure, restrictions on mass actions.
  • Data exchange documentation: message format, error codes, behavior on connection loss and reconnect, and rules for releasing new client versions.
  • Incident response procedures: what to do when latency grows, complaints spike, or the moderation service is unavailable, who makes the decision, and how to roll back a change.
  • Scaling scheme: how nodes are added for peak audience, where the bottleneck is, and by what signs it is visible in advance.
  • Instructions for moderators and support operators with typical scenarios and authority boundaries.
  • Report on behavior under load: scenarios in which chat remains operational, and thresholds for enabling protective mechanisms.

We keep documentation alongside the code and update it together with changes — it does not become outdated a month after launch. We test procedures in drills: we simulate connection loss and degradation so the on-call team acts according to instructions, not from memory.

Case: fivefold growth in concurrent viewers

Before the rework

On the Fanzone broadcast, live chat hit a ceiling: at peak concurrent viewers, remarks arrived with several seconds of latency and detached from the live moment.

About 3% of messages did not reach the audience, and after a node failure chat was brought up manually — tens of minutes without moderation and without history.

Complaints were reviewed in a separate export after the broadcast: there was no way to respond to a violation in real time.

What changed

Message ingestion and fan-out were split into independent layers: the stream first enters a queue, and subscribers receive it separately, so viewer growth no longer brings delivery down.

Moderation was embedded into the stream itself — filters and complaints are processed on the fly, not through deferred export. Message history is cached so that a new viewer's entry does not pull the entire chat archive.

Metrics after

Concurrent viewers on the same server fleet grew fivefold. Delivery latency dropped by about six times, message loss went from 3% to tenths of a percent, and recovery after node failure takes tens of seconds and is automatic.

The share of moderation complaints fell fourfold: violations leave the stream before viewers have time to see them.

What to do if the solution is already deployed and working

The replacement decision is not binary: in-house development and a ready-made service differ not entirely, but by boundary. Message exchange is broken down into layers — viewer authorization, ingestion, moderation, history storage, and subscriber delivery.

The first four layers are almost always portable as is, while delivery has to be rewritten: it is what hits resource limits as the audience grows.

Compatibility rests on the contract: the same message identifiers, event format, and role rights. The new transport is brought up alongside the old one, both write to shared history storage, and the client connects where the session router directs it.

As long as the event schema and response markup do not change, apps on viewers' devices do not need updating.

Migration proceeds in fractions, not as a single release: first 5–10% of channels, then comparison by three indicators — message delivery time, share lost at peak, and counter mismatch between buses.

If the metrics are worse, the share returns back with one configuration switch, without rolling back the app version and without stopping broadcasts.

What must be replaced is fan-out within a single process: with tens of thousands of concurrent viewers per channel, it hits memory and one core, so separate delivery nodes and distribution of subscriptions between them are needed.

A ready-made service handles this horizontally, but imposes restrictions on server-side moderation rules and custom message formats.

Therefore scaling is planned in advance: filters and history recording are moved to a separate layer so new platforms can be brought up without changes to app logic.

Technical doubts: security, moderation, scale

Live chat breaks not in a demo, but on moderation, access, and peak load. Below are answers to the engineering objections that most often arise when the client team starts validating the solution before launch.

How are spam and abuse filtered in the stream?

The filter sits at entry: rate limiting per user, device, and address, publication delay for fresh accounts, dictionaries, and a classifier on the stream.

Disputed messages go to a queue for manual review rather than being published immediately — the moderator processes them in batches and sees the dialogue context.

Who gets access to message history, and how?

History is written to separate storage with encryption and the retention period you set. Access is role-based: a moderator sees the dialogue but not personal data; exports and any archive access are logged with author and time.

What happens with multiple load growth?

Chat is split into independent streams by channel, so a spike on one stream does not affect the others. At peak, the queue buffers writes, while reads remain priority: history may load with delay, but the message stream itself does not break, and the viewer does not notice.

Can an erroneous moderator decision be rolled back?

Yes. Each moderator action is a separate record with author and reason; a block is removed in one click, and a deleted message is restored from the archive until the retention period expires. The client gets an auditable trace, not irreversible edits.

Let us discuss the task: what to send for an estimate and plan

The accuracy of a live chat estimate depends on how fully the scenarios and constraints are described. The more concrete the input data, the fewer assumptions in the work plan, and the more realistic the timelines.

  • Broadcast scenarios: how many streams run simultaneously, how many viewers are expected at peak, whether co-streams, paid rooms, direct messages, and reactions are needed.
  • Current scheme: what already works — player, authorization, message delivery, analytics; a description in words, data flow diagram, or admin screenshots will do.
  • Constraints: moderation rules, history retention depth, requirements for message ordering and delivery when a viewer's connection drops.
  • Access: test environments, accounts for message delivery services, sandboxes of payment and moderation systems — the things without which hypotheses cannot be tested on real data.
  • Load profile: expected peaks by hour, daily fluctuations, behavior on major event days, and what is considered unacceptable under overload.
  • Known issues: complaints about latency, lost or duplicated messages, failures during viewer influx — the most valuable inputs for architecture.

If some data is still unknown, it does not block the start: we will record assumptions separately and return with an estimate and work plan — by stages, with timelines and responsibility areas.