ResourceFit
ResourceFit is a command-line tool designed to analyze Docker container resource usage and recommend the most cost-effective Amazon Web Services (AWS) EC2 instances based on the container's memory, CPU, and disk space requirements. It fetches real-time container stats, normalizes the data, and compares them against available EC2 instance options, taking AWS EBS storage and pricing into account.
Features
- Host Machine Stats: Collects and displays CPU, memory, disk, and network information from the host machine.
- Docker Container Stats: Analyzes running Docker containers, showing stats like CPU usage, memory consumption, and network I/O.
- EC2 Recommendations: Recommends AWS EC2 instances based on the resource needs of the selected Docker container.
- AWS Pricing Data: Fetches EC2 and EBS pricing data to make cost-efficient recommendations.
- Memory and Disk Space Buffers: Includes customizable memory buffers (50-100%) to ensure recommended instances meet peak resource demands.
Installation
To install ResourceFit, follow the steps below:
-
Have python (version 3.9 and above) installed on your device, follow the link below to do this:
https://www.python.org/downloads/
-
Install ResourceFit:
pip install resourcefit
Usage
Once installed, you can use resourcefit from the command line:
resourcefit
The tool will:
- Display a list of running Docker containers.
- Allow you to select a container to analyze.
- Show real-time stats for the selected container (CPU, memory, I/O).
- Fetch and display AWS EC2 and EBS pricing data.
- Recommend the top three EC2 instances based on the selected container's resource usage and disk space requirements.
Example Output
Select a container to analyze:
1. webapp (ID: 123abc456def) - Image: webapp:latest
2. nginx (ID: 789ghi012jkl) - Image: nginx:latest
Enter the number of the container (default 1) [1]:
Selected Container ID: 123abc456def
Docker Container Stats:
container_id: 123abc456def
name: webapp
cpu_usage: 0.24%
mem_usage: 256.00 MiB / 1.00 GiB
mem_percentage: 25.00%
net_io_rx: 10.00 kB
net_io_tx: 5.00 kB
block_io_read: 0.00 MB
block_io_write: 0.05 MB
pids: 5
Fetching AWS EC2 pricing data...
Top 3 EC2 Instance Recommendations:
Instance Type Memory vCPU Storage priceMonthly
191 t4g.nano 0.5 2 EBS only (5.00 GB) 3.466
277 t3a.nano 0.5 2 EBS only (5.00 GB) 3.831
648 t3.nano 0.5 2 EBS only (5.00 GB) 4.196
Dependencies
ResourceFit requires the following Python libraries:
psutil: For host machine stats.docker: For Docker container stats.pandas: For data handling.requests: To fetch AWS pricing data.click: For the command-line interface.
How It Works
Step 1: Host Machine Stats
The tool collects basic host machine stats, including CPU count, memory size, disk I/O, and network I/O.
Step 2: Docker Container Stats
It lists running Docker containers and provides real-time statistics (CPU, memory, and I/O usage) for the selected container.
Step 3: AWS Pricing Data
ResourceFit fetches EC2 and EBS pricing data from AWS for both Linux and Windows instances in the specified region.
Step 4: EC2 Instance Recommendations
Based on the Docker container stats, ResourceFit recommends the top EC2 instances, applying a 50% memory buffer for peak loads. It also factors in disk space requirements for instances with EBS storage.
Customization
Memory Buffer Factor
The default memory buffer factor is set to 1.5 (50% more memory). This can be adjusted in the source code based on your needs.
AWS Region
By default, the AWS region is set to 'US East (N. Virginia)', but this can be modified in the code to support different regions.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues if you encounter any bugs or have feature requests.
Metadata
Release files for resourcefit 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| resourcefit-0.1.3.tar.gz | 11.8 kB | Without provenance | Details for resourcefit-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| resourcefit-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for resourcefit-0.1.3-py3-none-any.whl |
Total release size: 22.1 kB
Release files / resourcefit-0.1.3.tar.gz
| Download URL | resourcefit-0.1.3.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8a579d3c2f38e6e0b48a734de6f3a5704e9328dd8b54bb7ea403eb5d290abc2
|
|
BLAKE2b-256 checksum How to use checksums |
b1c26efcd985c5b918bd92f94cd2e6d4a76ce9209c0b40d713932aff9b6fc8be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / resourcefit-0.1.3-py3-none-any.whl
| Download URL | resourcefit-0.1.3-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c38cba260092597649120d63a268d2611192efd0501589d337a714e2424ac475
|
|
BLAKE2b-256 checksum How to use checksums |
bdc7526e9b195c6dae5165b0d50b322290d9cff20d36feea924f8a7994d4f8ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for resourcefit 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.