August 20, 2013

Identify Your Servers with Server Ids

Traceability
Version Control

magnifying-glass

Image: Brian D Perskin W/Flickr

Most Perforce installations have only a single server, which is no surprise, since a single well-administered Perforce server can easily serve the needs of several hundred very active users.

But at some point, as your Perforce installation grows in size and complexity, it is quite likely that you will find yourself deploying multiple servers.

  • You might decide to deploy a read-only replica as a stand-by spare, or to use for offline checkpointing.
  • Or you might deploy a read-only replica to a separate location, as part of your disaster recovery preparedness.
  • As your organization adopts Continuous Integration practices, you might decide to provide a build farm replica to shoulder the automation workload.
  • As you expand to multiple offices, you might find that your remote users need better performance, and so you might deploy a forwarding replica or perhaps an edge server in that remote office.

One way or another, you're probably going to find that your Perforce installation ends up with multiple servers.

Expanding to multiple servers is straightforward, but you may find that keeping track of all your different servers becomes confusing. When it comes to things like communicating with your colleagues, or documenting your administrative processes, it is useful to be able to precisely refer to each server distinctly.

This is where it is helpful to use the p4 server, p4 servers, and p4 serveridcommands. These commands are designed to let you describe all your Perforce servers in a precise and compact fashion, and the resulting data is useful both for you and for your Perforce servers themselves.

  1. The first step is to choose a unique id for each server. You might, for example, call your primary server "Master" and call your stand-by spare "Spare", while choosing "BuildHost" for your build automation server and "MiamiOffice" for the forwarding replica you deploy to your colleagues in Florida.
  2. Use the p4 servercommand to fill in the details about each server. For simplicitly, I strongly recommend that you use the same value for both the ServerID and the Name. Taking the time to provide a meaningful Description of each server will pay off later, when you are training a new associate and they can consult these notes to understand the layout of your overall installation.
  3. Next, use the p4 serveridcommand to configure each server with its server id. The server id will be written to the file "server.id" in the P4ROOT directory, and the server will read this file automatically when it starts up, thus remembering its server id from run to run.

Note that you may have multiple exact replicas of your Master server, each with a different configuration and a different purpose, but by giving each server its own unique server id and server spec, you can keep them straight and make your overall installation much clearer to understand and administer.