Introduction
A service registry is a database for the storage of data structures for application-level communication. It serves as a central location where app developers can register and find the schemas used for particular apps.
Using a service registry with Apache Kafka
Using Apache Kafka as a use case, let's examine how a service registry works. Service registry is ideal in this particular use case because Kafka does not provide consumers with the data structure automatically, and Kafka does not provide any data verification. Since Kafka does not parse or even read your data, it does not use up vital resources, and consequently is able to distribute data directly to the consumers very quickly. If Kafka did take the time to verify data, the performance would be much lower. So the lack of data governance is not a problem with Kafka. Just the opposite, it enables one of the main advantages of Kafka: high performance.
However, you must implement some other governance on the structure of the data, to ensure the consuming applications can consume the data properly. The solution is a service registry, which not only provides rules but also enforces them.
Consumers and producers exchange data via Kafka, and using a service registry allows producers and consumers to document, share and agree on the metadata that defines the traffic, from the start, to avoid data-related errors down the road. The metadata is provided in the form of schemas stored in the service registry.
The developer of the producer application registers the schema in the service registry, which then ensures that the producer is adhering to the specifications of its own schema. The service registry will even go so far as to reject bad data that does not conform to the registered schema.
Schemas can be registered by a developer of a specific producer application, as shown in the example above, or they can be registered by an organization for general use among the development team. In this second case, the service registry functions as a library for developers of producer applications, as well as consumer applications.
Meanwhile, developers of consumer applications also utilize the service registry like a library, retrieving schemas so they are able to build applications that consume the data from producer applications. When changes are made to the schema, the service registry provides consumers with the latest updated schema.
Benefits of a service registry
A service registry delivers the following advantages to the development team and the business:
Decouple data structure from applications
You can use a service registry to decouple the structure of your data from your applications and to share and manage your data structures and API descriptions at runtime using a REST interface.
Superior data quality
A service registry validates the schema and detects errors in the data to ensure data integrity. The service registry can include rules to ensure that uploaded content is syntactically and semantically valid, and is backward and forward compatible with other versions. However, the service registry will stop a producer from sending bad data that does not conform to the schema.
Single documented source of truth
Service registry provides a single source of the truth, validated and agreed upon by all parties involved.
Increased developer productivity
The service registry enables consistent reuse of schemas and API designs, saving developers time when building a producer or consumer application.
Cost savings
Detecting data-related errors early in the development lifecycle, rather than at runtime, saves on the higher costs of development time incurred when fixing errors downstream in the process.