NGINX
NGINX in Pyroscope Guide.
NGINX#
NGINX fronts the endpoints for TLS termination, routing, caching, and reverse proxying using an event‑driven, non‑blocking architecture. It also provides HTTP/TCP/UDP load balancing and efficient connection handling for external and internal traffic.
Configure the NGINX service by following the steps below:
1. Navigate to the following path:
<HEAL directory>/Appsone_Service
a. Create an NGINX directory.
b. Create an nginx.conf file and copy the following content into the file:
events {}
http {
# Upstreams for better readability and health checks
upstream backend1 {
server <OTEL Collector LB IP>:14250;
}
upstream backend2 {
server <Tempo Service IP>:4321;
}
server {
listen 9995 http2;
location / {
# Forward the main request to primary backend
grpc_pass grpc://backend1;
# REQUIRED for gRPC
grpc_set_header Host $host;
grpc_set_header TE trailers;
# Mirror requests to secondary backend
mirror /mirror;
mirror_request_body on;
}
# Mirror endpoint sends request to backend2
location /mirror {
internal;
rewrite ^ $request_uri break;
grpc_pass grpc://backend2;
grpc_set_header Host $host;
grpc_set_header TE trailers;
}
}
}
Docker#
Run the NGINX container with the configuration file mounted.
docker run -d --name="nginx" --cpus="1.0" --memory="2g" -v "<HEAL directory>/Appsone_Service/nginx/nginx.conf:/etc/nginx/nginx.conf:ro" --network=host nginx:1.22.1
HAProxy#
HAProxy delivers load balancing and proxying for the services with health checks, TLS termination, and rate limiting. Its performance and reliability help distribute traffic across backends at scale.
Configure the HAProxy service by following the steps below:
1. Navigate to the following path:
<HEAL directory>/Appsone_Service/conf/HAPROXY/haproxy.cfg
2. Add the following configuration parameters in haproxy.cfg file:
i. In the frontend of the 9998 port of HAProxy, add the following parameters:
acl url_dr_nginx path_beg -i /opentelemetry.proto.collector.trace.v1.TraceService/Export
acl url_dr_pyroscope path_beg -i /ingest
use_backend nginx_backend if url_dr_nginx
use_backend pyroscope_http_backend if url_dr_pyroscope
ii. Add the following backend parameters to the above frontend parameters, respectively:
backend nginx_backend
balance roundrobin
server nginx <nginx IP>:9995 check inter 3s rise 2 fall 3 proto h2
backend pyroscope_http_backend
balance roundrobin
server grafana-pyroscope <pyroscope IP>:4040 check inter 3s rise 2 fall 3
3. Save the haproxy.cfg file.
4. If the HAProxy is running in HA mode, update the latest file in all the servers where the HAProxy is running.
5. Restart the HAProxy.
Data Retention#
Data retention defines how long data is kept and how it is stored, archived, and securely deleted across each module. It balances operational needs like data minimization and applies to both production datasets and secondary copies, including backups and archives.
Tempo#
1. In Tempo, the retention (of stored trace data) is enforced by the compactor.
2. In the tempo.yml file, configure it as below:
compactor:
compaction:
block_retention: 48h # Retain trace data blocks for 2 days
Note: Mention the required duration in hours to delete the data automatically from tempo.
Post the mentioned time, the compactor will delete the blocks from MinIO.
3. Align Tempo retention (compactor block_retention) with MinIO lifecycle for consistent data deletion.
If not, execute the following commands:
a. Execute the following command for permission:
bash-5.1# mc alias set 'heal-minio-server' 'http://localhost:9000' 'healadmin' '<password>'
b. Execute the following command to delete the data manually:
bash-5.1# mc ilm rule add heal-minio-server/grafana-traces-data --expire-days <no. of days>
For example:
bash-5.1# mc ilm rule add heal-minio-server/grafana-traces-data --expire-days 2
Expected output:
Lifecycle configuration rule added with ID ‘d2r8tudq106lteto23oo’ to heal-minio-server/grafana-traces-data.
Pyroscope#
Pyroscope does not provide a built-in, time-based retention setting for profile data stored in MinIO. Hence, configure MinIO lifecycle rules to implement time‑based retention for Pyroscope data.
1. To delete the Pyroscope data manually by logging into the MinIO container, execute the following commands:
a. Execute the following command for permission:
bash-5.1# mc alias set 'heal-minio-server' 'http://localhost:9000' 'healadmin' '<password>'
b. Execute the following command inside the MinIO container:
bash-5.1# mc ilm rule add heal-minio-server/grafana-pyroscope-data --expire-days <no. of days>
For example:
bash-5.1# mc ilm rule add heal-minio-server/grafana-pyroscope-data --expire-days 2
Expected output:
Lifecycle configuration rule was added with ID ‘d2r90ndq106lth673k30’ to heal-minio-server/grafana-pyroscope-data.
Tempo datasource: Post-setup config#
Follow the post-setup configuration steps below:
1. Start the target application to begin sending trace data to Tempo and profile data to Pyroscope.
2. In a web browser, open http://<grafana-ip>:3003.
3. In Grafana, edit the existing Tempo data source.
a. In Traces to profiles, set Profile type to process_cpu-cpu from the dropdown.
Note: The Profile type list is populated only after Pyroscope receives profile data.
Traces and Profile Correlation Data#
Follow the steps below to verify trace‑to‑profile correlation in Grafana:
1. Visit the Explore menu and
- Select the Tempo data source
- Add time, service, and span as required.
2. Select any result trace ID to open the trace waterfall view; the linked profile data appears on the root span. 
Performance Benchmark#
Find the performance benchmarking below:
For example: The PetClinic application.
1. The PetClinic application showed no additional latency in trace response times.
Response time was consistent with the application’s behavior.
Workload and configuration
Target throughput: 1,600 transactions per second (TPS), approximately 32,000 samples per second (SPS), for both the following runs.
-
- Without agent
- With agent
Results
-
- Throughput with agent: Up to 1,500 TPS (approximately 29,250 SPS).
- CPU and memory: No material differences observed between runs.
2. An external delay was introduced randomly on approximately 50–60% of traces, increasing those response times beyond 100 ms and up to 250 ms to simulate latency under load.
Workload and configuration
Target throughput: 620 transactions per second (TPS), approximately 12,000 samples per second (SPS), for both runs.
-
- Without agent
- With agent
Results
-
- Throughput with agent: Drop in TPS with 40 TPS, 580 TPS (approximately 11,000 SPS).
- CPU and memory: No material differences observed between runs.
3. Approximately 10–12% application slowness in the target environment was observed when the Pyroscope agent was enabled.
4. Data volume and retention:
- At 1,400 TPS (approximately 24,000 SPS), data volume is about 2 GB per hour.
- For 24 hours of retention, allocate 48 GB of disk space.
- For 48 hours of retention, allocate 96 GB of disk space.
- For one week of retention, allocate 350 GB of disk space.