The Simple Magic of the Forwarding Replica
Image: Alexei von Wahl w/Flickr
Perforce replicas support a variety of different configurations. The most basic replica type is the read-only replica, but there are several other types of replicas that you can deploy.
The Forwarding Replica is one of my favorites.
A Forwarding Replica combines some of the best features of the Perforce Proxy with some of the best features of the Perforce Replica.
All Perforce replica servers implement read-only commands, such as 'p4 files', 'p4 describe', 'p4 annotate', and 'p4 diff2'. But when a Read Only Replica receives a request which it does not support (namely, a command which is not read-only), it refuses that request:
p4 edit //depot/main/jam.c Replica does not support this command.
However, when a Forwarding Replica receives a request which is not read-only, it automatically forwards that request to the master server for processing:
p4 edit //depot/main/jam.c //depot/main/jam.c#4 - opened for edit
After forwarding your request to the master server, the Forwarding Replica automatically waits for the results of that command to be replicated back to the replica server before continuing with your next command.
This simple change in behavior means that the Forwarding Replica supports the complete Perforce command set, not a limited subset, and so you can set your P4PORT to point to a Forwarding Replica and do all your normal work. Whenever you issue a read-only command, the Forwarding Replica processes that command locally, without incurring any work on your master server.
Since many commands are read-only commands, this results in a substantial transfer of workload off of your master server, which improves the overall experience for all of your users.
Furthermore, the Forwarding Replica also provides local caching of file content for 'p4 sync' commands issued via the replica. Just like the Perforce Proxy, 'p4 sync' commands issued to a remote master server via a local Forwarding Replica will be faster than if you issued them directly to your master server, because although the database changes must be performed at the master server, the files are transferred to your workstation from the Forwarding Replica's cache.
So a Forwarding Replica supports the full Perforce command set, just like a proxy, and it caches file contents locally, just like a proxy, but it also implements all read-only commands locally, just like a Read Only Replica.
Deploying and operating a Forwarding Replica is almost identical to deploying and operating a Read Only Replica; the only difference is that you specify
in your 'p4 server' spec. You can find more information about this in the online documentation.
It's just some simple magic, but it can make a big difference. If you haven't yet tried using a Forwarding Replica, give it a try!