可以分析源代碼並檢查在遷移到 AWS Graviton 時需要更改的過時運行library
優化 aws 成本的方法之一是遷移到並採用具有高性價比的AWS Graviton
推薦使用AWS Graviton,從可持續性的角度來看,它有很好的表現
但有需要注意的地方:
特別是有這兩點高度依賴於正在執行的應用程序的要求而不是基礎設施,因此建議在遷移之前進行驗證
因此,在 GitHub 上發布了遷移指南
https://github.com/aws/aws-graviton-getting-started
https://github.com/aws/aws-graviton-getting-started/blob/main/transition-guide.md
在上面的文章中,介紹了Graviton 的 Porting Advisor 作為一種工具來幫助分析和更改工作負載中的軟體
https://github.com/aws/porting-advisor-for-graviton
目前要分析的語言和檢查對像如下
先決條件
確認版本
# python3 --version
Python 3.10.6
下載檔案
root@ip-10-0-5-161:~# git clone https://github.com/aws/porting-advisor-for-graviton.git
Cloning into 'porting-advisor-for-graviton'...
remote: Enumerating objects: 333, done.
remote: Counting objects: 100% (333/333), done.
remote: Compressing objects: 100% (206/206), done.
remote: Total 333 (delta 102), reused 302 (delta 87), pack-reused 0
Receiving objects: 100% (333/333), 144.62 KiB | 3.71 MiB/s, done.
Resolving deltas: 100% (102/102), done.
root@ip-10-0-5-161:~#
root@ip-10-0-5-161:~# ls
porting-advisor-for-graviton
建立虛擬環境
root@ip-10-0-5-161:~# python3 -m venv .venv
root@ip-10-0-5-161:~#
root@ip-10-0-5-161:~# source .venv/bin/activate
(.venv) root@ip-10-0-5-161:~#
安裝library套件
(.venv) root@ip-10-0-5-161:~# cd porting-advisor-for-graviton
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# pip3 install -r requirements.txt
Collecting altgraph==0.17.2
Downloading altgraph-0.17.2-py2.py3-none-any.whl (21 kB)
Collecting Jinja2==3.1.2
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 KB 4.5 MB/s eta 0:00:00
Collecting MarkupSafe==2.1.1
Downloading MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting packaging==21.3
Downloading packaging-21.3-py3-none-any.whl (40 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 KB 7.4 MB/s eta 0:00:00
Collecting progressbar33==2.4
Downloading progressbar33-2.4.tar.gz (10 kB)
Preparing metadata (setup.py) ... done
Collecting pyparsing==3.0.9
Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 KB 20.3 MB/s eta 0:00:00
Collecting XlsxWriter==3.0.3
Downloading XlsxWriter-3.0.3-py3-none-any.whl (149 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 150.0/150.0 KB 10.8 MB/s eta 0:00:00
Using legacy 'setup.py install' for progressbar33, since package 'wheel' is not installed.
Installing collected packages: progressbar33, altgraph, XlsxWriter, pyparsing, MarkupSafe, packaging, Jinja2
Running setup.py install for progressbar33 ... done
Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.1 XlsxWriter-3.0.3 altgraph-0.17.2 packaging-21.3 progressbar33-2.4 pyparsing-3.0.9
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
用sample示範
root@ip-10-0-5-161:~/porting-advisor-for-graviton# ls sample-projects/
dotnet-samples go-samples java-samples node-samples python-samples ruby-samples
root@ip-10-0-5-161:~/porting-advisor-for-graviton#
執行檢查
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples
| Elapsed Time: 0:00:03
Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:06:27
4 files scanned.
detected python code. if you need pip, version 19.3 or above is recommended. we detected that you have version 22.0.2.
detected python code. min version 3.7.5 is required. we detected that you have version 3.10.6. see https://github.com/aws/aws-graviton-getting-started/blob/main/python.md for mo
re details.
sample-projects/python-samples/incompatible/requirements.txt:3: using dependency library openblas version 0.3.16. upgrade to at least version 0.3.17
sample-projects/python-samples/incompatible/requirements.txt:5: dependency library numpy is present. min version 1.19.0 is required.
Report generated successfully. Hint: you can use --output FILENAME.html to generate an HTML report.
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
檢查發現了以下兩個需要升級
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# cat sample-projects/python-samples/incompatible/requirements.txt
# Porting Advisor for Graviton test file
OpenBLAS>=0.3.16
SciPy>=1.7.1
NumPy
FakeDependency>=1.2.3(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
產生報告 html、json、csv、txt
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples --output report.html
| Elapsed Time: 0:00:03
Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:10:38
Report saved at: report.html
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples --output report.json
| Elapsed Time: 0:00:03
Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:11:17
Report saved at: report.json
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples --output report.csv
| Elapsed Time: 0:00:03
Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:11:27
Report saved at: report.csv
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples --output report.txt
| Elapsed Time: 0:00:02
Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:11:35
Report saved at: report.txt
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# ls report.*
report.csv report.html report.json report.txt
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
report.json
{
"errors": [],
"issue_types": "-CompilerSpecific,-CrossCompile,-NoEquivalent",
"issues": [
"DependencyVersionIssue: sample-projects/python-samples/incompatible/requirements.txt:3: using dependency library openblas version 0.3.16. upgrade to at least version 0.
3.17"
],
"open_text_mode": "w",
"ported_inline_asm": 0,
"remarks": [
"LanguageVersionRemark: detected python code. min version 3.7.5 is required. we detected that you have version 3.10.6. see https://github.com/aws/aws-graviton-getting-st
arted/blob/main/python.md for more details.",
"ToolVersionRemark: detected python code. if you need pip, version 19.3 or above is recommended. we detected that you have version 22.0.2.",
"DependencyVersionRemark: sample-projects/python-samples/incompatible/requirements.txt:5: dependency library numpy is present. min version 1.19.0 is required."
],
"root_directory": "sample-projects/python-samples",
"self_process": false,
"send_filename": false,
"source_dirs": [
"sample-projects/python-samples/compatible",
"sample-projects/python-samples",
"sample-projects/python-samples/incompatible"
],
"source_files": [
"sample-projects/python-samples/main.py",
"sample-projects/python-samples/submain.py",
"sample-projects/python-samples/incompatible/requirements.txt",
"sample-projects/python-samples/compatible/requirements.txt"
],
"target_os": "linux"
}
report.txt
4 files scanned.
detected python code. if you need pip, version 19.3 or above is recommended. we detected that you have version 22.0.2.
detected python code. min version 3.7.5 is required. we detected that you have version 3.10.6. see https://github.com/aws/aws-graviton-getting-started/blob/main/python.md for more details.
sample-projects/python-samples/incompatible/requirements.txt:3: using dependency library openblas version 0.3.16. upgrade to at least version 0.3.17
sample-projects/python-samples/incompatible/requirements.txt:5: dependency library numpy is present. min version 1.19.0 is required.
report.html