×
Community Blog EasySDK — A Powerful Recommendation Tool for ECS Inventory Resources

EasySDK — A Powerful Recommendation Tool for ECS Inventory Resources

In this article, the author explains how to use EasySDK to choose ECS instances in Alibaba Cloud based on various requirements.

Introduction

As Alibaba Cloud offers cloud services in more and more regions and zones, our product specifications are gradually iterated. With an increasing number of zones, more variety of specifications and complicated pricing strategies will arise, introducing new challenges to cloud resource management. Common questions when managing cloud resources such as Elastic Compute Service (ECS) include:

  • How can you select appropriate regions and availability zones?
  • How to prioritize appropriate specifications?
  • How to set the expected price?
  • How to avoid insufficient resource inventory?

Based on the above problems, we created an all-in-one open source SDK, EasySDK to help you effectively solve the problems. This article mainly explains the capabilities and usage of the "resource recommendation submodule."

Applicable Scenarios

The following problem arose with the growth of Alibaba Cloud users and the diversified usage scenarios.

1) Inventory

1) The Elastic Compute Service (ECS) inventory is not disclosed to the public due to security reasons. Consequently, you cannot perceive the specific absolute inventory of each specification in each availability zone. It is unreliable to randomly select availability zones and specifications, which often leads to insufficient resources when creating instances.

2) Our open source EasySDK uses the "progressive algorithm" innovatively and has undergone rigorous internal argumentation to ensure a high inventory of top-ranking instance types.

2) Duplicated Code

1) For example, if you want to create a network-wide preemptible instance based on the lowest price policy, more than 5 ECS APIs must be interfaced to obtain valid information.

2) The open-source EasySDK directly encapsulates these boiler-plate codes. You can use only a few lines of code for common scenarios to solve problems.

Recommendation Validity

"Validity" is another core feature of the EasySDK.

As the first SDK plug-in open to the public, the validity of the recommended results has been strictly demonstrated. Taking the "inventory first" policy as an example, various possible scenarios have been enumerated and analyzed. By correlating the simulation results of the "progressive algorithm" with the actual inventory in the background, the comprehensive confidence level is over 85%. Therefore, you can use it with confidence. The specific validity verification scheme will be described in subsequent separate articles.

Application Methods

The core idea of using EasySDK is simple. You can apply the following three simple steps to use it.

Step 1: Introduce dependencies.

<dependency>
    <groupId>com.aliyun.ecs.easysdk</groupId>
    <artifactId>preemptive-instance-recommendation</artifactId>
    <version>0</version>
</dependency>

Step 2: Initialize the SDKs.

// Replace the accessKey with your Alibaba Cloud accessKey
String accessKey = "<your-access-key>";
// Replace the secretKey with your Alibaba Cloud secretKey
String secretKey = "<your-secret-key>";
EasyEcsSDK.setProperty("aliyun.easysdk.sdk.ecs.access_key_id", accessKey);
EasyEcsSDK.setProperty("aliyun.easysdk.sdk.ecs.access_secret", secretKey);
EasyEcsSDK.init();

Step 3: Call the recommended methods.

PreemptiveInstanceRecommendationService preemptiveInstanceRecommendationService = EasyEcsSDK.getService(
    PreemptiveInstanceRecommendationService.class);
PreemptiveInstanceRecommendationRequest request = new PreemptiveInstanceRecommendationRequest();
List<String> regions = new ArrayList<String>();
regions.add("cn-beijing");
regions.add("cn-hangzhou");
regions.add("cn-shanghai");
request.setRegions(regions);
request.setStrategy(EnumRecommendationStrategy.SUFFICIENT_INVENTORY_FIRST);
request.setCores(1);
request.setProductCategory(EnumEcsProductCategory.EntryLevel);
request.setLimit(10);
Response<List<PreemptiveInstanceRecommendation>> recommend = preemptiveInstanceRecommendationService.recommend(
    request);

The returned <availability zone, specification> list is sorted by the policy entered by you, such as "inventory first" in the sample. That is, the more sufficient the inventory, the higher the sorting.

For more complete examples, you can refer to https://github.com/aliyun/alibabacloud-ecs-easy-sdk/tree/master/demos

We will consider more scenarios to add and improve in the future and welcome positive contributions and feedback.

Follow-up Plan

We will continue to maintain this open source project in the future. We have now received great positive feedback from all parties. For more information about the project roadmap, navigate to https://github.com/aliyun/alibabacloud-ecs-easy-sdk/projects/1

FAQ

Q) Where is the project address?

A) The project is open source and available via GitHub. You can use or modify the source code as required.

Q) Is the SDK officially maintained?

A) Yes, the ECS team carries out professional and long-term maintenance. At the same time, however, we hope you can participate in it and actively submit issues and contribute codes.

Q) What languages are supported?

A) Currently, only Java is supported. The CLI tool is under intensive development, and support for Python and Go is under planning. We welcome your participation.

Q) Which policies does the resource recommendation capability support?

A) Three policies are currently supported:

  • Price first: the lower the price, the higher the sorting;
  • Inventory first: The more sufficient the inventory, the higher the sorting;
  • Product generation first: Product specifications released more recently are presented first. However, we recommended using the "inventory first" policy for preemptible instances that require stable holdings to prevent drastic price fluctuations caused by short-term purchases in bulk.
0 0 0
Share on

Alibaba Cloud ECS

33 posts | 12 followers

You may also like

Comments

Alibaba Cloud ECS

33 posts | 12 followers

Related Products