Power User Tip - Preventing Server Swamp
Ever had your Perforce repository become unresponsive because someone ran a script that was hammering the repository in a while(1) loop? The Perforce server process (p4d) is normally a very gracious host, accepting any and all requests from users and automated processes. However, there are some cases where you'd like it to be a little more choosy. Otherwise, a poorly constructed script, malicious activity, or just plain old too much traffic can overwhelm p4d for a period of time.
The 2013.1 release has a great new configuration parameter that lets you prevent these situations. Just set the server.maxcommands parameter to the maximum number of requests that p4d should handle concurrently before it starts rejecting new requests:
p4 configure set server.maxcommands=200 p4 admin restart
After that, when p4d sees request #201, it will send a polite no thank you message:
Request refused: this server is configured to run a maximum of 200 simultaneous commands. Please try again later when the load is lower.
Note that you have to have server monitoring enabled in order for this configuration parameter to work.
So how did I arrive at 200 as a good number? You'll have to take an educated guess at first. Run the p4 monitor command a few times during periods of normal usage, and get a sense for how many requests p4d is processing. Multiply that by 3 or 5 to give your users a nice cushion before they start hitting the limit. Try that, and adjust as necessary. Ideally, you want p4d to handle all normal traffic, but reject any runaway scripts or denial-of-service attacks before they exhaust the physical resources on your server machine.