Types and architectural styles API
published: ⏰ 80I decided to gather everything I’ve learned about the API from various posts into a single article, cutting out all the unnecessary fluff. I’ll also leave a sort of cheat sheet for myself.
General Information
An API (Application Programming Interface) is a set of rules, protocols, and formats that allow different software components to interact with each other. The choice of API type is determined by requirements for performance, flexibility, compatibility, security, and ease of development.
APIs are treated more as conceptual specifications that may have one or more different implementations. For example, AMQP is treated as a message queue, not a specific implementation like RabbitMQ or Apache Artemis. I’ll skip legacy and exotic APIs (CORBA, WinAPI, XML-RPC, SOAP over JMS, and others), as I’m not sure anyone remembers or uses them now. Some I’ve simply skipped (for example, Short Polling).
| API | Brief Description |
|---|---|
| REST | An architectural style for building web services that uses standard HTTP methods (GET, POST, PUT, DELETE) and a resource-oriented approach. |
| SOAP | A structured XML messaging protocol that supports strong schemas (WSDL) and advanced security features (WS-Security). |
| GraphQL | An API query language that allows a client to request exactly the data they need and receive it in a single response. |
| gRPC | A high-performance RPC framework from Google that uses Protocol Buffers and HTTP/2 for binary data exchange. |
| MCP | An open standard designed to unify interactions between artificial intelligence models (e.g., large language models, LLMs) and external tools, data, and services. |
| WebSocket | A two-way, full-duplex channel over a single TCP connection, allowing the server to initiate real-time data transfers. |
| JSON-RPC | A simple remote procedure call protocol that uses JSON to encode requests and responses. |
| OData | A REST-based data access protocol that enables querying, filtering, sorting, and pagination via URL parameters. |
| SSE | Unidirectional data flow from server to client over a regular HTTP connection. |
| Long Polling | A technique for simulating a push connection: the client sends a request, the server holds it until new data becomes available, then responds. |
| STOMP | A simple text-based protocol for exchanging messages over brokers (e.g., WebSocket). |
| Webhooks | HTTP callbacks automatically sent by the server when a specific event occurs. |
| MQTT | A lightweight publish/subscribe protocol for transmitting telemetry and IoT device data in small packets. |
| AMQP | A messaging protocol with guaranteed delivery, supporting queuing, routing, and transactions. |
| EDI | Electronic Data Interchange, a standardized format for transferring business documents between companies. |
| CoAP | A protocol for resource-constrained devices that operates over UDP and supports REST-like requests. |
| WebRTC DataChannel | A peer-to-peer data channel for transferring arbitrary data (not just audio/video) between browsers using DTLS/SCTP. |
REST
The REST (Representational State Transfer) protocol is not a protocol, but an architectural style for designing web service APIs. A RESTful API is a set of rules and constraints that define how a client can interact with a server. A RESTful API uses standard HTTP methods (GET, POST, PUT, etc.) to interact with resources. Various data formats, such as JSON, XML, and others, can be used.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP/HTTPS |
| Formats | Any: JSON, XML, YAML, application/x-www-form-urlencoded, multipart/form-data, binary |
| Versioning | - URI-version: /v1/users- Header: X-API-Version: 1- Request Parameter: ?version=1- Accept-header: application/vnd.myapi.v1+json |
| Caching | HTTP Headers (Cache-Control, ETag, Expires, Last-Modified, Vary, Cache-Tag) |
| Documentation | - OpenAPI/Swagger (most popular) - Alternatives: API Blueprint, RAML, Postman Collections, AsyncAPI (for event APIs). |
| Security | HTTPS, OAuth 2.0 (Authorization Code, Client Credentials, PKCE), JWT, API keys, HMAC signatures, Mutual TLS, OpenID Connect. |
| RPC Support | No, but RPC-like calls can be implemented (e.g. POST /rpc with JSON payload). |
| Error Handling | HTTP statuses (4xx, 5xx), headers (X-Error), error body in JSON format (RFC 7807 Problem Details). |
| Client generation | OpenAPI Generator, Swagger Codegen, NSwag, AutoRest, APIMATIC, Postman. |
| Strong typing | The protocol itself does not impose typing, but it can be provided by external schemas and tools JSON-Schema / OpenAPI |
| Bidirectionality | Classic REST is a request/response system, so the “back channel” is implemented using separate mechanisms: Webhooks, Long Polling, Server-Sent Events (SSE) |
| Real-Time Exchange | REST itself is not designed for “real-time,” but is often combined with other technologies: SSE, WebSocket, HTTP/2 Server Push, Polling / Long Polling |
| Scalability | Due to the lack of state storage, it can easily scale horizontally. |
Key Concepts
- Resources. Any data accessible through the API (e.g., user, order, image). Each resource has a unique identifier (
URI - Uniform Resource Identifier), for example,
/api/orders/123. - Client. The initiator of interaction, sending requests to resources (e.g., a web browser or mobile app).
- Server. The system that stores resources, processes client requests, and returns responses.
- HTTP Methods/Verbs. Standard actions that a client can perform on resources. The main ones are:
GET: Retrieving (reading) resource data.POST: Creating a new resource.PUT: Updating (completely replacing) an existing resource.DELETE: Delete a resource.
- Resource Representation. The format in which data is transferred between the client and server (e.g., JSON, XML, HTML). JSON is most commonly used.
- Client-Server Model. The client and server are independent of each other. The client is responsible for the user interface and request logic, while the server is responsible for storing and processing data.
- Stateless. Each request from the client to the server must contain all the information necessary for its processing. The server does not store information about previous requests or the client’s session state between requests. This ensures scalability and reliability of the system.
- Cacheable. Server responses can be marked as cacheable, allowing clients or intermediaries to store and reuse them, reducing the load on the network and the server.
Applicability
- Web and Mobile Applications. The REST API enables interaction between the client-side (frontend on a web page or mobile app) and the server-side (backend), allowing for the retrieval, sending, and modification of data (e.g., news feeds, user profiles, product data).
- Microservices Architecture. In modern complex applications, broken down into many small, independent services ( microservices), the REST API is used as a standard mechanism for interaction.
- Third-Party Service Integration. Most large online platforms provide public REST APIs for integration with other applications. Examples include payment systems, social networks, mapping services, and others.
- Cloud Computing. REST plays a key role in managing cloud infrastructure and resources. APIs are used for programmatic management of virtual machines, data storage, and other cloud services (e.g., AWS, Azure, Google Cloud).
- Internet of Things (IoT). IoT devices (sensors, smart home appliances) often use REST APIs to exchange data with central servers, enabling remote monitoring and management.
- Access to public data. Government, scientific, and commercial organizations provide access to open data (e.g., weather, exchange rates, statistics) via REST APIs, allowing third-party developers to use this data in their applications.
- Internal integration of enterprise systems. Within companies, REST APIs are used to synchronize data between various information systems, such as CRM, ERP, and other internal applications.
Pros and Cons
| Pros | Cons |
|---|---|
| Simplicity and ease of learning: REST is based on standard, well-known HTTP protocols and methods (GET, POST, PUT, DELETE), making it intuitive for developers and lowering the entry barrier. | Redundancy of requests for complex data (Over-fetching/Under-fetching): Sometimes, retrieving complete information about a complex object requires making multiple separate REST requests to different resources. This can slow down the client and lead to excessive traffic (a problem often solved with GraphQL). |
| Scalability: The “stateless” principle means that the server does not need to store client session information between requests. This allows for easy load balancing across multiple servers and horizontal scaling. | Lack of a strict standard: REST is an architectural style with a set of guidelines, not a strict protocol (like SOAP). This can lead to differences in API implementation between different developers, which can sometimes make integration difficult. |
| Client-Server Independence: A clear separation of concerns allows client and server development teams to work in parallel and independently, while adhering to the agreed-upon API contract. | Challenge of Working with Real-Time Streaming Data: REST is based on a request-response model. To establish a persistent two-way connection or stream real-time data (for example, for chats or online games), additional technologies such as WebSockets must be used. |
| Caching: Using standard HTTP caching mechanisms (especially for GET requests) can reduce roundtrips to the server, reduce network load, and improve performance. | Potential vulnerability due to openness: Using standard HTTP methods and URLs can make REST APIs more predictable to attackers, requiring careful consideration of security, authentication, and authorization. |
| Data format flexibility: REST is not tied to any specific data format. While JSON has become the de facto standard, XML, YAML, or any other format can be used. | |
| Wide support: REST is supported by virtually all programming languages, frameworks, and development tools. |
SOAP
Simple Object Access Protocol (SOAP) is an XML-based messaging protocol designed for exchanging structured data between services or applications. It defines message formats and processing rules, making it a good choice for mission-critical applications where strong typing, predictability, and reliable message delivery are essential. Support for WS-Security and other extensions make it a suitable choice for services requiring high levels of security and data consistency.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP/HTTPS, SMTP, JMS, TCP, UDP (via SOAP over UDP), etc. |
| Formats | XML (the primary format; SOAP 1.2 provides the ability to bind to JSON via SOAP-Binding) |
| Versioning | Via namespace in WSDL, versions in the URL endpoint, SOAPAction headers, and/or individual service versions. |
| Caching | No, only at the application level (client/server). WSDL caching can be used. |
| Documentation | WSDL as a service description |
| Security | TLS/HTTPS (transport layer), WS-Security (signature, encryption, etc.). |
| RPC Support | RPC-style and Document-style (both supported). |
| Fault Transport | SOAP Fault – the <Fault> element in the SOAP-Envelope, containing <Code>, <Reason>, <Detail>, and (optionally) <Node>, <Role>. |
| Client Generation | wsimport (JAX-WS, Java), wsdl2java (Apache Axis2, Apache CXF), svcutil (WCF/.NET), SoapUI (testing and template generation). |
| Strong Typing | XML Schema (XSD) defines the types of all message elements. When importing WSDL, the client/server generates contract classes, allowing type checking at compile time. |
| Bidirectionality | SOAP supports request-response (classic) and asynchronous callbacks via WS-Addressing/WS-Callback (e.g., WCF Duplex) or WS-Eventing. |
| Real-Time Exchange | For real-time scenarios, WS-ReliableMessaging (guaranteed delivery) and WS-Eventing/WS-Notification (subscription-notification) are used. |
| Scalability | Scalable due to the absence of state and the ability to place a load balancer in front of a pool of servers. |
Key Concepts
- Message Format. SOAP messages are transmitted in XML format, which has a strict structure (envelope, header, body).
- Transport Protocol. SOAP can run on top of various application-layer protocols, such as HTTP, HTTPS, SMTP (email), and others, although HTTP is the most commonly used.
- Interoperability in Heterogeneous Environments. It is designed to ensure interoperability between various applications built on different platforms and programming languages.
- Rigor and Standardization. SOAP is highly standardized and offers advanced features such as built-in security ( WS-Security), reliable message delivery, and transaction support, making it the preferred choice for large enterprise systems (e.g., banking or government agencies) with high reliability and security requirements.
- WSDL. SOAP uses a special language called WSDL (Web Services Description Language) to define the “contract” ( available functions, data formats) between the client and server.
Applicability
- Financial Sector and Banking Systems. SOAP is widely used for transaction processing, integrating various banking systems, and ensuring secure financial data exchange where message delivery guarantees and a high level of security are critical (using the WS-Security and WS-AtomicTransaction standards).
- Healthcare. In healthcare information systems, SOAP is used to securely exchange sensitive patient data ( electronic health records), while adhering to strict regulatory requirements and standards (e.g., HIPAA in the US).
- Public Sector and Large Enterprises. Used to integrate complex, heterogeneous information systems within government agencies or large corporations where a formal interoperability contract (WSDL) and reliability are required.
- Telecommunications. Used in billing systems and other internal services of telecom operators.
- Legacy System Integration. SOAP often serves as a bridge for connecting legacy but still functional systems to modern applications, as it supports many different transport protocols beyond HTTP (e.g., SMTP, IBM MQ).
Pros and cons
| Pros | Cons |
|---|---|
| Language and Platform Independence. SOAP allows applications written in different programming languages and running on different platforms to interoperate because messages are transmitted in a standardized XML format. | Complexity. SOAP is more complex to learn and use than the simpler REST. Messages are in a verbose XML format, making them difficult to read and debug manually. |
| High Security. The protocol includes built-in security features such as WS-Security, which provides message-level encryption and authentication, which is critical for banking and enterprise systems. | High Bandwidth and Memory Requirements. Using XML messages increases the volume of data transferred and, as a result, network bandwidth and application memory requirements, making systems more expensive and difficult to scale. |
| Reliability and Transactions. SOAP supports complex operations with reliable message delivery and transaction management, which are key for mission-critical business processes. | Development Burden. Working with SOAP requires specialized tools and libraries, which can increase development time and costs compared to using native HTTP capabilities, as in REST. |
| Strong Standardization (WSDL). The contract between the client and server is clearly defined in the Web Services Description Language (WSDL), simplifying automatic code generation and testing (for example, with tools like SoapUI). | Need for Statefulness (Sometimes). Although the SOAP API may be stateless, some implementations require statefulness between requests, which increases the server load. |
| Flexibility in Transport Protocol Choice. Although HTTP is most commonly used, SOAP can work with a variety of application-layer protocols, including SMTP, FTP, and HTTPS. |
GraphQL
GraphQL is an API query language and server-side runtime that allows clients to retrieve exactly the data they need in a single request. It was developed as a more flexible and efficient alternative to traditional API building approaches such as REST.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP (POST for most requests, GET for simple read requests) and WebSocket (for subscriptions). |
| Formats | The request body is JSON, but a URL-encoded string is also allowed (for GET). The response is always JSON. |
| Versioning | No, schema evolution occurs through the addition/deprecation of fields and compatibility agreements (Schema Design → Versioning). |
| Caching | - Apollo Client, Relay, Urql, and others automatically cache query results. - HTTP Cache: GET requests can be cached by proxies (with the right headers). - Server: Result caching (e.g., DataLoader, Redis) is optional. |
| Documentation | SDL (Schema Definition Language) – a machine-readable schema from which introspective queries are generated. |
| Security | HTTPS, OAuth 2.0, JWT, API keys, session cookies, etc. |
| RPC Support | No, but mutation operations can perform actions similar to RPC calls. |
| Error Handling | Errors are returned in the errors field of the JSON response. |
| Client Generation | graphql-code-generator, Apollo Android/iOS SDK, Relay Compiler, urql-codegen |
| Subscriptions | Supported via WebSocket |
| Strong typing | The schema is described by GraphQL types (Scalar, Object, Interface, Union, Enum, Input). Each request is type-checked by the server – you can’t request a field that isn’t declared, and you can’t pass a variable of the wrong type. |
| Bidirectionality | GraphQL itself is a one-way request-response, but subscriptions implement bidirectional communication: the client opens a WebSocket connection, and the server pushes new data at any time. |
| Real-time exchange | Implemented via subscriptions on top of WebSocket. |
| Scalability | - Schema partitioning – microservices can “federate” their schemas (Apollo Federation, GraphQL Mesh). - Batch loading – DataLoader groups database/REST queries, reducing round trips. - Caching – query level (Apollo Server + CacheControl). - Complexity limiting – queryDepth, costAnalysis protect against DoS requests. |
Applicability
- Mobile Applications. Using GraphQL allows mobile clients to request only the data they need, which is critical for saving data and improving performance in bandwidth-constrained environments. This helps avoid the problem of over-fetching data, which is common in REST APIs.
- Complex User Interfaces and Data Aggregation. In web applications with complex UIs (e.g., dashboards, online catalogs, admin panels), GraphQL simplifies retrieving data from multiple different sources or microservices in a single request. This eliminates the need to make multiple sequential REST requests.
- Microservice Architecture. GraphQL serves as a powerful glue layer (single point of entry) for unifying data from disparate microservices, databases, and legacy REST APIs, providing clients with a single, consistent API.
- Rapidly Evolving Projects. GraphQL allows client applications to evolve independently of the backend. The client can request new fields as soon as they appear in the schema, without having to change server-side code or create new endpoints, as is often the case with REST APIs.
- CMS and content-oriented websites. For content management systems where different pages or components require different sets of data, GraphQL offers high flexibility and efficiency.
Key concepts
- Single endpoint. Unlike REST, which often uses multiple URLs for different resources, a GraphQL service typically exposes a single HTTP endpoint (usually /graphql) that handles all requests.
- Strongly typed schema. The GraphQL API is based on a schema defined using the Schema Definition Language (SDL). This schema acts as a formal contract between the client and server, defining the available data types, fields, and relationships, enabling automatic validation and documentation (introspection).
- Client-Defined Responses. Clients send a request that reflects the form of the required data. The server then returns a JSON response with exactly the same structure, ensuring that the client receives only the required information.
- Resolvers. On the server side, resolver functions define how to retrieve or calculate data for each schema field
using existing data sources such as databases or other REST APIs. Operations: GraphQL supports three main types of
operations:
- Queries – for reading or retrieving data (similar to GET in REST).
- Mutations – for creating, updating, or deleting data (similar to POST, PUT, DELETE in REST).
- Subscriptions – for updating data in real time, typically using WebSockets.
Pros and Cons
| Pros | |
|---|---|
| Precise data fetching (solves the problem of “over-fetching” and “under-fetching”). Clients can request exactly the data they need, and nothing more. This reduces bandwidth and improves performance, especially in mobile apps. | Caching complexity. REST APIs use standard URL-based HTTP caching. In GraphQL, all requests are typically sent through a single POST endpoint, /graphql, making traditional HTTP caching ineffective. Special client-side solutions (e.g., Apollo Cache) or server-side solutions are required. |
| Single request instead of many. Instead of sending multiple requests to different endpoints, as in a REST API, a client can retrieve data from multiple sources in a single request. | Steep learning curve. Developing and maintaining a GraphQL server, including schema design and writing resolvers, requires learning new concepts and tools, which can be more challenging than creating a simple REST API. |
| Lack of API versioning. GraphQL schema evolution occurs in an evolutionary manner. Fields can be marked as deprecated, but old queries continue to work, eliminating the need to create new API versions (v1, v2, etc.). | Potential server performance and security issues. Deeply nested or overly complex queries from a client can create significant load on the server (denial of service attacks, DoS). Additional security measures, such as limiting the depth of queries and their rate of execution (rate limiting), are required. |
| Powerful Type System and Self-Documentation. GraphQL uses a strong type system (Schema Definition Language, SDL) that provides a clear description of the available data. This enables automatic documentation generation and query validation. | Error Handling Issues. Error handling in GraphQL is not as standardized as in REST. An HTTP status of 200 OK is always returned, and error information is contained in the response body, which can complicate client-side logic. |
| Simplifying Data Aggregation. GraphQL allows you to combine data from different microservices or databases into a single, consistent API. | Additional Tooling. While GraphQL provides flexibility, it often requires additional client libraries (e.g., Apollo Client, Relay) to manage data, caching, and application state. |
gRPC
gRPC Remote Procedure Calls (gRPC) is a high-performance open-source framework designed for efficient communication between services in distributed systems. It allows a client application to directly call methods of a server application on another computer, as if they were local functions.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP/2 (provides multiplexing, priorities, and bidirectional streams). |
| Formats | Protocol Buffers (protobuf) – a compact binary format described in .proto files (see protobuf.dev). |
| Versioning | Implemented by changing the package/service name in .proto files, as well as through option java_package, option go_package, etc. |
| Caching | None. Caching is implemented at the application level if necessary. |
| Documentation | proto3 |
| Security | SSL/TLS (default), Google ALTS, OAuth 2.0 authentication, JWT, mTLS, and more. |
| RPC Support | A full-fledged RPC framework: supports unary calls, server- and client-side streaming, and bidirectional streaming. |
| Error Handling | gRPC Status Codes (see status-codes) – a set of codes mapped to HTTP statuses and error descriptions. |
| Client Generation | Via protoc + the appropriate plugin (grpc_cpp_plugin, grpc_java_plugin, grpc_node_plugin, grpc_go_plugin, etc.). Example for Go. |
| Strong Typing | The service and messages are described in .proto files, where each field has an explicitly defined type (int32, string, enum, message, etc.). After compilation, type-safe client and server classes are generated for the selected language, allowing the compiler to detect inconsistencies at build time. |
| Bidirectionality | gRPC uses HTTP/2 streams, allowing requests to be sent and responses to be received simultaneously. This is implemented as bidirectional streaming—both sides can write to the stream independently. |
| Real-time exchange | Thanks to its streaming support, gRPC is suitable for low-latency scenarios: telemetry, video broadcasting, online gaming, financial quotes, etc. |
| Scalability | HTTP/2 + binary protocol → low overhead, efficient connection utilization. gRPC easily integrates with modern orchestrators (Kubernetes, Istio) and service meshes, supports load balancing (client-side, server-side) and service discovery via DNS, xDS, Consul, and others. |
Applicability
- Microservice Architecture. gRPC is ideal for communication between internal services in a complex microservice architecture due to its high speed and efficiency, based on HTTP/2 and Protocol Buffers. Large companies use gRPC to manage communications between their numerous services.
- High-Load Systems and Real-Time Applications. gRPC provides low latency and high throughput, making it an excellent choice for systems that handle large volumes of data and require fast processing (e.g., analytics, AI, cloud computing).
- Bidirectional Streaming. gRPC supports various streaming types (server-side, client-side, and bidirectional), allowing for efficient data exchange without the need to establish multiple connections. This is useful for applications that require persistent connections and fast messaging, such as chat rooms or monitoring systems.
- Internet of Things (IoT). For low-power devices with limited communication bandwidth, gRPC offers an efficient data transfer mechanism thanks to its compact binary format, Protocol Buffers.
- Heterogeneous Environments. gRPC generates client and server code for a variety of programming languages, simplifying the integration of services written on different platforms (e.g., Java, Go, Python, C#).
- Mobile Application Development. gRPC’s high performance and low resource consumption make it an attractive communication protocol between mobile clients and servers.
- Distributed Databases. Some distributed databases, such as CockroachDB, use gRPC for internal communication between nodes.
Key Concepts
- Protocol Buffers (Protobuf). Used as the interface description language (IDL) and the default binary data serialization format. This ensures compact message sizes and high processing speed compared to text-based formats such as JSON or XML.
- HTTP/2. Used as the transport protocol. HTTP/2 provides a number of advantages, including multiplexing (sending multiple requests simultaneously over a single connection), header compression, and support for full-duplex bidirectional streaming.
- Automatic Code Generation: Based on the service definition file (.proto), the gRPC compiler generates strongly typed client and server code (stubs) for various programming languages, simplifying development and integration.
Additionally:
- gRPC-Web – an adapter that allows you to call gRPC from a browser over regular HTTP/1.1.
- Interceptors – allow you to implement logging, authentication, and tracing.
Pros and Cons
| Pros | Cons |
|---|---|
| High Performance. gRPC uses HTTP/2 and the Protocol Buffers (Protobuf) binary data serialization format, providing low latency and high throughput, often 7-10 times faster than REST with JSON for the same tasks. | Debugging Difficulty. The Protobuf binary format is not human-readable. This makes debugging requests and responses difficult in a browser or with standard tools, requiring specialized software. |
| Network Efficiency. HTTP/2 supports multiplexing (sending multiple requests and responses over a single TCP connection), eliminating the overhead of establishing and tearing down connections. Protobuf’s compact binary format also saves bandwidth. | Limited Browser Support. gRPC is based on HTTP/2, which is not fully supported directly by all web browsers. Using gRPC in web applications typically requires proxy servers (such as gRPC-Web). |
| Strong Typing and Reliability. Using Protocol Buffers ensures strongly typed contracts between the client and server. This allows errors to be detected at compile time rather than runtime, increasing system reliability. | Steep Learning Curve. For teams accustomed to simpler and more intuitive REST APIs with JSON, switching to gRPC and learning Protocol Buffers can require significant time and effort. |
| Automatic Code Generation. gRPC automatically generates client and server code in a variety of languages (C++, Java, Python, Go, Node.js, C#, and others) based on the service definition in the .proto file. This significantly reduces the amount of boilerplate code that needs to be written manually. | Fewer Tools. While the situation is improving, there are still fewer available tools, libraries, and ready-made integrations for gRPC than for REST APIs. |
| Streaming Support. gRPC natively supports various stream types: unidirectional (client or server) and bidirectional, making it ideal for real-time and IoT applications. | Firewall Issues. Some corporate firewalls and proxies may have trouble handling HTTP/2 traffic, which can cause problems in certain network environments. |
| Load Balancing Issues. gRPC uses HTTP/2 features, which requires load balancing at the application layer (Layer 7) rather than the simpler transport layer (Layer 4), adding complexity to infrastructure setup. |
MCP
The Model Context Protocol (MCP) is an open standard developed to unify interactions between artificial intelligence models (e.g., large language models, LLMs) and external tools, data, and services. It allows AI to retrieve relevant information and perform actions in external systems (e.g., CRM, email, or databases), thereby expanding its capabilities and reducing errors.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP/SSE, gRPC (proposal SEP-1352), WebSocket (unofficial) |
| Formats | JSON |
| Versioning | - In the MCP-Version header.- Versioning URI – /v1/context, /v2/context.- Feature-flags in metadata ( features: ["experimental-embedding"]). |
| Caching | - ETag / If-None-Match, Cache-Control (max-age=300, stale-while-revalidate=60), internal client-side cache. |
| Documentation | JSON-Schema |
| Security | TLS 1.3, OAuth 2.0 Bearer Token. |
| RPC Support | Unary RPC (JSON-RPC), Server-streaming. |
| Error Handling | Structured Error-Payload |
| Client Generation | MCP Inspector |
| Strong Typing | JSON-Schema |
| Bidirectionality | Uses SSE to stream text as it’s generated. |
| Real-time exchange | For scenarios where the model context changes on the fly (online learning, interactive chatbots), SSE is used. |
| Scalability | The MCP architecture is built on stateless services. |
Applicability
- Integration with enterprise data and tools (Enterprise Integration). This is a key application area of MCP. The
protocol allows AI models to securely connect to a company’s internal systems:
- CRM systems. AI agents can create leads, update contacts, or retrieve customer status information upon user request.
- ERP systems and databases. Models can retrieve data on warehouse inventory, order status, or financial statements in real time.
- Document management systems. AI can search, read, and summarize information from internal knowledge bases and corporate file repositories (e.g., SharePoint, Google Drive), without requiring manual copy-pasting of text into the chat window.
- Workflow Automation. MCP allows AI models to act as “digital workers,” automating multi-step tasks:
- Communications management. An AI assistant can read incoming emails, categorize them, create tasks in a task tracker (such as Jira or Trello), and send standard responses using external tools through MCP.
- Customer support. AI bots can access customer order history, check delivery status, and initiate returns by interacting with external APIs via a standardized protocol.
- Expanding the capabilities of AI assistants and development environments. In consumer and professional tools, MCP
provides:
- Up-to-date information retrieval (RAG systems). Models can use web search tools or access local files to retrieve the latest information, going beyond their training data.
- Local control. In development environments (IDEs), an AI assistant can read and modify local code, run tests, or manage versions (Git) through an MCP server running on the developer’s machine.
- Creating Autonomous Agents. MCP is a fundamental tool for developing autonomous AI agents that can independently set goals, plan actions, and execute them using a set of tools for interacting with the digital world. An agent can decide to “find information on the internet,” then “save it to a file,” and then “send a report by email”—all of which are performed via the unified MCP protocol.
Key Concepts
- MCP Host. This is the application or environment in which an AI model runs (e.g., an AI assistant, a chat app, or a development environment with AI capabilities). The host manages user requests and coordinates the model’s overall interactions with external tools.
- MCP Client. The client is embedded in the host application and serves as an intermediary between the host (AI model) and the MCP servers. It is responsible for establishing connections, discovering available tools (services) on the servers, and translating requests and responses into a standard protocol format.
- MCP Server. This is an external service or program that provides specific capabilities, data, or tools (e.g., access to a file system, SQL database, Slack API, Google Drive, or web search functionality). Servers use the MCP standard to ensure interoperability and secure access to their functionality. - Connection establishment. The host application initiates a connection to one or more MCP servers.
- Capability discovery. The MCP client requests a list of available tools, resources, and functions from the server (e.g., “read a file,” “send a message,” “search a database”).
- User/model interaction. When the user makes a request to the AI model, the host enriches the model’s context with information about the available tools.
- Tool selection and execution. The AI model, using its intelligence and the provided context, independently decides which tool from the MCP server should be used to complete the task. It generates a structured request, which the client sends to the appropriate server.
- Result retrieval and response generation. The server performs the requested action (e.g., retrieve data from a database or search the web) and returns the result to the client. The AI model then uses this result to generate an accurate and contextually relevant response to the user.
Pros and Cons
| Pros | Cons |
|---|---|
| Unification and Standardization. MCP provides a single, consistent interface for connecting any tools. AI application developers do not need to write unique integration code for each new service (whether it’s Slack, a database, or a file system). | Initial Implementation Complexity. Using MCP requires developing or adapting three separate components (Host, Client, Server), which requires additional engineering resources and protocol knowledge. |
| Scalability and Flexibility. Since tools connect via a standard protocol, new features can be added or removed without having to rewrite the core logic of the host application or retrain the AI model. | Dependence on Tool Quality. The effectiveness of an AI system using MCP directly depends on the quality and reliability of the tools connected via the protocol. If an external service is slow or error-prone, the AI will be unable to complete its task. |
| Enhanced Security (Secure by Default). MCP is designed with zero-trust principles in mind. All interactions require explicit permission, and tool access is limited to only those functions explicitly granted by the server. This reduces the risk of unauthorized AI access to sensitive data. | AI Model Load (Tool Selection). The AI model must not only process the user’s request but also select the correct tool from the available list, understand its parameters, and formulate the appropriate call. This increases the complexity of prompt engineering and can slow down the model’s response time. |
| Improved AI Accuracy (Reduced Hallucinations). By giving the model access to relevant external data (via search or databases), MCP enriches the context, enabling AI to provide more accurate, informed, and up-to-date answers while reducing “hallucinations” (invented facts). | Control and Monitoring Issues. Granting AI access to perform real-world actions in external systems (e.g., sending emails) requires careful control and auditing to ensure the AI agent acts within expectations and does not perform unintended actions. |
| Activating Autonomous Agents. The protocol enables AI not only to answer questions but also to perform actions (running code, sending emails, updating CRM), which is the foundation for creating powerful autonomous AI agents. | Lack of a broad ecosystem (yet). MCP is a relatively new and evolving standard. Unlike established APIs, there may be fewer out-of-the-box integrations with popular enterprise systems, requiring custom development. |
WebSocket
WebSocket is a technology that allows for a persistent, bidirectional (full-duplex) interactive connection to be established between a web browser (client) and a server over a single TCP connection.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | WebSocket (RFC 6455) – a bidirectional connection over TCP, operating over ws:// (unsecured) and wss:// (TLS). |
| Formats | Data is transferred as text (usually JSON) or binary (ArrayBuffer, Blob) messages. |
| Versioning | - URL version: wss://api.example.com/v1/ws- Message field: { "v": "2.0", "type": "ping" }. |
| Caching | There is no point in caching individual messages, since WebSocket is a streaming connection. Use application-side caching if necessary |
| Documentation | AsyncAPI or as a separate README/wiki. |
| Security | TLS, JWT in the Sec-WebSocket-Protocol header or in a URL parameter (?token=…) |
| RPC Support | JSON-RPC 2.0 over WebSocket or a custom request-response protocol. |
| Error Propagation | Errors are propagated as special messages (e.g., the error field in JSON) or via a JSON-RPC error object. |
| Client Generation | AsyncAPI Generator, |
| Strong Typing | When using TypeScript or generated SDKs, message types are described in schemas (JSON-Schema, Avro, Protobuf). |
| Bidirectionality | WebSocket supports full duplex |
| Real-time communication | Messages are delivered with minimal latency thanks to a persistent connection. |
| Scalability | For large loads, sharding and load balancers (NGINX, HAProxy, Envoy) with WebSocket support are used, as well as messaging through brokers (Redis Pub/Sub, NATS, Kafka) to distribute events across multiple server processes. |
Basic Concepts
- Client. Typically a web browser or other client application that uses the built-in WebSocket object to establish and maintain a connection with the server.
- Server. A server application capable of handling WebSocket connection requests, maintaining active sessions, and exchanging data with connected clients.
- Full-duplex communication. The client and server can send messages to each other asynchronously and simultaneously, without having to establish a new connection or wait for a response each time.
- Frames. Data is transmitted as lightweight frames rather than heavy HTTP messages, significantly reducing overhead and latency.
- Stateful. The connection remains open until one of the parties (the client or the server) decides to close it by initiating the close procedure (the onclose event).
Applicability
- Online chat and messaging applications. WebSockets ensure instant delivery of new messages to all participants in a conversation without the need to constantly poll the server for updates.
- Multiplayer online games. In games, every millisecond counts. WebSockets allow for rapid synchronization of player actions, their movements, game state changes, and results in real time, ensuring the low latency necessary for dynamic gameplay.
- Trading and financial platforms. Applications for trading stocks, cryptocurrencies, and forex use WebSockets to instantly update quotes, charts, and market information. Latency can cost money, so maximum efficiency is required.
- Real-time notifications. Social networks use this technology to instantly deliver notifications of new likes, comments, or friend requests as soon as they occur.
- Collaboration and Document Editing. In applications like Google Docs or Figma, WebSockets allow you to see changes other users make to a document or design in real time, providing a seamless collaboration experience.
- Geolocation Tracking and Logistics. Delivery services use WebSockets to continuously transmit updates about the location of a courier or vehicle to a customer’s map in real time.
- Monitoring Systems and Live Data. Dashboards tracking system metrics, sports scores, or the status of IoT devices use WebSockets to continuously transmit up-to-date data and graphs.
Pros and Cons
| Pros | Cons |
|---|---|
| Bidirectional (full-duplex) communication. The main advantage. Both sides – the client and the server – can send data at any time independently. This eliminates the need for constant requests from the client. | Complexity of debugging and implementation. Unlike simple HTTP requests, which are easily debugged in standard developer tools, debugging a constant stream of WebSocket messages can be more challenging. |
| Low Latency. Once a connection is established, data is transmitted almost instantly. This is critical for real-time applications such as online games or financial trading platforms. | Requires server-side support. WebSockets require a dedicated server or library that supports the WebSocket protocol (e.g., Node.js with ws, Python with websockets, Java with Jetty/Tomcat), not just a standard web server that serves static files. |
| Efficiency and Low Overhead. After the initial HTTP handshake, WebSocket data frames have minimal headers compared to repeated full HTTP requests, saving bandwidth and speeding up transfers. | Proxy and Firewall Issues. Some older or corporate proxy servers and firewalls may not understand or block the WebSocket protocol (since it starts as an HTTP request but is then “upgraded” to a different protocol), although this is becoming less common. |
| Reduced Server Load. Eliminates the need to constantly open and close new TCP connections for each request, reducing the load on the server infrastructure compared to HTTP polling. | Lack of built-in reconnection handling. Unlike HTTP, which is inherently resilient to short-term failures (the next request will simply retry), WebSocket requires manual implementation of logic for handling disconnections, timeouts, and automatic reconnection in both client and server code. |
| Compatibility with modern browsers. WebSocket is supported by the vast majority of modern web browsers, ensuring widespread availability of the technology. | Not suitable for simple requests. If you simply need to retrieve data once per page load (for example, a product list in an online store), using a persistent WebSocket connection is overkill and inefficient. Traditional HTTP (REST API) is better suited for such tasks. |
JSON‑RPC
JavaScript Object Notation - Remote Procedure Call (JSON-RPC) is a simple, lightweight protocol for remote procedure calls (RPC) that uses the JSON data format to encode messages. It allows a client to call methods or functions located on a remote server as if they were local functions in the client application.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP/HTTPS, WebSocket, TCP, Unix-socket, MQTT |
| Formats | JSON, JSON-Lines, MessagePack, or CBOR |
| Versioning | - Via the name of the called method. - Via a parameter in the message. - Via HTTP headers. - At the level of individual services. |
| Caching | - The protocol itself does not determine caching. - When using HTTP, standard headers ( Cache-Control, ETag, If-None-Match) can be used. |
| Documentation | JSON-RPC 1.0, JSON-RPC 2.0 |
| Security | HTTPS, JWT, IP access restriction, CORS policy |
| RPC support | Requests, notifications, batch requests |
| Error handling | Response as JSON with an ’error’ field and error codes |
| Client Generation | JSON-RPC Code Generator |
| Strong Typing | JSON Schema or separate IDL. During the client code generation stage, statically typed methods are derived from the schema. |
| Bidirectionality | - By default, client → server (request/notification). - When using a WebSocket or TCP socket connection, the server can send notifications to the client without a prior request (push model). - Often implemented through subscription methods ( subscribeEvents, unsubscribeEvents), after which the server sends events as notifications. |
| Real-Time Exchange | - Notifications allow data to be transmitted without waiting for a response, which is ideal for streaming (price quotes, telemetry, chat). - A WebSocket connection can maintain a constant stream of messages; each new object is a separate JSON-RPC message. - For large volumes, use batch notifications. |
| Scalability | - Doesn’t store state; each request fully describes the action, so servers can easily scale horizontally using load balancers. - Batch notifications reduce the number of network roundtrips, saving bandwidth. - For heavy loads, use message brokers to asynchronously process requests and send notifications. |
Applicability
- Blockchain and cryptocurrencies. Most blockchain platforms use this protocol as the primary interface for
interacting with network nodes:
- Interaction with nodes. Wallet applications, block explorers, and decentralized applications (dApps) use JSON-RPC to send transactions, query account balances, retrieve data about the latest blocks, and invoke smart contracts.
- API standardization. Protocols such as the Bitcoin Core API and the Ethereum JSON-RPC API have become industry standards, allowing developers to easily build tools compatible with various networks.
- Inter-service communication. In architectures consisting of many small, independent services (microservices),
JSON-RPC is used for efficient communication between them:
- High-performance internal communication. When services need to call specific functions from each other with low latency, JSON-RPC is often a more lightweight solution than a full-featured REST API.
- Hiding internal logic. RPC allows a client to call a complex procedure on the server without understanding the implementation details.
- Web Applications (AJAX). Historically, JSON-RPC has been widely used in web development for asynchronous data
exchange between the browser and the server (AJAX technology):
- Dynamic data updating. Allows web pages to update data (for example, get weather information, stock quotes, or user status) without reloading the entire page.
- Third-party system and API integration. JSON-RPC is often used in situations where it is necessary to integrate
various software applications over the network:
- Financial and banking systems. To perform atomic, well-defined operations, such as “check_balance” or " transfer_funds."
- Monitoring and management systems. For remotely controlling programs or executing commands on various network nodes.
Key concepts
- Simplicity and lightweight.
- Use of JSON. The protocol uses JSON syntax to encode messages. JSON is universal, human-readable, and easily parsed in virtually any modern programming language.
- Minimalistic specification. The JSON-RPC specification is very short and straightforward, simplifying its implementation on both the client and server sides.
- Remote Procedure Call (RPC) Principle
- Focus on actions/methods. Unlike REST, which focuses on resources (nouns) and standard HTTP verbs (GET, POST, PUT, DELETE), JSON-RPC focuses on calling specific procedures or functions (verbs) on the remote server.
- Call transparency. The goal of RPC is to make calling a remote function as similar as possible to calling a local function.
- Transport Protocol Independence
- Transport agnosticism. JSON-RPC is not tied to any specific network protocol. It can be transmitted over HTTP/S ( the most common), TCP, WebSocket, AMQP, or any other streaming or datagram protocol. This provides great flexibility when integrating into various architectures.
- Stateless
- Self-contained requests. Each request is processed independently of previous ones. The server is not required to maintain client state information between procedure calls. This simplifies scaling the server side.
- Flexible Request Processing
- Notification support. The client can send a request that does not require a response from the server (by omitting the id field). This is useful for transmitting events or information where confirmation of delivery or the result is not critical.
- Batching. The protocol allows combining multiple individual procedure calls into a single HTTP request (by sending an array of JSON objects). The server processes them and returns a single response containing an array of results. This reduces network latency when multiple small operations need to be performed.
- Predictable error handling
- Standardized error codes. The specification defines standard numeric codes for system errors (e.g., “Method not found,” “Parse error”) and also allows applications to use their own ranges of codes for logical application errors.
Pros and Cons
| Pros | Cons |
|---|---|
| Simplicity and lightweight. The protocol specification is very compact, and the use of JSON makes messages easy for humans to read and easy for machines to parse. This speeds up development and debugging. | Lack of API standards (Self-documentation). The REST API is self-documenting thanks to resource URLs and HTTP verbs. With JSON-RPC, you need to know the exact method name and parameter structure in advance (for example, from external documentation or a schema file like OpenAPI/Swagger). |
| High performance. The RPC approach is often more efficient for performing specific functions than REST. Using batching reduces the number of network calls (lowering latency). | Debugging is difficult without documentation. Without documentation, understanding what methods are available and how to call them becomes difficult. All requests are typically sent to the same endpoint. |
| Transport independence. JSON-RPC can run over any protocol (HTTP, TCP, WebSockets, etc.), providing greater flexibility in network architecture. | Limited use of HTTP features. When used over HTTP, JSON-RPC typically ignores standard HTTP verbs (always uses POST) and standard status codes (always 200 OK, errors are described in the body of the JSON response). This prevents the use of some standard HTTP infrastructure features (for example, HTTP request caching). |
| Action-oriented. Ideal for systems where interactions are described by verbs/commands rather than resources (as in REST). | Less flexible for general data queries. If you need to build a flexible API for retrieving, filtering, and linking various resources, REST or GraphQL are much better suited than an RPC approach. |
| Standardization in blockchain. The de facto standard for interacting with nodes of most cryptocurrencies (Bitcoin, Ethereum), ensuring widespread support and tooling in this niche. |
OData
The Open Data Protocol (OData) is an ISO/IEC and OASIS-approved protocol that defines a set of best practices for creating and consuming RESTful APIs. Its primary goal is to provide a simple and standardized way to interact with data through web services using standard web technologies such as HTTP, JSON, and URLs.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP/HTTPS |
| Formats | JSON (OData JSON format), Atom/XML (OData Atom) |
| Versioning | URIs (/v2/, /v4/), in the OData-Version header |
| Caching | HTTP caching headers (ETag, If-Match, If-None-Match, Cache-Control) |
| Documentation | EDMX-XML (metadata), OpenAPI with OData 4.1+ support |
| Security | OAuth 2.0, Bearer Tokens, Basic Auth, API Keys |
| RPC Support | OData allows you to declare functions (GET-only) and actions (non-idempotent) – similar to RPC |
| Error Handling | Errors are passed in standardized JSON/XML format with the fields error, code, message, and target. |
| Client Generation | OData Connected Service (Visual Studio), odata-client-codegen (Java), odata4j, Simple.OData.Client (C#), odata2ts (TypeScript) |
| Strong Typing | EDM (Entity Data Model) |
| Bidirectionality | - Delta Queries ($delta)- OData Change Notifications (OData v4.01) |
| Real-Time Exchange | OData Push (WebSocket), Server-Sent Events (SSE), SignalR integration. |
| Scalability | OData provides a set of mechanisms for serving large volumes of data: - Pagination, $top, $skip, $skiptoken (server-driven page).- Batch requests, multiple operations in a single HTTP message ( multipart/mixed).- Filtering, projection, sorting ( $filter, $select, $orderby) allow you to transfer only the required fields and records.- Caching via ETag and Cache-Control. |
Applicability
- Enterprise Software. The protocol has become the de facto integration standard for many major software vendors.
- Creating Unified APIs. OData is used by developers to create APIs that don’t require clients to have in-depth knowledge of the server implementation. Thanks to metadata and standard query parameters, clients can independently discover and interact with the data structure.
- Web and Mobile Application Development. Front-end developers (websites, iOS or Android mobile apps) use OData services as a reliable and flexible backend. The protocol allows mobile clients to request exactly the data they need, minimizing traffic and device load.
- Automation of tools and code generation. Because OData provides a complete data model through metadata (
$metadata), various tools and frameworks can automatically generate client code (proxy classes) or user interface elements. This significantly speeds up development. - Open Data and Government Services. OData’s simplicity and standardization make it attractive for publishing open data. Some government and municipal services use OData to provide access to public information in a machine-readable format.
Key Concepts
- Standardization and Unified Approach
- REST-based. OData is a protocol built on REST principles, using standard web technologies (HTTP, URL, JSON, XML).
- Unified Interface. It defines a set of rules and guidelines for request and response headers, status codes, HTTP methods (GET, POST, PUT, PATCH, DELETE), and URL conventions. This ensures consistency regardless of the data source.
- Powerful Query Options. A key feature of OData is the ability to perform complex queries on data by passing parameters directly in the URL string. This allows the client to control what data, how much, and in what order it wants to retrieve, without having to change server-side code:
$filter: Filter data based on specific criteria (similar to theWHEREclause in SQL).$select: Select only the required fields (projection).$orderby: Sort data.$expand: Load related data (navigational properties) in a single request, avoiding N+1 problems.$topand$skip: Implement pagination (skip and select a certain number of records).$count: Get the total number of records.- Metadata
- Machine-readable description. An OData service provides a machine-readable description of its Entity Data Model (
EDM) via a special
$metadataURL. - Self-discoverability. The presence of metadata allows for the automatic generation of client libraries (proxies), tools, and UIs that understand the data structure and available operations, simplifying development and integration.
- Machine-readable description. An OData service provides a machine-readable description of its Entity Data Model (
EDM) via a special
- Entity Data Model (EDM)
- Abstract data representation. OData uses an abstract data model (EDM), which defines entities, their properties, relationships between them, and keys for unique identification.
- Semantic interoperability. This improves semantic interoperability between different systems, allowing them to exchange data in a structured manner.
- Functions and Actions. Logic encapsulation. OData allows for the definition of custom operations that go beyond standard CRUD. Functions perform data reading operations, while Actions perform operations that modify data or have side effects.
Pros and Cons
| Pros | Cons |
|---|---|
| Standardization and Uniformity. Provides a unified and predictable way to interact with data. Any developer familiar with OData can immediately understand how a new OData service works. | Learning Curve. While the basic principles are simple, the protocol has many nuances, specifications, and advanced features. New developers may need time to learn all the capabilities (for example, complex filter expressions). |
| Reduced Server-Side Development Burden. Back-end developers don’t need to write hundreds of endpoints for each specific use case. The standard $filter, $orderby, $select, $expand, and $skip functions cover most client data manipulation needs. | Potential Redundancy and Complexity. For simple APIs, OData can be overkill. Its specification is quite extensive, and sometimes a “clean,” lightweight, hand-written REST API can be simpler and faster to implement. |
| Self-Discoverability (Metadata). The presence of $metadata enables automatic generation of client code and tooling, significantly speeding up the development of client applications and system integration. | Complex Query Performance. Giving the client complete freedom to formulate complex queries (for example, $expand with deep nesting) can lead to performance issues on the server side. The backend developer must carefully optimize the implementation of database queries to avoid problems. |
| Client-Side Flexibility. Client applications gain control over what data they need, how to filter and sort it, without having to change the server code. | Не всегда подходит для неструктурированных данных. OData отлично работает с реляционными и структурированными данными (Entity Data Model). Для работы с неструктурированными данными или для реализации RPC-подобных сервисов он подходит хуже. |
| Network Efficiency. Using $select and $expand helps minimize the amount of data transferred over the network, loading only the necessary fields and avoiding redundant data loading. | |
| Mature Ecosystem and Vendor Support. Widely supported by major market players (SAP, Microsoft), ensuring reliability, tool availability, and long-term support. |
SSE
Server-Sent Events (SSE) is a technology that allows a web server to send automatic updates (data) to a web browser or other client continuously over a single open HTTP connection.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP 1.1 (HTTP/2 can be used, but in browsers it works over regular HTTP). |
| Formats | Text (strings separated by \n), transfer of structured data as JSON inside the data field. |
| Versioning | Versioning is implemented at the application level – the event field or the data body specify the message type/version (e.g., event: v2.update). |
| Caching | Caching is disabled |
| Documentation | None |
| Security | CORS, TLS/HTTPS, token in the Authorization header, session cookie, URL parameter (?token=…) |
| RPC support | No, you can implement a “callback” via commands in a stream: the client receives a command event with a JSON payload and then sends a regular HTTP request (POST/PUT) to the server (e.g., SSE-RPC, EventSource-RPC). |
| Error propagation | - The server can close the connection (HTTP 500, 503) → the client will receive an error event. - Within the stream – sending an error event with the payload: text\nevent: error\ndata: {“code”:4001,“msg”:“Invalid token”}\n\n``` - The browser generates the error event automatically |
| Strong typing | No. Implemented at the payload level. |
| Bidirectionality | No, SSE is one-way. For feedback, the client typically: 1. Sends a regular HTTP request (POST/PUT) with the command. 2. Uses the ?replyTo=… query parameter, and the server responds with the same connection (a “long-polling” implementation).3. Combines SSE with WebSocket if a full bidirectional channel is required. |
| Real-time communication | - Low latency – typical latency is 100-300 ms (depending on network RTT and keep-alive intervals). - Auto-reconnection – EventSource automatically opens a new connection when disconnected, sending the Last-Event-ID for reconnection.- Keep-alive – the server can send a :heartbeat\n\n comment every 15-30 seconds to keep the connection open. |
| Scalability | - Connection limiting – each SSE connection holds an open HTTP token, so you need to plan for the number of concurrent clients (usually 10-30 thousand per process). - Load balancers – Nginx/HAProxy with proxy_http_version 1.1; proxy_set_header Connection ""; transmit the stream without buffering.- Clustering – multiple server instances write to a shared message broker (Redis Pub/Sub, Kafka, NATS). Each process subscribes and relays messages to clients. |
Applicability
- Notification and Alert Systems. SSE is ideal for implementing functionality where the user needs to instantly
receive information about new events without having to refresh the page or constantly request information:
- Social media notifications for new messages, friend requests, or comments.
- Breaking News Alerts. Delivering news headlines immediately after they are published.
- System Notifications. Alerts about system status, errors, or background task completion.
- Real-Time Data Streaming. The technology is used to continuously display changing data when information relevance
is critical:
- Financial applications. Streaming stock quotes, exchange rates, and indices in real time.
- Sports broadcasts. Updating current match scores, statistics, and game progress (live scorecards).
- Monitoring and analytics. Displaying server performance metrics, system load, or IoT device metrics on administrative panels (dashboards).
- Online chats (in some cases). While WebSockets are more commonly used for full-fledged two-way chats, SSE can be used in simplified chats where messages are sent via a standard HTTP POST request and received via an SSE stream. This reduces server-side implementation complexity while leveraging the benefits of the standard HTTP protocol.
Key concepts
- Unidirectional communication (Server-to-Client). This is a fundamental difference from WebSockets. Data is transferred only from the server to the client. The client initiates the connection and listens for the data stream, but does not use the same connection to send data back.
- Uses standard HTTP/HTTPS. SSE runs on top of the standard Hypertext Transfer Protocol. This offers significant advantages:
- Infrastructure compatibility. Works seamlessly through existing proxy servers, firewalls, and load balancers without the need for special configuration.
- No need for special protocols. No protocol upgrade to the WebSocket protocol is required.
- Data format
text/event-stream. Data is transferred as plain text with the MIME typetext/event-stream. Each message is formatted according to a simple syntax: - Messages are strings terminated by double line feeds (
\n\n). - Various fields are supported, such as
data(the message itself),event(the event type),id(the message identifier), andretry(the suggested time before reconnection). - Built-in automatic reconnection mechanism. Browsers have built-in functionality that automatically attempts to re-establish an SSE connection if it is lost (for example, due to network failures or server timeouts). This makes SSE highly resilient to transient network failures without the need to write additional reconnection handling code on the client.
- Simple client API (
EventSource). SSE is handled on the client using a simple, native JavaScript API, theEventSourceinterface. This simplifies development. - Efficiency and low overhead. Compared to constant server polling, SSE is much more efficient, as it eliminates the overhead of establishing and closing a new HTTP connection for each update. Compared to WebSockets, SSE has lower frame overhead, as it transmits plain text rather than binary frames.
Pros and Cons
| Pros | Cons |
|---|---|
| Simplicity and lightweight. SSE is significantly easier to implement both on the client side (using the native EventSource API) and on the server side. It doesn’t require a complex protocol or connection management like WebSockets. | One-way communication only. This is the main limitation. You can’t use the same SSE connection to send data from the client back to the server. For this, you have to use separate HTTP requests (POST/PUT/DELETE). |
| Uses standard HTTP. Works on top of regular HTTP/HTTPS. This means that SSE is compatible with virtually any existing network infrastructure, proxies, firewalls, and load balancers without the need for special configuration changes. | Connection Limit. Historically (especially in older versions of HTTP/1.1), browsers could limit the number of simultaneous SSE connections (usually to 6) from a single domain. In HTTP/2, this issue is less pronounced, but can still be a factor. |
| Automatic Reconnection. Browsers have a built-in mechanism for automatically reconnecting when the network is interrupted, which improves reliability and eliminates the need for the developer to write reconnection logic manually. | Text-Only Support. SSE transmits data as plain text (text/event-stream). While it is possible to transmit JSON within the text data field, binary data is more difficult to transmit directly, unlike WebSockets. |
| Efficiency for One-Way Data. For scenarios where data flows only from the server to the client (e.g., news feeds, stock quotes), SSE is more efficient than WebSockets due to the lower overhead of transmitting text messages. | Lack of support for older versions of IE. Internet Explorer (up to IE11) never supported the native EventSource API. Polyfills were required to ensure compatibility, although this is rarely an issue for modern applications. |
| Event type support. SSE allows sending messages with different event names, simplifying the processing of different data types on the client side in a single connection. | High latency during round-trip. If the application requires frequent round-trip data exchange (e.g., online games, chats with active input), the latency will be higher than when using WebSockets, since client responses require a new HTTP request. |
Long Polling
Long Polling is a technique used to emulate real-time, two-way communication over the standard HTTP protocol, which inherently operates on a request-response basis.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP/HTTPS. The client sends a regular GET (or POST) request to the endpoint, the server keeps the connection open until an event occurs or a timeout (usually 30-60 seconds). |
| Formats | Text (JSON, XML, plain-text) |
| Versioning | Via URL path (/api/v1/updates), query parameters (?v=2), or headers (Accept-Version: 2) |
| Caching | Disabled, otherwise the client may receive a stale response. This is done using the Cache-Control: no-cache, no-store, must-revalidate and Pragma: no-cache headers. |
| Documentation | No |
| Security | HTTPS, JWT, OAuth 2.0 Bearer, CSRF |
| RPC Support | No, you can implement “JSON-RPC over HTTP” in the response body |
| Error Handling | HTTP codes (4xx, 5xx), JSON response with error/message fields |
| Client Generation | No |
| Strong Typing | No |
| Bidirectionality | No |
| Real-Time Exchange | Latency is determined by the connection hold timeout (30-60 seconds) + network RTT. When events are active, the server responds immediately, resulting in “near real-time” (latency ≈ < 200 ms). When no events occur, the client receives an empty response (204) or a timeout message and immediately opens a new request. This makes the model suitable for chat applications, notifications, and monitoring, but less efficient than WebSocket at high message rates. |
| Scalability | Limited by the number of simultaneously open HTTP connections on the server (usually several thousand). |
Applicability
- Online chat and messaging systems. Chat implementation requires instant message delivery from the server to the client.
- Applications running through specific APIs. Some third-party services and APIs that want to provide real-time updates but don’t support WebSockets use Long Polling as their primary mechanism.
- Online games and collaborative applications (Deprecated). Before WebSockets, Long Polling was used for updating game state, character movement, or collaborative document editing. Now, WebSockets are almost always used for such tasks due to their much greater efficiency and low-latency, two-way communication.
- Social media notifications (Deprecated). Server-Sent Events (SSE) or WebSockets are now more commonly used for these purposes.
- Compatibility with legacy browsers and infrastructure. Long Polling remains relevant in environments with severe limitations or where it is necessary to support very old browsers (e.g., Internet Explorer 6/7) that do not support modern APIs (WebSockets, EventSource/SSE).
Key Concepts
- Emulating the PUSH model via PULL requests. The main feature of Long Polling is that it simulates the server sending data (push), while using the underlying client request mechanism (pull). The server initiates data transfer only when it is ready, but always in response to a previously made client request.
- Keeping the HTTP connection open. Unlike short polling, where the connection is immediately closed with an empty response, with Long Polling the server deliberately keeps the connection open for a long time (several seconds or even minutes), waiting for data.
- Using standard HTTP. Like Server-Sent Events, Long Polling is entirely based on the standard HTTP/HTTPS protocol.
This ensures:
- High compatibility. Works through any proxies, firewalls, and load balancers without the need for special configuration.
- Support for older browsers. This is the most universal method of delivering real-time data to legacy web clients.
- Immediate data delivery (if available). As soon as new data becomes available on the server, it is immediately sent to the client over an open connection, minimizing latency compared to short, scheduled polling (e.g., every 5 seconds).
- Cyclical nature of operation (Continuous Polling). Long Polling requires a continuous cycle of requests to maintain relevance. As soon as the client receives a response (or times out), it immediately sends a new request to the server to “join the queue” again. This cycle provides the illusion of a persistent connection.
- Overhead of creating a new connection. Since each individual connection in the cycle is eventually closed and a new one is immediately opened, overhead is incurred for establishing the TCP/IP connection and the HTTP handshake with each cycle. This makes Long Polling less efficient than WebSockets (which use a single persistent connection) at high update rates.
- Potential “Head-of-Line Blocking” issue. Depending on the implementation and protocol (especially in HTTP/1.1 with its limited number of connections per domain), Long Polling can block other requests on the same domain because one connection is constantly busy waiting for data.
Pros and Cons
| Pros | Cons |
|---|---|
| High compatibility and versatility. Works 100% through any existing web infrastructure, including legacy proxies, corporate firewalls, and load balancers, since it uses standard HTTP GET/POST requests. | Per-connection overhead. Each round-trip (receive data -> close -> new request) requires a complete establishment of a new TCP/IP and HTTP connection. This creates more network traffic and latency than a single persistent connection (WebSockets or SSE). |
| Older browser support. This is the most reliable method of ensuring “real time” for very old web browsers (before the HTML5 API). | Potential request blocking. HTTP/1.1 limits the number of simultaneous connections to a single domain (usually 6). While one connection is stuck in Long Polling mode, it can block the loading of other resources (images, scripts) from the same server. |
| Ease of implementation on the server. It does not require a protocol update (like WebSockets) or special server support for the text/event-stream format (like SSE); it can often be implemented using standard server technologies without additional libraries. | Complexity of timeout management. Timeouts must be carefully configured on both the client and server sides to prevent the connection from being forcibly closed by network equipment before data becomes available. |
| Immediate data delivery. Unlike scheduled short polling, data is delivered to the client as soon as it becomes available on the server, minimizing latency. | Ineffective at high update rates. If data is updated very frequently, constantly reopening connections becomes extremely inefficient. WebSockets handle this scenario significantly better. |
| Fallback. Often used as a reliable fallback in modern libraries (e.g., Socket.IO) in case the primary method (WebSockets) is blocked by client network restrictions. | Less “pure” bidirectionality. While bidirectionality is possible, it is implemented through two different mechanisms: incoming via Long Polling, and outgoing via separate POST requests. WebSockets offer a single, symmetric channel. |
STOMP
Streaming Text Oriented Messaging Protocol (STOMP) is a simple text-based messaging protocol designed to provide interoperability between clients and message brokers.
| Features | Description and Examples |
|---|---|
| Formats | Messages are transmitted as text frames with headers in the form of key:value pairs and a message body in an arbitrary format. The body is often encoded as plain-text, JSON, XML, or binary (Base64), but the protocol itself imposes no restrictions. |
| Versioning | No |
| Caching | No |
| Documentation | No |
| Security | TLS/SSL, SASL |
| RPC Support | No, via a custom implementation of the request/response pattern |
| Error Passing | An ERROR frame containing a message header and a body describing the problem. |
| Client Generation | No |
| Strong typing | No |
| Bidirectionality | Yes. SEND, SUBSCRIBE, UNSUBSCRIBE frames go from the client to the broker, while MESSAGE, RECEIPT, and ERROR frames go from the broker to the client. This makes the channel fully bidirectional without the need to open separate sockets for reading and writing. |
| Real-time communication | Thanks to its simple text format and WebSocket support, STOMP is often used for push notifications in browsers (chat applications, live tables, game lobbies). |
| Scalability | Through broker clustering and queue partitioning. STOMP clients can connect to any node in the cluster, and the broker distributes messages to subscribers. |
Applicability
- Online Chat Applications. STOMP provides a structured and reliable way to route these messages through a broker.
- Real-Time Dashboards. Applications that need to display real-time data, such as system metrics, status updates, or financial quotes. Updates are automatically sent to all subscribed clients.
- Real-Time Tracking. In shipping, logistics, or geolocation tracking systems, STOMP can be used to continuously transmit location or order status updates to clients.
- Notifications and Alerts. Social media applications or enterprise systems use STOMP to instantly send notifications to users about new events (e.g., new emails, comments, likes).
- Games and Collaboration. In multiplayer online games or collaboration tools, STOMP helps synchronize state between different clients with minimal latency.
- Integration with enterprise message brokers. STOMP provides a simple, interoperable communication format for clients written in various languages (Java, Python, Ruby, JavaScript) with full-featured message brokers such as Apache ActiveMQ, RabbitMQ, or Artemis MQ.
- Internet of Things (IoT) applications. Due to its lightweight nature, STOMP may be suitable for certain IoT scenarios where devices need to communicate with central servers or other devices, although MQTT is more commonly used in this area.
Basic Concepts
- Text Format. STOMP is a text-oriented protocol, making it easy to read, simple to implement, and convenient for debugging (you can even interact with the broker via Telnet).
- Frame-Based Structure. Data exchange between the client and the broker occurs using frames. A frame consists of
three main parts, similar to HTTP messages:
- A command (e.g., CONNECT, SEND, SUBSCRIBE).
- A set of headers in the key:value format, separated by a newline.
- An optional message body, followed by a terminating null byte (NULL octet).
- Transport Layer Agnosticism. STOMP does not define how exactly data is transmitted over the network. It requires a reliable bidirectional streaming protocol (e.g., TCP or WebSockets) on top of which it implements the messaging logic.
- Binary data support. Although the protocol is text-based, the message body can contain binary data, which is optionally encoded (e.g., in Base64).
- Cross-language compatibility. Provides a standardized communication format, allowing clients written in different programming languages (Ruby, Python, Java, JavaScript) to easily communicate with any STOMP-compatible message broker.
- Ease of client implementation. Developers can often write a basic STOMP client in a few hours due to the simplicity of the protocol.
- Acknowledgment mechanisms (ACK/NACK). Supports acknowledgment of message receipt and processing, ensuring reliable delivery.
- Publish/Subscribe. Implements standard messaging patterns through a destination mechanism, allowing clients to subscribe to topics or queues.
- Heartbeat. Supports a heartbeat mechanism for detecting inactive or broken connections.
Pros and Cons
| Pros | Cons |
|---|---|
| Simplicity and ease of learning. STOMP is very easy to learn and use. Its command- and header-based structure (similar to HTTP) is intuitive for developers. | Transport protocol dependence. STOMP is not a standalone transport protocol. It requires an underlying, reliable streaming protocol, such as TCP or WebSockets. |
| Debuggability. Being a text-based protocol, STOMP is easy to debug. Developers can use simple tools like telnet or curl to manually connect to the broker and send commands for testing. | Text protocol overhead. The text-based nature of the protocol may introduce slightly higher overhead than purely binary protocols (such as AMQP or MQTT) when transferring large volumes of data or in high-performance systems. |
| Cross-language compatibility. STOMP provides a standardized “wire format,” allowing clients in different languages (Java, Python, JS, Ruby, etc.) to interoperate with any STOMP-compatible broker. | Limited feature set. STOMP is intentionally simple. It has fewer built-in routing and infrastructure management features than more complex protocols such as AMQP. |
| Excellent integration with WebSockets. STOMP is ideal for use on top of WebSockets in web applications. This makes it easy to implement two-way real-time messaging between the browser and the server. | Lack of strongly typed headers. STOMP headers are simple pairs of strings, which may require additional application-side validation compared to protocols with more strict data type definitions. |
| Binary Data Support. Despite being text-based, STOMP can carry binary data in the frame body, making it flexible for various payload types. | Less Common in IoT. In the Internet of Things (IoT), it is often superseded by MQTT, which is typically more efficient in environments with limited network bandwidth and device resources. |
| Lightweight Client. Implementing a basic STOMP client requires minimal effort and a small amount of code, making it easy to embed into various applications. |
Webhooks
Webhooks are a mechanism that allows applications to exchange information about specific events in real time. Simply put, they are automatic messages sent from one application to another when a predefined event occurs in the first.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | HTTP/HTTPS |
| Formats | JSON (application/json), XML (application/xml), form-encoded (application/x-www-form-urlencoded) |
| Versioning | URIs (/v1/webhook, /v2/webhook), headers (X-Webhook-Version: 2) |
| Caching | Not cached |
| Documentation | OpenAPI/Swagger, in separate “webhooks” sections (OpenAPI 3.1) |
| Security | HTTPS, HMAC Signature, Basic/Auth Token, IP Whitelisting |
| RPC Support | No, you can simulate a request-response: the origin server waits for HTTP 2xx from the recipient, otherwise it re-delivers. Some platforms allow you to specify a Callback URL and receive a response, which is considered the result of an RPC call. |
| Error Handling | HTTP Statuses |
| Client Generation | Not required |
| Strong Typing | JSON Schemas (JSON Schema, Avro, Protobuf) for Event Types |
| Bidirectionality | Communication is one-way (source → receiver). When bidirectional interaction is required, use a combination of webhook and API request. |
| Real-Time Exchange | Webhook messages are delivered almost instantly after an event occurs. |
| Scalability | The webhook infrastructure must be able to withstand high peak requests (thousands to tens of thousands per second). Best Practices: - Queues – the receiving server quickly queues the request and immediately responds with 2xx.- Idempotent Handlers – use event_id for deduplication.- Endpoint Sharding. |
Applicability
- E-commerce and order management. Webhooks ensure instant data synchronization between your online store, payment
system, CRM, and warehouse.
- Payment notifications. Payment gateways send webhook notifications when a payment is successful or declined. This automatically updates the order status in your system.
- Inventory synchronization. When a product is purchased in one store, a webhook can notify other systems to update inventory levels.
- Delivery tracking. Automatically notify customers or internal systems about changes in order delivery status.
- Continuous integration and deployment (CI/CD). In software development, webhooks play a key role in automating
build processes. When a developer pushes new code to a repository, GitHub or GitLab can send a webhook to a build
server (e.g., Jenkins or Travis CI), which automatically triggers testing and deployment of the new version of the
application.
- CRM and Marketing. Webhooks allow you to instantly respond to customer actions and automate sales funnels.
- Lead Processing. When a form is filled out on a website (e.g., through a newsletter service), a webhook can instantly create a new lead card in your CRM system (e.g., amoCRM).
- Triggered Messages. Send automatic email notifications or chatbot messages immediately after a specific user action (registration, course purchase).
- Communication and Notification Systems. Most modern corporate messengers use webhooks to integrate with external services. Notifications about new application bugs, Jira task updates, or new orders can be automatically sent to a work channel.
- Monitoring and Analytics. Webhooks are used to receive instant alerts about critical events.
- Server Monitoring. If server resources exceed a specified threshold or the system crashes, a webhook can immediately send an alert to the administrator.
- Real-time Analytics. Transfer user behavior or system event data to analytics platforms without delay.
Key Concepts
- Real-time data transfer (Push model). This is a key characteristic. Instead of the target application periodically “pulling” data from the source, a webhook “pushes” data as soon as an event occurs. This ensures immediate system response to changes and eliminates unnecessary load associated with frequent empty requests.
- Event-driven operation. Webhooks are activated only by specific, predefined events (triggers), such as “new user created,” “payment completed,” or “code updated.” The system receives only current and relevant information, not all data.
- Use of HTTP requests. The webhook mechanism is based on standard and widely used web technologies.
- Method. The most common method used is POST (sometimes PUT or DELETE) for sending data. - Data format. The payload is typically sent in JSON or XML format, which is easily read by most modern applications.
- Ease of implementation (for developers). Using webhooks doesn’t require complex protocol setup. Simply provide a publicly accessible URL (endpoint) that can accept HTTP requests. Integration is quick and the learning curve is low.
- Unidirectional nature (most common). Webhooks are essentially notifications. The source system sends information and doesn’t wait for a complex dialog or series of responses. It only waits for confirmation of receipt (usually an HTTP status of 200 OK). Although they are essentially unidirectional, the response from the receiving server may contain instructions on how to further process the event, but the primary purpose is to deliver the notification.
- Require security and authentication. A public URL for receiving webhooks can be vulnerable. Therefore, security mechanisms are important:
- HTTPS. Uses a secure connection to encrypt data.
- Request signatures (Signatures). The sender often signs the request with a secret key, and the recipient verifies this signature to ensure the data came from a legitimate source.
- The need for error handling and retries (Retry mechanisms). The target server may temporarily become unavailable. Good webhook implementations include a retry policy that automatically attempts to deliver the notification multiple times within a specified period.
Pros and Cons
| Pros | Cons |
|---|---|
| Speed and real-time. The most important advantage. The reaction to an event occurs instantly, without delays, unlike API polling, where the delay can range from several seconds to minutes. | Requires a public endpoint. Your server that receives webhooks must be accessible from the outside (have a public IP address or domain name) so that the external service can reach it. This complicates testing on a local machine without special tools (such as ngrok). |
| Efficiency and load reduction. Webhooks save resources for both systems. There is no need to constantly send “empty” requests asking “Did something happen?” Data is transferred only when it is really needed. | Security Challenges. A public URL is vulnerable to unauthorized requests. Sender authentication mechanisms (via secret keys, request signatures, and authentication) must be implemented. |
| Ease of Implementation. Receiving a webhook requires simply creating a simple HTTP endpoint (URL) in your application that can handle POST requests. No complex configuration is required. | Зависимость от надежности сети. Если сервер-получатель временно недоступен или произошел сбой сети в момент отправки, уведомление может быть потеряно (если отправитель не реализует политику повторных попыток). |
| Scalability. The event-driven approach scales well. The sending system doesn’t care how many receiving systems are listening for events – it simply sends a notification. | Reliability. The developer on the receiving side must provide mechanisms for handling duplicates (if the webhook is received twice due to the sender retrying) and graceful error handling. |
| Business Process Automation. Webhooks are the foundation of modern automation, allowing you to connect disparate services (payments, CRM, messengers, Git services) into a single seamless workflow. | Fire-and-forget model. A webhook is typically sent without waiting for a complex response. If you need two-way data synchronization or a complex dialog between systems, webhooks won’t be enough – you’ll need a full-fledged API. |
MQTT
Message Queuing Telemetry Transport (MQTT) is a lightweight messaging protocol specifically designed for use in resource-constrained systems such as the Internet of Things (IoT) and machine-to-machine (M2M) communications.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | TCP, TLS, WebSocket (for browsers), MQTT-SN (for UDP networks). |
| Formats | Binary packets. The message body (payload) can be any format – JSON, CBOR, Protocol Buffers, MessagePack, simple strings, binary files. |
| Versioning | At the data level |
| Caching | No, but Retained Messages (messages stored by the broker for new subscribers) and Session Persistence (preserving QoS 1/2 state of messages and subscriptions when the client disconnects) are implemented |
| Documentation | At the data level |
| Security | TLS/SSL, user/password, client certificates, OAuth 2.0 (via broker) |
| RPC support | No, implemented using the request/response pattern |
| Error Handling | Reason Codes and Properties (MQTT 5) - CONNACK – 0x80 (Unacceptable Protocol Version).- PUBACK / PUBREC – 0x80 (Not authorized).- The Reason String property provides a human-readable description. |
| Client Generation | - C/C++ – Eclipse Paho C, Mosquitto lib, Async MQTT Client. - Python – paho-mqtt, hbmqtt, asyncio-mqtt. - Java/Android – Eclipse Paho Java, HiveMQ MQTT Client. - JavaScript/Node.js – mqtt.js, @hivemq/mqtt-client. - Go – Eclipse Paho Go, gmqtt, hivemq/mqtt-client-go.** |
| Strong Typing | In pure MQTT, message types are not described, since the transmitted data is an arbitrary byte array. Strong typing is usually introduced at the data schema level (JSON Schema, Protobuf, Avro) and/or through the AsyncAPI description, where each topic is assigned a payload type. |
| Bidirectionality | Yes, a client can publish and subscribe simultaneously. This allows a sensor device to send measurements and receive control commands through different topics. |
| Real-time communication | Thanks to a small header (2–5 bytes) and QoS 0/1/2 support, MQTT ensures near-instantaneous delivery (latency ≈ 10–30 ms on a local network). When using WebSocket + TLS, latency increases to ~50-100 ms, which is still acceptable for most IoT applications (telemetry, lighting control, UI updates). With QoS 0, messages may be lost, but this allows for maximum speed. |
| Scalability | Brokers support a large number of connections (from tens of thousands to millions) due to: - Cluster / Federation. - Queue sharding |
Applicability
- Internet of Things (IoT). This is the primary and broadest application area for MQTT. The protocol is used to
communicate between billions of resource-constrained devices.
- Smart Home. MQTT underlies many automation systems. Temperature, humidity, and motion sensors, as well as smart lamps, plugs, and thermostats, use MQTT to send data to a central broker (e.g., Home Assistant, OpenHAB, or cloud services).
- Wearables. Fitness trackers and medical devices use MQTT to transmit health data (heart rate, glucose levels) to smartphones or cloud services, minimizing battery drain.
- Industrial Internet of Things (IIoT) and automation. In industry, MQTT enables efficient data collection from
equipment and sensors, which is critical for real-time production monitoring and control.
- Equipment monitoring. Sensors on production lines send data on machine status, temperature, pressure, and other parameters.
- Predictive Maintenance. Data collected via MQTT is used to analyze and prevent breakdowns before they occur.
- Transportation and Logistics. MQTT is used to provide communication between vehicles, control centers, and sensors
in logistics systems.
- Vehicle Tracking. Monitor the location, speed, and condition of trucks or trains in real time.
- Smart Cities. Control street lighting systems, monitor traffic, and monitor parking conditions.
- Unreliable and Satellite Networks. MQTT’s ability to handle high latency and frequent connection interruptions ( using QoS layers) makes it ideal for remote or mobile applications. Data collection from remote wells or pipelines, where the connection may be satellite or cellular with poor signal quality, is ideal.
- Mobile Apps and Notifications. Despite the availability of specialized services from Apple and Google, some chat apps and notification services use optimized MQTT implementations to quickly and efficiently deliver messages to mobile devices.
- Agriculture. MQTT is used in precision agriculture. Sensors for soil moisture, air temperature, pH, and other parameters transmit data to centralized systems to automate irrigation and fertilization.
Key Concepts
- Pub/Sub Model. Unlike the traditional client-server (request-response) model, where the client directly requests
data from the server, MQTT uses the Pub/Sub model.
- Broker. A central coordinator through which all messages flow.
- Publishers. Send messages on specific topics to the broker.
- Subscribers. Receive messages on topics they are interested in by subscribing to them through the broker.
- Decoupling. The publisher and subscriber are unaware of each other’s existence, ensuring high scalability and flexibility of the system.
- Lightweight and Efficient. MQTT was originally developed for resource-constrained devices (microcontrollers,
sensors) and low-bandwidth networks.
- Minimal data size. The fixed MQTT message header takes up only 2 bytes.
- Low power consumption. The efficient design allows devices to conserve battery power.
- Binary format. Messages are transmitted in binary form, which reduces overhead compared to text-based protocols such as HTTP.
- Quality of Service (QoS). MQTT offers three quality of service levels, allowing developers to balance delivery
reliability and data transfer speed:
- QoS 0 (At Most Once). The message is sent without delivery confirmation (“fire and forget”). Suitable for non-critical, frequently updated data (e.g., real-time temperature readings).
- QoS 1 (At Least Once). The message is guaranteed to be delivered, but may be received by the recipient multiple times (duplicates are possible). Used for important commands (e.g., turning a light on/off). - QoS 2 (Exactly Once). The highest level of reliability. Messages are delivered exactly once, without loss or duplication. Used for mission-critical data where accuracy is paramount (e.g., financial transactions).
- Working on TCP/IP. The MQTT protocol uses TCP/IP as the underlying transport protocol, ensuring a reliable, ordered connection.
- Resilience to unreliable networks. MQTT is designed to operate in unstable connection conditions, which are
typical for mobile or satellite networks.
- Persistent Sessions. Allow the client to quickly reconnect to the broker after a connection failure without losing subscriptions and queued messages.
- Last Will and Testament (LWT). The client can pre-define a message that the broker will automatically send to subscribers in the event of an unexpected client disconnection. 6. Security. Security is ensured through integration with existing standards, such as TLS/SSL encryption and authentication mechanisms (username/password).
Pros and Cons
| Pros | Cons |
|---|---|
| Lightweight and low resource consumption. The minimal message header size (from 2 bytes) and low protocol overhead allow its use on the weakest devices (microcontrollers with small memory) and in low-bandwidth networks. This also results in low power consumption, extending the lifespan of battery-powered devices. | Dependent on a central broker. The entire system is tied to the broker. If the broker fails or becomes a performance bottleneck (if it is not clustered), communication between all devices is interrupted. |
| Efficiency in unreliable networks. The protocol is designed to withstand frequent connection interruptions (typical of mobile and satellite networks). QoS (Quality of Service) and persistent sessions guarantee message delivery and quickly restore connections without data loss. | Lack of built-in encryption. The MQTT protocol itself does not provide data encryption. Security is implemented at the transport layer using TLS/SSL (as with HTTPS), which requires additional device resources and infrastructure configuration. |
| Publish/Subscribe model. Provides loose coupling (decoupling) between senders and receivers. They do not need to know each other’s IP addresses. This significantly simplifies scaling the system: new publishers or subscribers can be easily added without changing the existing architecture. | Not suitable for transferring large amounts of data. Although it is technically possible to transfer large files, the protocol is not optimized for this. It is designed for transferring small, frequent messages (telemetry). HTTP or FTP are better suited for transferring large files. |
| Ease of implementation. The protocol is easy to learn and has many ready-made client libraries for most programming languages and platforms. | Limited pure routing capabilities. Message routing is based solely on “topics”, which are hierarchical strings (e.g., home/livingroom/temp). This is simple, but less flexible than more complex routing protocols that use headers or complex rules. |
AMQP
The Advanced Message Queuing Protocol (AMQP) is an open, standard application-layer protocol designed for reliable and asynchronous messaging between various applications and systems. It ensures guaranteed data delivery even during failures and is widely used in microservices architectures.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | TCP |
| Formats | Binary. Message body – JSON, XML, Protobuf, Avro, and any other formats regardless of protocol. |
| Versioning | Via message body |
| Caching | No |
| Documentation | At the data transfer level |
| Security | TLS/SSL, SASL (PLAIN, EXTERNAL, SCRAM-SHA-1/256) for authentication |
| RPC support | No, but implemented via the request/response pattern |
| Error Handling | DLQ (dead-letter queue) – rejected or expired messages are redirected to a separate queue for further analysis. |
| Client Generation | - Java – amqp-client- .NET – RabbitMQ.Client- Python – pika- Go – streadway/amqp- Node.js – amqplib |
| Strong Typing | Data-Level |
| Bidirectional | Yes |
| Real-Time Exchange | Thanks to its low latency (less than a millisecond on a local cluster) and push model (messages are delivered immediately after publication), AMQP is suitable for real-time applications: chat applications, online games, financial tickers, sensor monitoring. If necessary, QoS = 0/1/2 (RabbitMQ) or flow control (AMQP 1.0) can be enabled to guarantee delivery without performance degradation. |
| Scalability | AMQP brokers (RabbitMQ, Apache Qpid, Azure Service Bus) support clustering, federation, and sharding. Messages can be replicated between nodes, and queues can be mirrored (RabbitMQ) or partitioned (Azure Service Bus). As the load increases, new nodes are added, and client libraries automatically balance connections. AMQP 1.0 also supports link-routing and address-based routing, making it easier to build large-scale topologies without changing client code. |
Applicability
- Microservice architecture. AMQP is the foundation for communication between independent microservices. It allows services to exchange messages asynchronously, without requiring knowledge of each other’s availability or location. This ensures fault tolerance and simplifies scaling of individual system components.
- Financial sector and banking. In this industry, reliability is paramount. AMQP is used to process and transmit financial transactions, trading data, and market position updates, ensuring that no message (transaction) is lost, even during system failures.
- Distributed task processing (task queues). Applications often involve resource-intensive tasks (e.g., generating PDF reports, scaling images, sending large numbers of emails). AMQP is used to create queues to which such tasks are submitted. Separate “worker” processes (workers) retrieve tasks from the queue and execute them in the background, without delaying the main user interface.
- Real-Time Systems and the Internet of Things (IoT). In systems where data comes from multiple sensors (e.g., industrial IoT or oceanographic research), AMQP ensures reliable, low-latency delivery of data streams from devices to central processing servers.
- Large-Scale Enterprise Integrations (EAI). AMQP is used as the basis for enterprise event buses or message brokers that integrate multiple disparate information systems within a company (e.g., inventory management, order processing, customer communications).
- Cloud Computing. Large cloud providers such as Amazon Web Services (AWS) and Microsoft Azure use AMQP to enable internal communication between different cloud services and to provide reliable message queuing services to their customers.
Key Concepts
- Reliability. The main advantage. AMQP guarantees message delivery using acknowledgement mechanisms. A message is not considered delivered until the receiver explicitly acknowledges its processing. This prevents data loss.
- Asynchronous Messaging. Message exchange occurs asynchronously. The sender does not wait for a response from the receiver, allowing both services to operate independently. This improves overall system throughput and performance.
- Loose Coupling. Producers and consumers are unaware of each other. They interact only through an intermediary—the message broker. This significantly simplifies the development, testing, and scaling of individual components.
- Guaranteed Delivery. The protocol supports persistence: messages can be stored on the broker’s disk until delivery, surviving system restarts or network failures.
- Flexible Routing. AMQP offers powerful routing mechanisms through exchanges. Messages can be routed to one or multiple queues based on various criteria (routing patterns: fanout, direct, topic, headers).
- Platform and Language Independence. AMQP is an open standard. Client libraries exist for all major programming languages (Java, Python, .NET, Ruby, PHP, etc.) and operating systems, ensuring excellent compatibility.
- Security. The protocol supports various user authentication mechanisms and data encryption during transmission (via TLS/SSL).
- Transactions. AMQP allows you to combine multiple message operations (sending, receiving, acknowledging) into a single transaction, ensuring their execution on an all-or-nothing basis.
Pros and Cons
| Pros | Cons |
|---|---|
| High reliability and guaranteed delivery. This is the main advantage. Acknowledgements, persistence (storage on disk), and transaction mechanisms ensure that important messages are not lost even during network failures or broker/receiver downtime. | Increased protocol complexity. AMQP is a feature-rich and fairly complex protocol. Configuring, administering, and understanding all the intricacies of routing and delivery modes requires more effort and expertise than simpler protocols (e.g., HTTP requests or MQTT). |
| Vendor Independence (Open Standard). AMQP is an open, standardized protocol. You are not tied to a specific product or cloud provider. You can easily replace RabbitMQ with another broker that supports AMQP without having to rewrite your application logic. | Performance Overhead. Guaranteed delivery and persistence mechanisms require additional disk writes and network acknowledgements. In scenarios where speed is more important than 100% delivery guarantees, AMQP may be slower than more lightweight solutions (such as Kafka or pure UDP connections). |
| Cross-platform and language support. Client implementations exist for virtually any programming language (Java, Python, Go, .NET, Ruby, PHP), ensuring easy integration of disparate systems. | Brokerator Resource Requirements. To ensure reliability and store large volumes of messages, an AMQP broker (such as RabbitMQ) can consume a significant amount of RAM or disk space. |
| Flexible and complex routing. A powerful system of exchanges enables complex message delivery scenarios (for example, sending a message to multiple subscribers using topic routing). | Not always optimal for streaming. While AMQP is great for task queues, it was not originally designed as a platform for large-scale data streaming. For these tasks, solutions like Apache Kafka or Pulsar often demonstrate better performance and scalability. |
| Scalability and loose coupling. Using a broker as an intermediary allows for easy scaling of senders and receivers independently. |
EDI
Electronic Data Interchange (EDI) is an automated technology that allows companies to exchange business documents in a standardized electronic format between their computer systems without human intervention.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | AS2 (Applicability Statement 2), FTP / SFTP, OFTP (Odette File Transfer Protocol), HTTPS-API (REST/SOAP) |
| Formats | EDIFACT (UN/EDIFACT), ANSI X12, XML-EDI (e.g., cXML, UBL, RosettaNet), JSON-EDI |
| Versioning | ? |
| Caching | Client- and server-side |
| Documentation | UN/EDIFACT, ANSI X12 |
| Security | TLS/SSL, Digital Signatures (PKCS#7, S/MIME), MDN (Message Disposition Notification), PGP/GPG |
| RPC support | No, but: - Some VAN solutions allow synchronous request-response via AS2-request/response. - When integrating via a REST/SOAP API (e.g., “EDI-as-a-service”), RPC-like calls can be implemented. |
| Error Handling | - 997 Functional Acknowledgment (X12) – acknowledges receipt and indicates syntax errors. - CONTRL/UNH (EDIFACT) – similar to the control segment (UNH-CONTRL). - MDN (AS2) – may contain the status 200 OK, 400 Bad Request, 500 Error, and a detailed description of the problem. - NACK/REJECT messages in modern API wrappers (JSON-EDI). |
| Client Generation | - EDI generators: IBM Sterling B2B Integrator, Seeburger BIS, MuleSoft Anypoint Platform, Microsoft BizTalk Server, SAP PI/PO - Open source: Smooks, Mendelson EDI, bots-edi, PyX12, EDIFACT-parser - Low-code/No-code platforms (Boomi, SnapLogic) |
| Strong Typing | XSD-based schemas for XML-EDI (UBL, cXML), EDIFACT-/X12-schema as EDI-DTD or JSON-Schema |
| Bidirectionality | - VAN platforms support “inbound” and “outbound” queues, allowing both parties to initiate a transfer at any time. - AS2/HTTPS APIs allow a request (send) to be initiated and a response (receive) to be received within a single connection, making the channel fully bidirectional. |
| Real-time exchange | - AS2 request/response and HTTPS API (REST/SOAP) enable document transfer within milliseconds, which is suitable for order-to-cash with near-real-time requirements. - Event-driven architecture: messages are published to Kafka/RabbitMQ upon receipt from the VAN, and consumers process them instantly. - WebSocket/gRPC-over-EDI – experimental solutions where a binary EDI packet is encapsulated in a streaming protocol for ultra-low-latency scenarios (e.g., autopilot logistics). |
| Scalability | - Horizontal scaling of VAN clusters and cloud EDI platforms (AWS EDI, Azure Logic Apps) – adding nodes without downtime. - Batch processing + parallel file transfer (multi-threaded SFTP, OFTP-2) allow processing hundreds of thousands of documents per hour. |
Applicability
- Logistics and Supply Chain Management. The system automates the entire product flow from manufacturer to end
customer.
- Interaction with carriers. Transfer cargo data, track delivery statuses, and issue freight invoices.
- Warehouse management. Automatic incoming shipment notifications (ASN), allowing you to prepare your warehouse for receiving goods in advance.
- Inventory optimization. Exchange warehouse balance data in near real time.
- Retail. Large retail chains require their suppliers to use EDI to standardize and speed up purchasing processes.
- Order processing. Instant order transfer from the retail chain to the supplier.
- Invoicing. Automatic generation and sending of invoices, speeding up the payment process.
- Shipment Notifications. Suppliers send ASN (Advanced Shipping Notices), which helps stores plan the receipt of goods.
- Manufacturing. EDI helps manufacturing companies synchronize their processes with raw material and component
suppliers, as well as finished product distributors.
- Production Planning. Exchange demand forecasts and supply plans (Forecasts and Schedules).
- Just-in-Time Component Delivery. Ensuring assembly line continuity through accurate and automated data exchange.
- Finance and Banking. EDI is used to automate financial transactions and exchange payment information between banks
and corporate clients.
- Electronic Payments. Exchange of funds transfer instructions (EFT – Electronic Funds Transfer).
- Bank Statements. Automated transfer of account information.
- Healthcare and Insurance. In this area, EDI helps standardize data exchange between hospitals, pharmacies,
insurance companies, and government agencies.
- Insurance claims processing. Electronic submission and processing of reimbursement claims.
- Medication inventory management. Automated ordering of medications and equipment from suppliers.
- Energy and utilities. Companies use EDI to exchange data on resource consumption, billing, and customer transfers between service providers.
Key concepts
- Standardization of data formats. This is a key characteristic of EDI. For computer systems from different
companies to “understand” each other, information must be transmitted in a strictly defined, generally accepted
format.
- Use of standards. EDI relies on international or industry standards, such as UN/EDIFACT (the most common international standard), ANSI X12 (dominant in North America), TRADACOMS (used in British retail), and others.
- Universal “language.” These standards define the precise structure of the document (for example, the location of the order number, total amount, date, etc.), eliminating misinterpretations.
- Automation. EDI minimizes or completely eliminates human intervention in the exchange and processing of business
documents.
- Elimination of manual entry. The document is created in the sender’s outgoing ERP system (e.g., 1C or SAP) and automatically uploaded to the recipient’s incoming ERP system.
- Processing speed. Automation allows for the processing of thousands of documents in minutes, which is impossible with a manual approach.
- Structured data exchange. Unlike traditional email or fax, where data is unstructured and requires manual interpretation, EDI transmits data in a machine-readable, structured form.
- Business document transfer. EDI is designed specifically for the exchange of commercial documents (invoices, orders, delivery notes).
- Ready for processing. Received data is immediately ready for use in the recipient company’s business processes.
- Security and reliability. The transfer of confidential commercial information requires a high level of security.
- Secure protocols. Data exchange occurs over secure communication channels (VPN, FTPS, AS2), rather than over the regular, unsecured internet.
- Delivery confirmation. EDI systems typically include mechanisms for confirming receipt and document processing, ensuring that no documents are lost.
- Platform independence. The sender and recipient systems may use completely different software (for example, the sender uses SAP on Linux, and the recipient uses 1C on Windows). The EDI provider or internal software takes on the task of converting the company’s internal formats to the universal EDI standard and vice versa.
Pros and Cons
| Pros | Cons |
|---|---|
| Cost Reduction. EDI eliminates the costs associated with paper documents (paper, printing, postage, archiving). Automation eliminates the need for manual data entry, freeing employees to focus on higher-priority tasks. | High Initial Costs and Implementation Complexity. EDI implementation requires specialized software, provider services, and integration with an internal accounting system (ERP, 1C, SAP). This requires a significant financial investment. The integration process can be technically complex and time-consuming, requiring the involvement of qualified IT specialists. |
| Increased Speed and Efficiency. Unlike mail or fax, EDI documents are delivered and processed almost instantly. This accelerates the entire transaction cycle—from order to payment. Fast order and invoice processing improves cash flow and inventory turnover. | Dependence on standards and providers. International and industry EDI standards are periodically updated, requiring ongoing technical support and changes to system settings. Many companies use value-added networks (VANs) for data exchange. This means additional ongoing costs for the provider’s services and dependence on their stability. |
| Minimization of errors. Manual data entry inevitably leads to errors (typos in amounts, addresses, and part numbers). EDI transfers data directly from system to system, guaranteeing its accuracy. | Format rigidity. EDI requires strict adherence to data formats. Even the slightest deviation from the standard can result in the rejection of the entire document by the counterparty’s system. Small partners who don’t use EDI must maintain parallel (manual or hybrid) document exchange processes. |
| Improving Partner Relationships. Many large companies (especially in retail) require their suppliers to use EDI. The ability to work with EDI is a significant competitive advantage. EDI provides better transaction and order status visibility for all participants in the supply chain. |
CoAP
Constrained Application Protocol (CoAP) is a lightweight application protocol designed specifically for use in resource-constrained devices (e.g., sensors, embedded systems, wearables) in the Internet of Things (IoT).
| Features | Description and Examples |
|---|---|
| Protocol/Transport | UDP (IPv4/IPv6) |
| Formats | Binary, compact (4-byte header + options). The message body can be in any format: CBOR (RFC 7049) – recommended for small resources, JSON, XML, Plain-text, Protobuf, etc. |
| Versioning | Via message body |
| Caching | Built-in caching mechanism similar to HTTP: ETag, If-None-Match, Max-Age, Cache-Control options |
| Documentation | Depending on the message body format |
| Security | DTLS 1.2 (RFC 6347), OSCORE (RFC 8613), CoAP over TCP/TLS (RFC 7967) for networks where TCP is preferred. |
| RPC Support | CoAP implements request-response (GET, POST, PUT, DELETE). For RPC, POST/PUT are often used with a body containing a method call (e.g., JSON-RPC or CBOR-encoded). Observe is also possible – a callback (push) from the server to the client, which is convenient for asynchronous RPC. |
| Client Generation | - libcoap (C), Eclipse Californian (Java), CoAPthon (Python), node-coap (Node.js), aiocoap (async-Python). - CoAP-CLI, Copper (CoAP Chrome Extension), Mbed CoAP (C++) tools. |
| Strong Typing | For strong typing, CBOR is typically used in conjunction with COSE-CWT or CBOR-Schema (RFC 8949 + RFC 8949-Schema). |
| Bidirectionality | No, bidirectionality can be achieved in several ways: - Separate response – the client receives an empty ACK, and the server later sends a separate response. - Observe – the server initiates sending notifications to the client without a new request. - CoAP-over-TCP – supports multiplexed streams, allowing the client and server to open multiple independent dialogs in a single connection. |
| Real-time exchange | For low-latency and real-time scenarios, use: - Non-confirmable (NON) messages – no ACK, minimal latency. - Observe + Confirmable (CON) notifications to guarantee the delivery of critical events. - Block-wise transfer (RFC 7959) – allows for the transmission of large packets in chunks without increasing latency. |
| Scalability | CoAP is designed for large-scale IoT networks: - Multicast requests ( GET coap://[ff02::fd]/.well-known/core) allow polling hundreds of devices simultaneously.- Proxy/Cache – intermediate nodes cache responses, reducing the load on final resources. - Lightweight header (4 bytes) and binary encoding save bandwidth. - DTLS-PSK ensures a fast handshake without expensive certificates. |
Applicability
- Smart Home Automation. IoT devices such as smart thermostats, door sensors, lighting fixtures, and other household sensors use CoAP to communicate with a central hub or gateway. The protocol’s lightweight nature allows these devices to operate efficiently and conserve energy.
- Wireless Sensor Networks (WSNs). CoAP is ideal for networks consisting of numerous low-power sensors scattered over a large area, such as environmental, agricultural, or infrastructure monitoring.
- Industrial Internet of Things (IIoT). In industrial settings that require collecting data from equipment or controlling automated systems over limited networks (M2M communications), CoAP provides an efficient and reliable communication method.
- Smart Grids. It is used in smart metering and energy management systems where minimal resource consumption and data transfer over constrained networks are critical.
- Wearables and healthcare. In battery-powered devices (fitness trackers, medical sensors), CoAP helps transfer data while minimizing power consumption and extending battery life.
Key concepts
- Operating over UDP. CoAP uses the User Datagram Protocol (UDP) instead of TCP, reducing the overhead of establishing and maintaining a connection. This is critical for low-power devices and unstable networks.
- Lightweight and low overhead. The protocol is designed with minimal resource consumption. The fixed CoAP header size is only 4 bytes, reducing the amount of data transferred and, consequently, conserving bandwidth and battery life on devices.
- REST-like architecture. CoAP supports RESTful architecture principles similar to HTTP. It uses standard request methods such as GET, POST, PUT, and DELETE, simplifying integration with existing web services and HTTP proxying.
- Reliability mechanisms (optional). Despite using UDP, CoAP includes a built-in messaging layer that provides optional reliable delivery using Confirmable (CON) and Non-Confirmable (NON) messages. A retransmission mechanism ensures the delivery of important data.
- Asynchronous Messaging Support. CoAP allows a client to send a request and receive a response later (a separate response), which helps efficiently manage device resources and reduce radio activity.
- Resource Discovery. The protocol supports a resource discovery mechanism, allowing clients to find available resources on a server (e.g., via URI paths), simplifying device management on the network.
- Security. To ensure data confidentiality and integrity, CoAP uses DTLS (Datagram Transport Layer Security), a TLS/SSL analog adapted to run over UDP.
- Multicast Support. Unlike HTTP, CoAP supports multicasting of requests, allowing a client to send a single request to a group of devices simultaneously.
Pros and Cons
| Pros | Cons |
|---|---|
| Efficient resource usage. This is the main advantage of CoAP. It is designed to run on devices with very limited memory, low processing power, and low power consumption. | Dependence on UDP (potential disadvantage). While running on top of UDP provides efficiency, it also means that CoAP must implement its own reliability, fragmentation, and congestion control mechanisms, which makes it more complex to implement compared to using TCP. |
| Low overhead. The minimal header size (4 bytes) and compact message format save network bandwidth and battery power, which is critical for large-scale IoT networks. | Lack of native support in standard browsers. Browsers do not support CoAP out of the box. Interacting with CoAP devices from web applications typically requires specialized proxy servers or gateways that translate HTTP requests into CoAP requests. |
| Working over UDP. Using UDP eliminates TCP’s connection establishment and teardown overhead, which speeds up data transfers and reduces latency in networks with packet loss. | Difficulty of working with large data volumes. While CoAP is suitable for small messages (sensor readings), transferring large files or streaming data can be inefficient due to UDP packet size limitations and the need for data fragmentation. |
| REST-compatible. CoAP uses an architecture familiar to web developers (GET, POST, PUT, DELETE methods), simplifying the integration of IoT devices with existing web services and cloud platforms. | Limited tool ecosystem. Compared to the ubiquitous HTTP, CoAP has fewer available debugging tools, libraries, and ready-made solutions, although this is gradually improving. |
| Reliability Mechanisms. Although UDP is unreliable, CoAP has a built-in acknowledged message retransmission (CON) layer, ensuring that important data is delivered when needed. | NAT Traversal Complexity. Working with devices behind firewalls and NAT (Network Address Translation) can be challenging when using UDP, as sessions are more difficult to keep open than with TCP. |
| Security Support (DTLS). The protocol includes a standard encryption mechanism using Datagram Transport Layer Security, ensuring secure communication even on resource-constrained networks. |
WebRTC DataChannel
WebRTC DataChannel is a part of WebRTC (Web Real-Time Communication) technology that provides a bidirectional, secure channel for direct transmission of arbitrary text or binary data (such as files) between two peers (browsers or other WebRTC-enabled applications) in real time without the need for an intermediate server.
| Features | Description and Examples |
|---|---|
| Protocol/Transport | DataChannel is implemented on top of SCTP (Stream Control Transmission Protocol), which is encapsulated in DTLS (for encryption) and transmitted over UDP via the ICE transport. |
| Formats | Supported strings (UTF-8) and binary data: ArrayBuffer, Blob, TypedArray. |
| Versioning | No, versioning is implemented at the application level (for example, in message metadata or the channel name). |
| Caching | No. For reliable delivery in reliable mode, SCTP retransmits lost packets. If message caching is necessary (for example, during a temporary loss of connection), the application should implement its own buffer. |
| Documentation | No |
| Security | DTLS, authentication occurs via certificate exchange |
| Error Transmission | - The onerror event reports SCTP/DTLS layer problems.- When a channel is closed, the code and reason are transmitted ( closeEvent.code, closeEvent.reason).- At the application level, you can include the error field in messages (e.g., { "type":"error", "code":123, "msg":"Invalid payload" }). |
| Client Generation | - SimplePeer (RTCPeerConnection wrapper). - PeerJS (server-side signaling + API). - webrtc-datachannel (C++/C# wrappers). |
| Strong Typing | In JavaScript, types are checked only at runtime, so TypeScript or serialization schemes (Protobuf, FlatBuffers, MessagePack) are typically used for strong typing. |
| Bidirectionality | DataChannel is fully bidirectional – any participant can simultaneously send and receive data without opening a separate channel. |
| Real-time exchange | Thanks to the low latency of UDP + SCTP and the absence of intermediate servers, DataChannel is suitable for instant exchange: chat, collaborative editing, game events, telemetry transmission. |
| Scalability | - Multiple channels: a single RTCPeerConnection can hold up to 65,535 logical SCTP streams, allowing you to create separate channels for different data types (chat, files, signals).- Signaling clustering: for large P2P networks, distributed signaling (WebSocket sharding, Redis Pub/Sub) and mesh or SFU architecture are used, where the SFU only relays SDP and ICE, while the DataChannel connections themselves remain P2P. - Browser limitations: most browsers limit the total volume of data sent (≈ 16 MB/sec) and the number of open channels (≈ 50-100) - if necessary, you should group messages or use compression (gzip, brotli). |
Applicability
- Multiplayer games. Transmitting game logic, game state information, player positions, and control commands with minimal latency is critical for smooth gameplay. Unreliable DataChannel mode is often used for this purpose.
- Text chats and instant messaging. Providing instant, real-time messaging, often in addition to audio and video communication, in collaboration applications or social networks.
- P2P file transfer. Direct exchange of large files between users, which reduces the load on the server infrastructure and increases transfer speed. An example of such an application is the WebTorrent client.
- Collaborative editing. Applications that allow multiple users to simultaneously work on a single document, presentation, or code snippet. DataChannel synchronizes changes between peers in real time.
- Remote Control and IoT. Transmitting control commands or telemetry data between devices within the Internet of Things (IoT). For example, remote control of CCTV cameras, drones, or smart home devices.
- Data Synchronization. Using DataChannel to synchronize metadata, events, or auxiliary information with the main media stream (audio/video) in video conferencing or online learning applications.
- Cloud Computing and Streaming. In some cases, DataChannel can be used to transfer data between a client browser and a remote desktop or cloud gaming service.
Key concepts
- Connection Type and Security
- P2P (Peer-to-Peer) connection. Establishes a direct connection between two endpoints (e.g., two browsers) without the need to constantly transfer data through an intermediate server. This ensures minimal latency.
- Security. All data transmitted through the channel is encrypted by default. The DTLS (Datagram Transport Layer Security) protocol is used, guaranteeing the confidentiality and integrity of transmitted information.
- Cross-platform. DataChannel is part of the WebRTC standard, supported by all modern web browsers (Chrome, Firefox, Safari, Edge) and native applications on mobile platforms (iOS, Android).
- Flexibility and Reliability of Data Delivery. DataChannel is built on the SCTP (Stream Control Transmission Protocol), which runs on top of UDP and provides developers with a choice of two main delivery modes: reliable and unreliable.
- Performance and Throughput
- Low Latency. Direct P2P connections and the use of UDP in unreliable mode minimize network latency, which is critical for interactive applications.
- High Throughput. DataChannel can efficiently use all available bandwidth between peers to quickly transfer large amounts of data.
- NAT Traversal Support. WebRTC uses STUN and TURN technologies to overcome issues with NATs and firewalls, enabling connections even in challenging network conditions.
- Data Types
- Support for various formats. The channel can transmit both text data (strings) and binary data.
- Asynchronous API. The DataChannel interface uses asynchronous events (such as
onmessage,onopen), simplifying integration into non-blocking environments such as web browsers.
Pros and Cons
| Pros | Cons |
|---|---|
| Low Latency. The main advantage of P2P communication. Data is transferred directly between peers, bypassing an intermediate server, which is critical for online gaming, collaborative editing, and other real-time interactive applications. | Difficulty establishing a P2P connection (NAT Traversal). Despite the use of STUN/TURN servers to traverse firewalls (NAT), it is not always possible to establish a direct P2P connection (especially in corporate networks with strict firewalls). In such cases, all traffic must be routed through a TURN server, which negates the benefits of P2P in reducing server load. |
| Reduced server load and resource conservation. The server is used only for the connection establishment phase (signaling), and not for transmitting the data traffic itself. This significantly reduces bandwidth and server capacity costs. | Client bandwidth dependence. The quality and speed of data transfer directly depend on the internet connection speed of both parties. If one user has a poor channel, it will affect the entire connection. |
| High throughput. DataChannel can use the maximum available connection speed between two peers, which is ideal for quickly transferring large files. | No default server logic. Applications using DataChannel often require an additional server for signaling (exchanging information necessary to establish a connection) and for a backup TURN server. This adds complexity to the architecture. |
| Built-in security. All connections are encrypted by default using DTLS, providing a high level of security without additional effort from the developer. | Limits on the number of peers in a single session. WebRTC was originally designed for point-to-point connections. Building complex multi-user networks (mesh networks) can be difficult or inefficient, as each client must maintain a connection with every other client. Larger groups typically require more complex server solutions (SFU/MCU). |
| Flexibility of delivery modes (Reliable/Unreliable). The developer can choose between guaranteed delivery (for chats and files) and non-guaranteed but very fast delivery (for games), tailoring the channel to the specific needs of the application. | Connection reliability. Although a P2P connection is fast, its stability can be less predictable than a connection to a reliable, high-performance cloud server, since it depends on the stability of the home or mobile users’ networks. |
| Cross-browser and cross-platform support. It is an open standard and is supported by all major modern browsers and mobile platforms. |