Skip to content

Commit af3b1cd

Browse files
mm-omdimm-hsh
andauthored
Performance Testing: Container cpu memory limits (#184)
* Added new Compose file for data insertion into postgres * Fix command in Docker Compose to handle line endings before executing load script * Refactor Docker Compose command to handle line endings and streamline load script execution * Aligned files in folder structure * Enhance schema validation in bulk data loader and remove unused schema generator script * Remove unused schema volume from Docker Compose and clean up load.sql comments * Add container observability features with CPU and memory limits exporter - Introduced Docker Compose configuration for observability services - Added Prometheus metrics exporter for container CPU limits - Created Grafana dashboards for monitoring CPU and memory usage - Configured OpenTelemetry collector for metrics collection - Implemented necessary environment variables for resource limits * Update Docker images for twinengine-dataengine and dpp-plugin to use 'develop' tag * Update container observability dashboard to improve CPU and memory metrics with new expressions and intervals * Remove usage instructions from Docker Compose file * Refactor load scripts to improve error handling and enhance readability by using constants for repeated values * feat: Add observability stack with Grafana, Prometheus, and custom CPU limits exporter - Introduced a Docker Compose setup for observability, including services for Grafana, Prometheus, and a custom CPU limits exporter. - Added SQL script for truncating the database with a dynamic approach. - Created Grafana dashboard configuration for monitoring container metrics. - Implemented a Python-based CPU limits exporter that reads container limits from Docker and environment variables. - Configured OpenTelemetry collector for gathering metrics from Docker containers. - Established health checks and dependencies for services in the Docker Compose file. * refactor: Improve Dockerfile structure and enhance error logging in CPU limits exporter * refactor: Consolidate user creation and dependency installation in Dockerfile * Remove SQL scripts for schema checks, data loading, and database truncation - Deleted `check-schema.sql` which checked for required tables in the database schema. - Removed `load.sql` which contained the logic for bulk data loading into various tables. - Eliminated `truncate-db.sql` that was used to truncate all tables in the public schema. * refactor: Update Docker setup and metrics exporter for resource limits * refactor: Update Docker images and user permissions in docker-compose.yml * refactor: Change user for otel-docker-stats-collector to root for improved permissions * refactor: Adjust CPU and memory limits for performance services in Docker setup * refactor: Reduce scrape intervals for container CPU and memory metrics to improve observability --------- Co-authored-by: Hardi Shah <hsh@mm-software.com>
1 parent 901c36d commit af3b1cd

15 files changed

Lines changed: 1033 additions & 11 deletions

File tree

performance/databaseBulkDataLoader/.env.example

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/performance/README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# DataEngine Performance Test
2+
3+
This folder contains a Docker Compose setup for running a full DataEngine performance environment with:
4+
5+
1. TwinEngine DataEngine
6+
2. DPP plugin
7+
3. PostgreSQL
8+
4. Registry and template services
9+
5. LGTM observability stack (Grafana, Prometheus, OTLP)
10+
11+
## What Is Included
12+
13+
The stack in `docker-compose.yml` starts these main services:
14+
15+
1. `twinengine-dataengine`
16+
2. `dpp-plugin`
17+
3. `postgres`
18+
4. `pgadmin`
19+
5. `otel-lgtm`
20+
6. `otel-docker-stats-collector`
21+
7. `docker-resource-exporter`
22+
8. Supporting services (`nginx`, `mongo`, template repositories, registries, UI)
23+
24+
## What Is Required
25+
26+
1. Docker with Compose support.
27+
2. Access to local container ports listed below.
28+
3. Valid resource settings in `.env`.
29+
30+
## Environment Configuration
31+
32+
This performance stack reads CPU and memory settings from `.env`:
33+
34+
```env
35+
TWINENGINE_CPU=0.5
36+
TWINENGINE_MEMORY=1g
37+
38+
DPP_PLUGIN_CPU=0.5
39+
DPP_PLUGIN_MEMORY=1g
40+
41+
POSTGRES_CPU=4
42+
POSTGRES_MEMORY=8g
43+
```
44+
45+
These values are applied through `cpus` and `mem_limit` in `docker-compose.yml`.
46+
47+
## CPU and Memory Sizing Examples
48+
49+
You can tune container resource usage in `docker-compose.yml`.
50+
51+
Example service settings:
52+
53+
```yaml
54+
services:
55+
twinengine-dataengine:
56+
cpus: ${TWINENGINE_CPU:-1}
57+
mem_limit: ${TWINENGINE_MEMORY:-1g}
58+
```
59+
60+
CPU examples:
61+
62+
```yaml
63+
cpus: 1 # 1 core
64+
cpus: 2 # 2 cores
65+
cpus: 4 # 4 cores
66+
cpus: 0.5 # Half a core
67+
cpus: 1.25 # 1¼ cores
68+
```
69+
70+
Memory examples:
71+
72+
```yaml
73+
mem_limit: 512m # 512 MB
74+
mem_limit: 1g # 1 GB
75+
mem_limit: 2g # 2 GB
76+
mem_limit: 4g # 4 GB
77+
```
78+
79+
## Run
80+
81+
From this folder:
82+
83+
```bash
84+
docker compose up -d
85+
```
86+
87+
To stop and remove containers/volumes:
88+
89+
```bash
90+
docker compose down -v
91+
```
92+
93+
## Common Endpoints
94+
95+
1. DataEngine entry via nginx: `http://localhost:8080`
96+
2. pgAdmin: `http://localhost:8081`
97+
3. Grafana (LGTM): `http://localhost:3000`
98+
4. Prometheus (LGTM): `http://localhost:9090`
99+
5. PostgreSQL: `localhost:9999`
100+
101+
## Notes
102+
103+
1. This folder runs the complete local performance stack, not just the bulk loader.
104+
2. For database-only loading, use the `databaseBulkDataLoader` subfolder.
105+
3. If you change CPU/memory values, restart the stack to apply updates.

performance/databaseBulkDataLoader/README.md renamed to test/performance/databaseBulkDataLoader/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ The runner uses the official `postgres:16-alpine` image only as a client contain
1313

1414
The loader does not generate schema. It validates required tables first and exits with an error if any are missing.
1515

16+
## Example .env file
17+
18+
```env
19+
PG_CONN_STRING=postgresql://postgres:admin@localhost:9999/twinengine
20+
ASSET_COUNT=1000
21+
BATCH_SIZE=100
22+
```
23+
1624
## Configuration
1725

1826
The loader reads only environment variables:
@@ -21,14 +29,6 @@ The loader reads only environment variables:
2129
2. `ASSET_COUNT` (optional, defaults to `1000`)
2230
3. `BATCH_SIZE` (optional, defaults to `100`)
2331

24-
Create your runtime file:
25-
26-
```bash
27-
cp .env.example .env
28-
```
29-
30-
Then update at least `PG_CONN_STRING`.
31-
3232
## Run
3333

3434
From this folder:

performance/databaseBulkDataLoader/docker-compose.yml renamed to test/performance/databaseBulkDataLoader/docker-compose.yml

File renamed without changes.
File renamed without changes.

performance/databaseBulkDataLoader/sql/check-schema.sql renamed to test/performance/databaseBulkDataLoader/sql/check-schema.sql

File renamed without changes.
File renamed without changes.

performance/databaseBulkDataLoader/sql/truncate-db.sql renamed to test/performance/databaseBulkDataLoader/sql/truncate-db.sql

File renamed without changes.

0 commit comments

Comments
 (0)