# Peer discovery

Discovery maintains a register of providers and consumers of data services, which allows DataSource applications to find and connect to each other at runtime without the necessity of using [`add-peer`](../datasource/datasource-datasource-peers-configuration-part-1.md#add-peer) to configure connections between specific DataSources at specific network locations.

In a traditional deployment, connections between named DataSources are configured in advance using complementary pairs of [`add-peer`](../datasource/datasource-datasource-peers-configuration-part-1.md#add-peer) configuration items, one on each side of the connection. The  `add-peer` block of the DataSouce responsible for initiating the connection includes the network location of its peer (`addr` and `port` options).

**DataSource connection configuration in a traditional deployment**

![discovery-peer-discovery-1](../../images/discovery-peer-discovery-1.png)

In a deployment that uses Discovery’s peer discovery, connections are not configured prior to deployment but discovered at runtime. Discovery maintains a register of DataSources in the deployment that includes their network locations, the data services they are configured with, and the data services they provide. Through this register, providing peers know which DataSources to connect to, and consuming peers know which DataSources to permit connections from.

The role of `add-peer` is replaced by `discovery-provide-service __service_name__` configuration in providing peers. A DataSource configured with `discovery-provide-service __service_name__` consults the Discovery register for DataSources configured with a data service named `__service_name__` and automatically connects to them. 

**DataSource connection configuration with Discovery’s peer discovery**

![discovery-peer-discovery-2](../../images/discovery-peer-discovery-2.png)

Peer discovery provides scalable peer connectivity, allowing you to add new component instances to a deployment at runtime without downtime for reconfiguration. However, for data services to take advantage of new component instances, you need Discovery’s [scalable data services](discovery-scalable-data-services.md).

---

**See also:**

* [Migrate to peer discovery](discovery-migrating-peer-discovery.md)
