RFC6733 say that "At a minimum, a Diameter node SHOULD have an established connection with two peers per realm, known as the primary and secondary peers.the mechanisms (manual configuration and DNS)are used to discovery remote peer. "
How do I know which peer is the primary peer and which peer is the secondary peer in a realm?
This is a decision made by the Diameter host itself - it's not a property of the peers. In particular, it's possible for one Diameter host to decide that one peer is its primary and for another Diameter host to decide that a different peer is its primary, even if both peers are in the same realm.
Having said that, it's possible that the choice of primary peer can be influenced by the administrator.
Depending on your Diameter stack, you may be able to configure which peer to prefer.
If you are using DNS SRV to determine your peers, you can set a priority in the SRV record, which the Diameter host should honor.
The main reason for having a secondary peer is so that, on failure of the primary, the Diameter host can immediately fail over to sending traffic to the secondary peer.