SAP是企业中广泛使用的ERP系统,SAP应用系统的上云也已经是大势所趋,相对于其他应用系统来说,SAP的机型选择要相对苛刻一写。首先,不是所有的AWS EC2机型都通过了SAP公司的认证;其次,就是通过了认证的机器,也不是能运行所有的SAP应用。SAP公司为不同的应用认证了不同的机型。例如m4系列的服务器是SAP认证的机型,但它不是HANA数据库认证的机型。SAP服务器的性能是通过SAPS值体现的,如果我对运行SAP应用的服务器进行了机型优化,我如何才能知道对SAPS值有何影响?
所以在进行SAP服务器的选型时,我们可以通过设置EXCLUDE_EC2_TYPE的值来规避选择非SAP认证的服务器的现象发生,在这两个网站上可以查询SAP的何种应用认证了何种类型的EC2:
https://aws.amazon.com/cn/sap/instance-types/
设置了EXCLUDE_EC2_TYPE后,对SAP机型进行优化了。优化完成后,怎么对比SAPS值呢? 我们的方案是首先从网站上抓取不同EC2对应的SAPS值,然后下载下来生成一个Excel表格以备后用。
Python程序get_ec2_saps.py就可以完成这个工作:
第一步:下载网上的相关表格
import pandas as pd
saps_table = pd.read_html(‘https://aws.amazon.com/cn/sap/instance-types/’)
import pandas as pd
saps_table = pd.read_html('https://aws.amazon.com/cn/sap/instance-types/')
第二步:对表格进行合并、清理
new_table = saps_table[0]
old_table = saps_table[1]
new = new_table[['Instance Type', 'vCPU', 'Mem (GiB)', 'SAPS']]
old = old_table[['Instance Type', 'vCPU', 'Mem (GiB)', 'SAPS']]
ec2_saps = pd.concat([new, old])
ec2_saps.replace({'\*': ''}, regex=True, inplace=True)
ec2_saps['vCPU'] = pd.to_numeric(
ec2_saps['vCPU'], downcast='integer', errors='coerce')
ec2_saps['Mem (GiB)'] = pd.to_numeric(
ec2_saps['Mem (GiB)'], downcast='float', errors='coerce')
ec2_saps['SAPS'] = pd.to_numeric(
ec2_saps['SAPS'], downcast='float', errors='coerce')
第三步:保存到Excel表格里面
ec2_saps.to_excel('ec2_saps.xlsx', index=False完成,让我们看看结果,由于机型过多,我们仅截取部分内容:
接下来我们要做的就是将我们得到的SAPS值的结果拼接到机型优化的结果中去。我们以下面的优化结果作为例子,输入文件的格式如下:
Python 程序add_saps.py可以完成结果的拼接工作:
import pandas as pd
source = "blog3_output.xlsx"
sheet = 0
target = pd.ExcelWriter('result.xlsx')
for i in range(1, 6):
sheet = i
ex1 = pd.read_excel(source)
ex2 = pd.read_excel("ec2_saps.xlsx")
merge = ex1.merge(ex2, left_on="type",
right_on="Instance Type", how='left')
merge.drop(['Instance Type', 'vCPU', 'Mem (GiB)'], axis=1, inplace=True)
merge.rename(columns={'SAPS': 'source_saps'}, inplace=True)
merge = merge.merge(ex2, left_on="target_type",
right_on="Instance Type", how='left')
merge.drop(['Instance Type', 'vCPU', 'Mem (GiB)'], axis=1, inplace=True)
merge.rename(columns={'SAPS': 'target_saps'}, inplace=True)
merge.to_excel(target, sheet_name=str(sheet), index=False)
target.save()
运行前提条件:ec2_saps.xlsx和blog3_output.xlsx保存在当前目录下。

注意上面表格的后两列,已经标注了源和目地系统的SAPS值。