All Products
Search
Document Center

IoT Platform:Best practices for instance migration

Last Updated:Jun 06, 2023

IoT Platform provides the instance migration feature. You can use the feature to migrate the products, devices, and data of the rules engine from a public instance of the previous version to an Enterprise Edition instance. This topic describes how to modify a business system to implement instance migration and provides a migration solution. In this example, an enterprise that provides shared services is used.

Background information

The shared-service platform of Enterprise A uses the device management feature of IoT Platform and provides shared services in multiple business scenarios, such as smart parks and smart campuses. The shared services include shared washing machines, shared dryers, and shared massage chairs.

Compared with public instances of the previous version, Enterprise Edition instances of IoT Platform provide more features, better expandability, higher stability, and business models that are more suitable for customers. For more information, see Differences between public instances and Enterprise Edition instances.

To meet the requirements of a shared-service platform-related project that is delivered by a specific customer, you can select a suitable type of an Enterprise Edition instance. This way, you can implement resource isolation, ensure the stability of the shared-service platform, and reduce project evaluation costs. For more information, see Types of Enterprise Edition instances.

IoT Platform public instances of the previous version are released before IoT Platform Enterprise Edition instances are released. Therefore, existing devices run on the public instances of the previous version. To implement resource isolation, ensure stability, and reduce project costs, you can migrate device data from a public instance to an Enterprise Edition instance.

Scenarios

Scenario

Sequence number

Description

1~1.2

Connect shared devices to IoT Platform and submit device data.

Your application uses Advanced Message Queuing Protocol (AMQP) server-side subscriptions or the data forwarding feature to receive data that is submitted by the devices, such as device status.

Your databases store the forwarded device data or subscribed device data in real time.

2~2.2

After a customer uses an app that is provided by the shared-service platform to scan a QR code to complete authentication and authorization, the customer can view the status of a shared device. Then, the customer can use the app to send commands to the shared device to obtain shared services.

Note

After the authentication is successful, the app is connected to the shared-service platform to start billing.

Your application receives the commands from the customer and invokes device management services of IoT Platform to start the shared services on the device.

When the device is running or the processes of the shared services are completed, the device submits the device status to IoT Platform. IoT Platform synchronizes the data of the device status to your application by using the data forwarding feature. Then, your application can store the data in your database. After the processes of the shared services are completed, the shared-service platform sends a PUSH message to the app. The message tells the customer that the processes of the shared services are completed and includes the billing details.

Migration solution

For more information about the process of instance migration, see Usage notes. You must evaluate the business system that is related to shared devices and create a migration solution based on the preceding migration process.

Modify the business system

After you evaluate the business system, you must modify specific items based on your business scenario. This way, your devices can communicate with IoT Platform as expected after the devices are migrated.

Item

Solution

References

AMQP server-side subscription

If you use an SDK to connect an AMQP client to IoT Platform, you must specify the ID and endpoint of the destination Enterprise Edition instance. Then, configure a new AMQP client. When you perform phased migration, specify the latest consumer group ID and start the new AMQP client.

You must start the preceding AMQP clients at the same time. This ensures that two AMQP clients are concurrently run to receive data from the source public instance and the destination Enterprise Edition instance. This prevents data loss.

Connect an AMQP client to IoT Platform

Data forwarding

Configure a data forwarding rule for the public instance.

  • Specify a topic to receive messages when events that are related to all migration tasks occur on the public instance and subscribe to messages when the status of the instance migration tasks changes.

    If a device is migrated during instance migration, a message about the information is forwarded.

  • Forward and store device information to your database.

    During instance migration, the system migrates the data forwarding rule and updates the ID of the source public instance to which a device belongs to the ID of the destination Enterprise Edition instance in the database.

IoT Platform API calls

You must develop an application based on your business requirements. Before you call an IoT Platform API operation, you must query all tables of the database to obtain the ID of the Enterprise Edition instance. Then, set the IotInstanceId parameter to the ID of the Enterprise Edition instance and call the API operation.

Instance migration

After you modify the business system and release the application, you can use the instance migration feature of IoT Platform to migrate the shared devices of the public instance. The following figure shows the migration process.Migration process

Sequence number

Step

Description

1~1.2

Debug the shared devices to be migrated of the public instance.

When a customer uses the app of the shared-service platform to obtain shared services from a shared device, the business application queries the information about the device in the public instance.

You can call IoT Platform API operations to manage the devices to be migrated over an Alibaba Cloud gateway without the need to specify an instance ID.

2~2.5

To start instance migration, perform the following steps:

  1. Step 1: Create a migration task.

  2. Step 2: Perform phased migration.

In the IoT Platform console, create and start an instance migration task to perform phased migration.

  • Migrate a specified product, the data of the rules engine, and the data of devices to which you want to perform phased migration from the public instance to the Enterprise Edition instance. The devices are forcibly disconnected.

  • When you re-connect the devices, the devices are automatically connected to the Enterprise Edition instance. After the devices are migrated, the migrated data is also forwarded to the business server. Then, the business server updates the information about the devices in the database.

  • After the devices that are migrated in phases are verified, you must configure and restart a new AMQP client, and specify the ID that is generated during phased migration for the new AMQP consumer group to receive data.

3

Step 3: Perform full migration.

In the IoT Platform console, start a full migration task to migrate all devices of a specified product to the Enterprise Edition instance. The full migration process is the same as the phased migration process.

Note

The full migration task applies to all devices, except for the devices that are migrated by using the phased migration task.

4~4.2

Verify the shared devices that are migrated to the Enterprise Edition instance.

A customer can use the app of the shared-service platform to obtain shared services from a shared service without the need to obtain the ID of the instance to which the device belongs. The business application queries the information about the device in the Enterprise Edition instance.

If you want to call IoT Platform API operations to manage migrated devices over an Alibaba Cloud gateway, you must specify an instance ID.

Note

If you can obtain shared services from a device as expected after all devices are migrated, the instance migration task is completed and successful.

If an error occurs when you obtain shared services from a device, you can use the rollback feature to migrate the devices from the Enterprise Edition instance to the public instance and keep other data unchanged. For more information, see Migrate the resources of an instance.