During certain interval there is huge WAL file generation f3om primary around 300gb/hr which delays sync in secondary by atleast 30 mins. Other time it is normal
I assume this is streaming replication? What’s the network configuration between the nodes? When I was replicating across the pond (high latency); I would monitor the lag and if it fell behind by several gigabytes the script would ship the WAL files in parallel to the remote WAL backup server across the pond. It then terminated the streaming replication which would force the DR replica to pull the WAL files from its local backup server which was much faster than streaming replication (a single tcp connection) over a high latency connection.
What’s the replication configuration? Is the replica a hot standby with active queries? What’s the I/o subsystems on both systems?