Conversation
Right-sized the resources for Django containers across all environments and the RDS instance in the Production and Preprod environments. This will result in a savings of approximately $2,481. The following changes have been made: - Production: - RDS instance type was changed from `db.m6in.8xlarge` to `db.m6in.4xlarge`. - ECS tasks for Django containers: the number was reduced from `12` to `10`, and memory was reduced from `8GB` to `4GB`. - Preprod: - RDS instance type was changed from `db.m6in.8xlarge` to `db.m6in.4xlarge`. - ECS tasks for Django containers: the number was reduced from `12` to `10`, and memory was reduced from `8GB` to `4GB`. - These changes were made to maintain parity with the Production environment, as it is a copy of that environment. - Staging: - ECS tasks for Django containers: memory was reduced from `8GB` to `2GB`. - Test: - ECS tasks for Django containers: memory was reduced from `8GB` to `4GB`. - Development: - ECS tasks for Django containers: memory was reduced from `8GB` to `1GB`, and CPU was reduced from `1 vCPU` to `0.5 vCPU`.
|
📝 WalkthroughWalkthroughThis pull request includes modifications to several Terraform configuration files for different environments of the OpenSupplyHub project. Key changes involve reductions in resource allocations, specifically the CPU and memory for Fargate services and adjustments to RDS instance types across development, pre-production, production, staging, and test environments. Additionally, the release notes have been updated to reflect these changes and other bug fixes within the application. Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
deployment/environments/terraform-preprod.tfvars (1)
19-19: LGTM - Preprod maintains parity with productionThe resource reductions mirror production exactly, which is ideal for:
- Validating production changes
- Testing performance impact
- Identifying potential issues
Suggestions:
- Use preprod to validate the resource reductions before rolling out to production
- Run load tests in preprod with production-like workloads
- Monitor key metrics (response times, error rates, resource utilization)
Also applies to: 25-25, 29-29
doc/release/RELEASE-NOTES.md (1)
77-90: Improve list formatting consistencyThe release notes content is comprehensive, but the formatting could be improved for better readability.
Apply this formatting:
* Right-sized the resources for Django containers across all environments and the RDS instance in the Production and Preprod environments. This will result in a savings of approximately $2,481. The following changes have been made: * Production: * RDS instance type was changed from `db.m6in.8xlarge` to `db.m6in.4xlarge`. * ECS tasks for Django containers: the number was reduced from `12` to `10`, and memory was reduced from `8GB` to `4GB`. * Preprod: * RDS instance type was changed from `db.m6in.8xlarge` to `db.m6in.4xlarge`. * ECS tasks for Django containers: the number was reduced from `12` to `10`, and memory was reduced from `8GB` to `4GB`. * These changes were made to maintain parity with the Production environment, as it is a copy of that environment. * Staging: * ECS tasks for Django containers: memory was reduced from `8GB` to `2GB`. * Test: * ECS tasks for Django containers: memory was reduced from `8GB` to `4GB`. * Development: * ECS tasks for Django containers: memory was reduced from `8GB` to `1GB`, and CPU was reduced from `1 vCPU` to `0.5 vCPU`.🧰 Tools
🪛 Markdownlint (0.37.0)
78-78: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
79-79: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
80-80: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
81-81: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
82-82: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
83-83: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
84-84: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
85-85: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
86-86: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
87-87: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
88-88: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
89-89: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
90-90: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
78-78: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
79-79: Expected: 4; Actual: 8
Unordered list indentation(MD007, ul-indent)
80-80: Expected: 4; Actual: 8
Unordered list indentation(MD007, ul-indent)
81-81: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
82-82: Expected: 4; Actual: 8
Unordered list indentation(MD007, ul-indent)
83-83: Expected: 4; Actual: 8
Unordered list indentation(MD007, ul-indent)
84-84: Expected: 4; Actual: 8
Unordered list indentation(MD007, ul-indent)
85-85: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
86-86: Expected: 4; Actual: 8
Unordered list indentation(MD007, ul-indent)
87-87: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
88-88: Expected: 4; Actual: 8
Unordered list indentation(MD007, ul-indent)
89-89: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
90-90: Expected: 4; Actual: 8
Unordered list indentation(MD007, ul-indent)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
deployment/environments/terraform-development.tfvars(1 hunks)deployment/environments/terraform-preprod.tfvars(1 hunks)deployment/environments/terraform-production.tfvars(1 hunks)deployment/environments/terraform-staging.tfvars(1 hunks)deployment/environments/terraform-test.tfvars(1 hunks)doc/release/RELEASE-NOTES.md(1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.37.0)
doc/release/RELEASE-NOTES.md
78-78: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
79-79: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
80-80: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
81-81: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
82-82: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
83-83: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
84-84: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
85-85: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
86-86: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
87-87: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
88-88: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
89-89: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
90-90: Expected: asterisk; Actual: dash
Unordered list style
(MD004, ul-style)
78-78: Expected: 2; Actual: 4
Unordered list indentation
(MD007, ul-indent)
79-79: Expected: 4; Actual: 8
Unordered list indentation
(MD007, ul-indent)
80-80: Expected: 4; Actual: 8
Unordered list indentation
(MD007, ul-indent)
81-81: Expected: 2; Actual: 4
Unordered list indentation
(MD007, ul-indent)
82-82: Expected: 4; Actual: 8
Unordered list indentation
(MD007, ul-indent)
83-83: Expected: 4; Actual: 8
Unordered list indentation
(MD007, ul-indent)
84-84: Expected: 4; Actual: 8
Unordered list indentation
(MD007, ul-indent)
85-85: Expected: 2; Actual: 4
Unordered list indentation
(MD007, ul-indent)
86-86: Expected: 4; Actual: 8
Unordered list indentation
(MD007, ul-indent)
87-87: Expected: 2; Actual: 4
Unordered list indentation
(MD007, ul-indent)
88-88: Expected: 4; Actual: 8
Unordered list indentation
(MD007, ul-indent)
89-89: Expected: 2; Actual: 4
Unordered list indentation
(MD007, ul-indent)
90-90: Expected: 4; Actual: 8
Unordered list indentation
(MD007, ul-indent)
🔇 Additional comments (3)
deployment/environments/terraform-production.tfvars (1)
18-18: Consider gradual resource reduction in production
Significant resource reductions:
- RDS: 50% reduction (8xlarge → 4xlarge)
- ECS tasks: 17% reduction (12 → 10)
- Memory: 50% reduction (8GB → 4GB)
While these align with cost-saving objectives, consider:
- Implementing these changes gradually
- Setting up detailed monitoring
- Having a rollback plan
Consider implementing:
- Resource utilization alerts
- Performance monitoring dashboards
- Load testing with reduced resources
- Gradual rollout strategy (e.g., start with RDS, then ECS, then memory)
Also applies to: 24-24, 29-29
✅ Verification successful
Resource reduction plan appears safe with existing monitoring
The infrastructure has adequate monitoring in place to safely implement the proposed resource reductions:
-
CloudWatch monitoring is configured with:
- CPU and memory alarms for cache (
aws_cloudwatch_metric_alarmfor cache_cpu and cache_memory) - Log groups for application components (app, cli, cc, dd, kafka, logstash)
- Lambda-based failure alerts for batch and step functions
- CPU and memory alarms for cache (
-
Resource changes align with other environments:
- RDS: m6in.4xlarge matches preprod configuration
- Memory allocations (4GB) align with test environment settings
- Similar configurations are already tested in lower environments
Recommendations for implementation:
- Use existing CloudWatch alarms to monitor performance during changes
- Roll out changes during low-traffic periods
- Start with staging verification, then preprod, before production deployment
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for performance-related issues in production
gh api repos/opensupplyhub/open-supply-hub/issues \
--jq '.[] | select(.labels[].name == "production" or .labels[].name == "performance") | {title: .title, url: .html_url}' | \
grep -i "performance\|timeout\|memory\|slow"
Length of output: 219
Script:
#!/bin/bash
# Let's check for monitoring and alerting configurations
fd "monitoring|alert|dashboard" --type f
# Check terraform files for monitoring resources
rg -l "monitoring|cloudwatch|alert|metric" --type tf
# Look for existing resource configurations
rg "rds_instance_type|ecs_task|memory" --type tfvars -A 2 -B 2
Length of output: 4099
Script:
#!/bin/bash
# Check terraform configurations for monitoring and metrics
rg "monitoring|cloudwatch|alert|metric" -A 5 -B 5 deployment/terraform/container_service.tf deployment/terraform/iam.tf
# Check for existing resource configurations in terraform files
rg "rds_instance_type|task_count|memory" deployment/environments/ -A 2 -B 2
# Look for CloudWatch alarms or monitoring configurations
rg "aws_cloudwatch_metric_alarm|aws_cloudwatch_log_metric_filter" deployment/terraform/
Length of output: 17936
deployment/environments/terraform-development.tfvars (1)
30-31: Verify the impact of significant memory reduction
The memory allocation has been significantly reduced from 8GB to 1GB. While this aligns with cost optimization goals, please verify:
- Application performance remains stable with 1GB memory
- No out-of-memory errors occur during development tasks
✅ Verification successful
Memory allocation in development environment appears appropriate
The reduced memory configuration (1GB) in the development environment is consistent with the application's resource patterns across environments:
- Production/Preprod: 4GB memory
- Staging: 2GB memory
- Test: 4GB memory
- Development: 1GB memory
The development environment has appropriately scaled-down resources:
- Single instance count (app_ecs_desired_count = "1")
- Reduced CPU (512 = 0.5 vCPU)
- Proportionally reduced memory (1GB)
- Smaller RDS instance (db.t3.micro)
The configuration maintains the right balance for development workloads while optimizing costs.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for OOM events in CloudWatch logs
# Get the log group name for the ECS service
LOG_GROUP=$(aws logs describe-log-groups --log-group-name-prefix "/ecs/opensupplyhub-development" --query 'logGroups[0].logGroupName' --output text)
# Search for OOM events in the last 24 hours
echo "Checking for OOM events in $LOG_GROUP..."
aws logs filter-log-events \
--log-group-name "$LOG_GROUP" \
--filter-pattern "\"out of memory\" OR \"OutOfMemoryError\" OR \"Killed\"" \
--start-time $(($(date +%s) - 86400))000
Length of output: 565
Script:
#!/bin/bash
# Let's check the application's memory usage patterns and requirements from the codebase
# Search for memory-related configurations in the infrastructure code
echo "=== Checking memory configurations across environments ==="
fd -e tfvars -x cat {} \; 2>/dev/null
# Look for Docker memory configurations
echo -e "\n=== Checking Docker memory configurations ==="
fd -e dockerfile -e compose.yml -e compose.yaml -x cat {} \; 2>/dev/null
# Search for memory-intensive operations in the codebase
echo -e "\n=== Checking for potential memory-intensive operations ==="
rg -i "memory|heap|cache" --type-add 'config:*.{yml,yaml,json,conf,config}' --type config
Length of output: 10324
deployment/environments/terraform-test.tfvars (1)
35-35: LGTM! Resource optimization looks appropriate
The reduction to 4GB memory for the test environment maintains a good balance between cost optimization and testing requirements.
React App | Jest test suite - Code coverage reportTotal: 27.88%Your code coverage diff: 0.00% ▴ ✅ All code changes are covered |
Dedupe Hub App | Unittest test suite - Code coverage reportTotal: 56.14%Your code coverage diff: 0.00% ▴ ✅ All code changes are covered |
Contricleaner App | Unittest test suite - Code coverage reportTotal: 98.91%Your code coverage diff: 0.00% ▴ ✅ All code changes are covered |
Countries App | Unittest test suite - Code coverage reportTotal: 100%Your code coverage diff: 0.00% ▴ ✅ All code changes are covered |
Django App | Unittest test suite - Code coverage reportTotal: 79.96%Your code coverage diff: 0.00% ▴ ✅ All code changes are covered |
Right-sized the resources for Django containers across all environments and the RDS instance in the Production and Preprod environments. This will result in a savings of approximately $2,481. The following changes have been made: - Production: - RDS instance type was changed from `db.m6in.8xlarge` to `db.m6in.4xlarge`. - ECS tasks for Django containers: the number was reduced from `12` to `10`, and memory was reduced from `8GB` to `4GB`. - Preprod: - RDS instance type was changed from `db.m6in.8xlarge` to `db.m6in.4xlarge`. - ECS tasks for Django containers: the number was reduced from `12` to `10`, and memory was reduced from `8GB` to `4GB`. - These changes were made to maintain parity with the Production environment, as it is a copy of that environment. - Staging: - ECS tasks for Django containers: memory was reduced from `8GB` to `2GB`. - Test: - ECS tasks for Django containers: memory was reduced from `8GB` to `4GB`. - Development: - ECS tasks for Django containers: memory was reduced from `8GB` to `1GB`, and CPU was reduced from `1 vCPU` to `0.5 vCPU`.



Right-sized the resources for Django containers across all environments and the RDS instance in the Production and Preprod environments. This will result in a savings of approximately $2,481. The following changes have been made:
db.m6in.8xlargetodb.m6in.4xlarge.12to10, and memory was reduced from8GBto4GB.db.m6in.8xlargetodb.m6in.4xlarge.12to10, and memory was reduced from8GBto4GB.8GBto2GB.8GBto4GB.8GBto1GB, and CPU was reduced from1 vCPUto0.5 vCPU.