P4P, the Helix Proxy, or the Perforce Proxy as its original name, improves Helix (Perforce) performance in WAN topographies by mediating between Helix (Perforce) clients and servers to cache frequently transmitted file revisions.

To setup a Helix (Perforce) Proxy, we need to download P4P first.

Download P4P

P4P is available for download separately at https://www.perforce.com/downloads/helix-proxy-server-p4p

For Unix, Linux and Macintosh, you will get an executable for download, and that's all needed.
For Windows, you will get an installer of Helix (Perforce), and installation of that is required.

If you are running Red Hat, CentOS, or Ubuntu, you have an additional option to configure the Perforce package repository and install via OS package manager instead of downloading the executable manually.
Guide for this is available at Installing and Upgrading the Server // Helix Versioning Engine Administrator Guide: Fundamentals.
The package name for P4P is helix-proxy.

Put the Executable into the Right Place

When you've downloaded P4P, you need to put it into a directory contained in environment variable PATH, or add the directory where p4p resides to PATH alternatively.

Or simply use the full path to p4p to avoid the need to fiddle with PATH.

If you are on Unix, Linux or Macintosh, you should also make sure p4p is executable by running the following command in the directory p4p resides.

chmod +x p4p

Set Up a New User for Perforce

To help protect system security, it's best to create a separate account for Perforce.

For example, on Linux, you may run adduser perforce to create a user named perforce.

And to run p4p as the user perforce, use sudo -u perforce p4p.

Run Helix (Perforce) Proxy on Linux Based Systems

p4p -d -p 1666 \
    -t perforce.server.example.com:1666 \
    -r /mnt/p4pcache/perforce-1666 \
    -L /mnt/p4pcache/log/perforce-1666

Here,

  • -d means to run p4p as a daemon;
  • -p specifies the port the proxy itself listens to ($P4PORT or 1666 by default);
  • -t specifies the target perforce server the proxy connects to ($P4TARGET or perforce:1666 by default);
  • -r specifies the cache root ($P4PCACHE by default); Note: this directory needs to be created beforehand;
  • -L specifies the log file ($P4LOG or stderr by default); Note: the log file and the containing directory will get created automatically.

If you need more control over P4P, check p4p -h for usage.

P4P only logs errors by default ($P4DEBUG or none). To increase log level, use -v option, and set its value to server=1 or higher (up to 3).
See P4DEBUG // P4 Command Reference & Monitoring the Server // Helix Versioning Engine Administrator Guide: Fundamentals for more info.

Sample Script for Linux

#!/bin/sh

if [ $UID = 0 ]; then
	>&2 echo Do NOT run p4p as root!
	>&2 echo Run this as a regular user as a security precaution.
	exit 1
fi

p4p=/home/perforce/bin/p4p
P4DEBUG="server=1"

# Kill existing p4p daemons
pkill -P1 p4p

# Start new p4p instances
"$p4p" -d -p 1666 -t perforce1:1666 -r /mnt/p4pcache/perforce1_1666 -L /mnt/p4pcache/log/perforce1_1666 -v "$P4DEBUG"
"$p4p" -d -p 2666 -t perforce2:2666 -r /mnt/p4pcache/perforce2_2666 -L /mnt/p4pcache/log/perforce2_2666 -v "$P4DEBUG"

Further Reading