Download PDF
Download page TCP Mode Configuration for PHP Agent.
TCP Mode Configuration for PHP Agent
By default, PHP Agent and Java proxy communicate with each other using Inter-Process Communication (IPC). However, using Transmission Control Protocol (TCP) communication is beneficial in these scenarios:
- When you want the Java proxy and PHP Agent to run over different host operating systems.
- In containers (such as Docker and Kubernetes), where mounting the same volume for all the containers is possible but not recommended.
To enable TCP communication, set -tcp-comm-port
to a valid port value while installing the agent. Also, set -
tcp-port-range
to a valid port range (3000-3005). The PHP Agent and Java proxy can now communicate using TCP.
The Java proxy listens to the incoming connection requests from agents over the -
tcp-comm-port
. The communication occurs for each agent over these two unique ports:
- Reporting port
- Request port
These ports can be set during the agent installation or proxy configuration.
TCP Mode Environmental Variables
This table lists the TCP mode configuration environment variables:
Variable Name | Description | Configuration Notes |
---|---|---|
|
| It is an optional variable. By default, it is set to |
|
| You must define this variable. |
| Defines the port range over which the proxy allocates ports (request / reporting) to communicate with the agent | You must define this variable. |
| Defines the port for reporting transport between the agent and proxy. | It is an optional variable. If not defined, proxy allocates a port in the defined range. |
| Defines the port for request and configuration transport between the agent and proxy. | It is an optional variable. If not defined, proxy allocates a port in the defined range. |
Sample Installation Command
The following is a sample command to install the agent with the TCP mode enabled.
install.sh -a PHPCust@XC6v2n8m2$543 --tcp-comm-port=3000 --tcp-port-range=3000-3010 controller1.appdynamics.com 8818 myApp myTier myNode
Set Up CurveZMQ to Encrypt the Agent-Proxy Communication
By default, the communication between Java Proxy and the PHP Agent is not encrypted. This section describes how to encrypt the communication between the proxy and the agent using CurveZMQ. CurveZMQ is an authentication and encryption protocol for ZeroMQ.
To enable the curve encryption, use the -
curve-enabled
flag while installing the agent. The following is a sample command to install the agent with CurveZMQ enabled.
install.sh -a PHPCust@XC6v2n8m2$543 --tcp-comm-port=3000 —tcp-port-
range=3000-3010 —curve-enabled controller1.appdynamics.com 8818 myApp
Configure Proxy and Agent in Separate Containers
- Use the following sample command to deploy the agent in a container.
./install.sh -a e2e-customer@59b661ac-720f-43ce-9b07-9d3bdf1cdb17 --auto-launch-proxy=0 —tcp-comm-host=PROXY_HOST --tcp-comm- port=3000 --tcp-port-range=3000-3010 --curve-enabled CONTROLLER_HOST_NAME CONTROLLER_PORT APP_NAME TIER_NAME NODE_NAME 8090
CODE - Perform the following steps to deploy proxy in a container than the agent container.
- Download the proxy artifact and unzip it.
- Make a copy of the
runProxy.template
file and rename it asrunProxy
. - Run the following command.
bash /proxy/runProxy /tmp/proxy.communication /tmp/agentLogs -Dappdynamics.proxy.curveenabled=yes -Dappdynamics.proxy.curvesecretfile=/home/appdynamics-php-agent- linux_x64/certs/secret/proxy.key_secret -Dappdynamics.proxy.curvepublicfile=/home/appdynamics-php-agent- linux_x64/certs/public/proxy.key -Dcommtcp=3000 -Dappdynamics.proxy.commtcphost=$(hostname -I) -Dappdynamics.proxy.commportrange=3000-3005 -Dappdynamics.agent.ssl.protocol=TLSv1.2
CODE
Ensure that agent and proxy are part of the same network to allow agent-proxy communication. You can use Docker Compose to achieve this.
- If you are using Docker Compose, you can set proxy host value as proxy container name.
Deploy PHP Agent with Shared Proxy in a Kubernetes Cluster
This section describes how to deploy PHP Agent with shared Java proxy on Kubernetes.
Proxy Pod Configuration
Make a note of the following points while configuring the pod for proxy:
- Expose a continuous range of ports in the proxy service for the proxy-agent communication.
- Run the proxy pod with spec type for proxy service set to
ClusterIP
. - Make sure to set the following environment variables for running proxy in TCP mode:
Variable | Value | Required |
---|---|---|
APPDYNAMICS_TCP_COMM_PORT | TCP Port for proxy, for example, | Yes |
APPDYNAMICS_TCP_COMM_HOST | TCP Host where agents make the request. It is recommended to set it as the IP Address where pod is running. In the
CODE
| Yes |
APPDYNAMICS_TCP_PORT_RANGE | Specify the port range for proxy to allocate request/reporting ports. For example, Make sure to provide enough ports in the port range. The total number of ports must be at least double the number of agents. | Yes |
APPDYNAMICS_CURVE_ENABLED | Set to | Optional |
- Applications that run with PHP Agent must run in pods. You can scale up or scale down the PHP Agent pods.
- The proxy runs as a single and separate pod. It is exposed to the PHP Agents through a service. You should not scale or replicate the proxy pod.
Sample Proxy Deployment Specification for Kubernetes
##Proxy Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: proxy-deployment
spec:
replicas: 1
selector:
matchLabels:
app: proxy
template:
metadata:
labels:
app: proxy
spec:
containers:
- name: proxy
image: appdynamics/php-proxy-x64:latest
env:
- name: APPDYNAMICS_CURVE_ENABLED
value: "true"
- name: APPDYNAMICS_TCP_COMM_PORT
value: "3000"
- name: APPDYNAMICS_TCP_COMM_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: APPDYNAMICS_TCP_PORT_RANGE
value: "3000-3010"
##Proxy Service
apiVersion: v1
kind: Service
metadata:
name: proxy-service
spec:
selector:
app: proxy
type: ClusterIP
ports:
- protocol: TCP
name: port-1
port: 3000
targetPort: 3000
- protocol: TCP
name: port-2
port: 3001
targetPort: 3001
- protocol: TCP
name: port-3
port: 3002
targetPort: 3002
- protocol: TCP
name: port-4
port: 3003
targetPort: 3003
Sample Command for Agent Installation in a Pod
./install.sh -a e2e-customer@59b661ac-720f-43ce-9b07-9d3bdf1cdb17 --auto-launch-proxy=0 --tcp-comm-host=proxy-service.default --tcp-comm-port=3000 --tcp-port-range=3000-3010 --curve-enabled CONTROLLER_HOST_NAME CONTROLLER_PORT APP_NAME TIER_NAME NODE_NAME 8090
- If you are using Kubernetes, set the
tcp comm host = proxy-service.default
parameterproxy-service
is the name of the proxy service and.default
is the default namespace. - A single proxy can send data to Controller only when the application name for the agent reporting to it is same.