In brief
An operator's network constantly produces events: alarms, performance counters, usage records, and session state changes. Apache Kafka serves as a durable, scalable log of these events, from which OSS, billing, analytics, and customer service read independently. The most important design decisions are the split into topics and partitions, the choice of event key, retention time, the schema and its versions, and how late and repeated events are handled. They determine whether the processing can later be scaled and tested.
What events the network produces
An operator's network is thousands of elements, each of which reports something. The most common kinds of events:
| Kind | Example | Who uses it |
|---|---|---|
| Alarms | link loss, overheating, a card restart in a device | network operations center, OSS |
| Performance counters | base station load, latency, share of failed calls | network planning, quality monitoring |
| Usage records | a data session, a call, an SMS | mediation and billing |
| Session events | device registration, session setup and teardown | analytics, fraud detection |
| Configuration changes | a new software version, a parameter change | audit, root cause analysis |
Traditionally each of these streams flowed along its own route: alarms to the monitoring system, counters to files collected every quarter of an hour, usage records to mediation. A shared event platform lets you use the same data in many places without building more point-to-point connections.
Why Kafka works at an operator
Kafka is not an ordinary queue. It is a distributed log: events are written in order and kept for a set time, and each consumer reads them at its own pace and remembers where it left off. This gives traits that matter to an operator:
- Many independent consumers. The same usage records are read by billing, analytics, and the fraud detection system, and a failure of one does not hold up the others.
- Replay of data. After a processing error, you can read the events again from a chosen point.
- Scaling through partitions. A topic is divided into partitions, which many instances of a consumer process in parallel.
- Failure resilience. Partitions are replicated across several servers.
We describe the first decisions when adopting Kafka more broadly in the article Apache Kafka in the enterprise, and the choice between an integration bus and events in the article ESB or event-driven architecture.
Topics, keys, and schemas
Most problems with streams originate in decisions made at the start.
Topics by domain, not by source. A topic “network-alarms” is better than a separate topic for each device vendor, because the consumer does not need to know where the event came from.
The key determines ordering. Kafka guarantees order only within a single partition, and the partition is chosen by the key. When the key is the network element identifier, all alarms from one device arrive in order. When the key is the subscriber identifier, that subscriber's sessions arrive in order.
A versioned schema. Each event has a described format, for example in Avro or Protobuf, stored in a schema registry with compatibility rules. A producer can add a field, but cannot change the meaning of an existing one without a new version.
Personal data in events. A phone number and a device's location are personal data. It is worth deciding from the start which topics contain them, who has access, how long they are kept, and where a surrogate identifier (a pseudonym) is enough.
Stream processing: typical uses
On network events, an operator builds processing that works in seconds, not in reports from the previous day:
- Alarm correlation. A cut fiber cable produces hundreds of alarms from the devices behind it. The system groups them into one event with a root cause, and the on-duty engineer gets one ticket instead of hundreds.
- Anomaly detection in counters. A sudden rise in the share of failed calls in one region triggers an alarm before customers call.
- Information for the customer. An outage event goes to the IVR and the app, which warn the customer, as we describe in the article CRM, IVR, and automation of a telecom operator's customer service.
- Usage control. Usage records in near real time make it possible to warn the customer before they exceed a bundle.
Stream libraries and engines are used for this kind of processing, for example Kafka Streams or Apache Flink. In design, you need to distinguish event time (when something happened in the network) from processing time (when the event arrived). Counters from a remote node can arrive late, so time windows need a rule for late events.
Duplicates, delays, and testing
In distributed systems, an event can arrive twice, for example after being resent by the producer or after a consumer restart. Kafka offers an idempotent producer and transactions, which help avoid duplicates within the platform itself, but a consumer that writes its result to another system should still be idempotent. For billing it is a matter of money: a record counted twice means a wrong invoice.
Stream testing is worth basing on several fixed cases:
- Replaying recorded traffic from a real day, preserving the time intervals, in a test environment.
- Out-of-order and late events relative to the time window.
- Duplicates sent on purpose, and checking that the result does not change.
- Broker and consumer failure during processing, and measuring the recovery time.
- Consumer lag at peak load, for example during a major outage when alarms arrive in a sudden surge.
- Schema compatibility in the CI pipeline, before a new producer version reaches production.
Consumer lag and processing times are among the standing monitoring indicators of the platform, described in the article Observability. An example of moving from an integration bus to a Kafka event platform, though at a bank, is described in the scenario Replacing the ESB with a Kafka event platform. Integrations, Kafka, and performance testing are carried out by B2Bnetwork engineers (What we do).
Questions and answers
Does Kafka replace the network monitoring system?
No. The network monitoring system still collects alarms from devices and shows them to the on-duty staff. Kafka is the layer through which events reach many consumers at once: OSS, analytics, customer service, and billing. Thanks to it, a new consumer does not require a new connection to every system in the network.
How long should events be kept in Kafka?
As long as needed to replay processing after an error and to serve consumers that read with a delay, usually from a few days to a few weeks. For long-term storage and historical analysis, events are copied to a data warehouse or a data store. For topics with personal data, the retention time also follows data protection rules.
How do you choose an event key in a stream from the network?
According to the order in which events must be processed. For alarms and counters, the key is usually the network element identifier, for usage records the subscriber or session identifier. You also need to check the key distribution: one very active network element must not overload a single partition while the others sit empty.
Does stream processing replace batch processing in billing?
Usually not entirely. Streams work well for balance checks, bundle overrun warnings, and fraud detection. The invoice for a cycle is still produced in a billing run, which has to account for corrections and late records. The two approaches work side by side on the same data.