Compare EC2 instances families without querying AWS API
Project description
ec2-compare
Compare EC2 instances families without querying AWS API
Example:
- Getting on instances by parameters
import ec2_compare.mixin
req = ec2_compare.mixin.EmrRequestMixin().ec3__get_machines(
max_instances=5, # maximum number of machines
# reuest parameters
**{
'cpu': 40, 'ram': 786432, 'min_cpu': 8, 'min_ram': 65536,
'InstanceType': ['c4', 'c5.', 'r4', 'r5.', 'm4', 'm5.'],
'SupportedArchitectures': ['x86_64'], 'SupportedUsageClasses': 'spot'
})
- Getting on instances suitable for on-demand
>>> import ec2_compare.internal.on_demand
>>> ec2_compare.internal.on_demand.get_instances_dict()[0]['InstanceType']
'm5d.xlarge'
Why it's more memory & CPU efficient
1). ec2-compare
- Memory (penalty 8.1 Mb - 8175616 bytes)
>>>
def getCurrentMemoryUsage():
''' Memory usage in Bytes '''
import psutil
import os
process = psutil.Process(os.getpid())
return process.memory_info().rss
>>> getCurrentMemoryUsage()
9535488
>>> import ec2_compare.ec2data
>>> getCurrentMemoryUsage()
17641472
>>> len(ec2_compare.ec2data.get_instances_dict())
341
>>> getCurrentMemoryUsage()
17711104
- Load time:
>>> import timeit
>>> timeit.timeit('import ec2_compare.ec2data;len(ec2_compare.ec2data.get_instances_dict())', number=1)
0.0028156930000000635
>>> timeit.timeit('import ec2_compare.ec2data;len(ec2_compare.ec2data.get_instances_dict())', number=1)
0.001711632000002794
>>> timeit.timeit('import ec2_compare.ec2data;len(ec2_compare.ec2data.get_instances_dict())', number=1000)
0.8330168470000032
>>> timeit.timeit('import ec2_compare.ec2data;len(ec2_compare.ec2data.get_instances_dict())', number=1000)
0.8174298469999997
2). Reading from json file:
- Memory (penalty 2.5 Mb - 2592768 bytes)
>>> getCurrentMemoryUsage()
9379840
>>> import json
>>> with open("./helpers/aws_ec2.json") as json_file:
... json.load(json_file)
...
>>> getCurrentMemoryUsage()
11972608
- Load time:
>>> import timeit
>>>
s= '''
import json
with open("./helpers/aws_ec2.json") as json_file:
json.load(json_file)
'''
timeit.timeit(s, number=1000)
>>
4.628850890999999
Versioning
ec2_compare
follows
PEP 440.
How to build
python -m pip install -e ./[devel]
# or pip install -e ./[devel]
# Running tests
scripts/tests.sh
Update data Locally
- Downland the latest info
aws ec2 describe-instance-types | jq '.InstanceTypes' > aws_ec2.json
- repack
python3 repack.py
Thank you
- https://github.com/actions/ for an awesome github actions
- mypy for doing all dirty work for us
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ec2_compare-1.0.0a8.tar.gz
(326.1 kB
view details)
Built Distribution
ec2_compare-1.0.0a8-py3-none-any.whl
(461.4 kB
view details)
File details
Details for the file ec2_compare-1.0.0a8.tar.gz
.
File metadata
- Download URL: ec2_compare-1.0.0a8.tar.gz
- Upload date:
- Size: 326.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fc860852ba6e291a7c80c655fdb054b5f4e9659bcdd6a0d229acd36483e3a93 |
|
MD5 | 4ce4b02637667628d6048deb2b909aa5 |
|
BLAKE2b-256 | 19d28403548c48c8d5aeece2759e8ffa6a6680aae8840f7c1523e2555e5f07c0 |
File details
Details for the file ec2_compare-1.0.0a8-py3-none-any.whl
.
File metadata
- Download URL: ec2_compare-1.0.0a8-py3-none-any.whl
- Upload date:
- Size: 461.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92fe96fc682171e686a537fcc1218fa745c2f5c8dbd597a9cdd6b0341a04ef48 |
|
MD5 | 29aafff50c8f39d9f5c0f4b68eec70e6 |
|
BLAKE2b-256 | 389d7e857550a9214fc1ac1a0c2ba2a854f391f62bb14aeceb906c4ff4f6a62a |