Skip to content
Server Infrastructure

Server Infrastructure

Peerix is designed to work in a decentralized manner, allowing peers to connect directly to each other without relying on a central server for media relay. However, it does require a signaling server for peers to discover each other and establish connections. For better connectivity and performance, especially in restrictive network environments, it is recommended to use a TURN server for media relay when direct peer-to-peer connections are not possible.

The server infrastructure for Peerix consists of two main components:

  • NATS is a high-performance messaging system that enables efficient communication between peers for signaling purposes. Due to its scalability and reliability, it is recommended for use in production applications. Using NATS allows you to use Peerix without any server-side code because all signaling is handled through NATS servers.
  • TURN is a protocol that allows peers to relay media through a server when direct peer-to-peer communication is not possible due to network restrictions. Using a TURN server ensures that your application can maintain connectivity even in challenging network conditions, such as behind NAT or firewall.

The following diagram illustrates the relationship between Peerix, NATS, and TURN servers:

    graph TD
  PX(Peerix) --> ND(NATS Driver)
  ND --> NATS(NATS Server)
  PX --> TURN(TURN Server)
  

You can choose one of the following options to set up your server infrastructure: