You can run an external PostgreSQL database in high availability for increased resiliency (available from Xray version 3.54.5 and Postgres 13). For information on setting up PostgreSQL database in high availability mode, see High Availability in PostgreSQL Database.
To avoid latency in the Xray database transactions, you should declare replication as asynchronous in PostgreSQL HA. Replication lag depends on several factors including setup, network latency and database load. In addition to declaring asynchronous replication, to minimize the potential for data loss in case of failover, you should also monitor the replication lag and take steps to avoid it. For specific information about how to do this, read about the
replay_lag column, which approximates the delay before recent transactions become visible to queries.