Efficiently managing millions of Tamagotchi devices with AWS IoT

[ad_1]

Tamagotchi Uni, the first model in the Tamagotchi series to be equipped with wi-fi connectivity, is now available. This new model allows Tamagotchi to connect directly to the internet and interact with other unique Tamagotchi from around the world. BANDAI CO., LTD., the company responsible for product development and sales, adopted AWS IoT to realize the concept of globally interconnected Tamagotchi, enabling users to interact with each other.

In this post, we share how BANDAI CO., LTD. and their cloud development partner, Phoenisys, Inc., used AWS to connect and manage millions of Tamagotchi devices. In particular, it was crucial to perform remote updates, using the Jobs feature of AWS IoT Device Management to distribute the latest firmware across all Tamagotchi devices without causing any delays for customers.

What are Tamagotchi Uni?

Tamagotchi Uni  

The Tamagotchi is handheld virtual pets that users can nurture. Over 91 million units have been sold worldwide since inception in 1996 and have been appreciated by people of all ages. The latest model in Tamagotchi series, Tamagotchi Uni, was released worldwide on July 15, 2023. This new model allows Tamagotchi to connect directly to the internet and interact with other unique Tamagotchi from around the world. The vision for the product is to create a world where Tamagotchi fans across the world can communicate with each other using their own nurtured Tamagotchi.

Tamagotchi Uni evolutions

With wi-fi connectivity, Tamagotchi users can explore the Tamaverse, a metaverse of Tamagotchi, and meet Tamagotchi nurtured by users around the world. Additionally, Tamagotchi Uni are directly connected to the cloud, allowing users to continuously download new events and items for distribution. Connectivity also enables users to simultaneously compete and cooperate with each other. These functionalities are possible due to AWS IoT Core, which offers reliable cloud connectivity across many AWS Regions.

TamaverseTamagotchi Uni connects to the internet via wi-fi

Secure connectivity with AWS IoT and a serverless architecture

To make Tamagotchi Uni IoT-enabled, BANDAI established the following three key goals:

  • Implementing secure connections
  • Scaling and load-balancing resources to accommodate over 1 million connections worldwide
  • Optimizing operational costs

The Tamagotchi solution has been implemented on an AWS serverless architecture using AWS IoT.

AWS architecture for Tamagotchi Uni

AWS architecture for Tamagotchi Uni

This section briefly describes how AWS services are used in the architecture to help improve the reliability and cost-effectiveness of developing, operating, and managing Tamagotchi Uni.

AWS IoT Core

Tamagotchi Uni use AWS IoT Core for authentication, connection, and messaging. The Device Shadow feature is used to manage the state of each Tamagotchi Uni device, using the delta of the shadow as a flag to retrieve distributed items and content. This ensures efficient communication between the device and AWS, facilitating seamless interaction.

AWS IoT Device Management

The development team anticipated that managing the growing supply of Tamagotchi Uni devices would become challenging. Therefore, they used AWS IoT Device Management to index the extensive Tamagotchi Uni fleet and create dynamic groups based on the state of each device, facilitating efficient over-the-air (OTA) updates.

FreeRTOS

The Tamagotchi Uni device software that connects to AWS runs on FreeRTOS, which minimizes the amount of resources and code required to implement device-to-cloud communication for efficient system development.

AWS Lambda

Tamagotchi Uni use AWS Lambda for processing tasks, delivering new announcements, and registering assets.

Amazon DynamoDB

Tamagotchi Uni use Amazon DynamoDB as a fully managed, serverless, key-value NoSQL database that runs high-performance applications at any scale.

Amazon Simple Storage Service (Amazon S3)

Tamagotchi Uni use Amazon S3 as an object storage service that offers industry-leading scalability, data availability, security, and performance. Each of these data stores are used to manage the various resources within Tamagotchi Uni.

Amazon Timestream

Tamagotchi Uni use Amazon Timestream to accumulate historical data of user’s actions like downloading items and additional content.

Challenges in firmware distribution to all devices

The team will use AWS IoT Jobs to update Tamagotchi Uni with new games and content through periodic firmware updates. While Jobs makes firmware updates easy and secure, the team learned that the default maximum number of job executions per hour (1,000 units per minute) would result in too much time required to complete updates for all of the devices.

The extended time would cause delays and an inconsistent experience for customers. Some customers might learn that other users got the update and are enjoying the new content while their own device is outdated. For customers eager to enjoy the new content as soon as possible, the prolonged wait for the update can result in significant stress.

While it is possible to adjust the quota for the maximum number of job executions that can be delivered per minute, there are limits.

Overcoming challenges with large-scale firmware updates

To minimize wait times, the team changed the firmware update process so that the update would be executed when the customer agreed to the update. Since the update process requires human intervention, it cannot be performed on all devices at the same time. Considering that the timing of server inquiries may vary depending on the customer’s playing environment and time differences, the team determined that it wouldn’t be necessary to distribute the update to all devices at the same time. The new policy prioritizes ordered distribution to customers who make update inquiries.

To technically realize the new policy, the team designed job delivery as a continuous job, with the job target being dynamic thing groups rather than individual things (see following figure). Dynamic thing groups are a feature of AWS IoT Device Management that allows you to set search conditions for things registered in AWS IoT when creating a group. In this case, when things are added to the dynamic thing group after the job is created, the job is delivered immediately to those newly added things. This allows for faster and more efficient job delivery, specifically delivering to the devices that meet the set conditions.

The mechanism and ingenuity of the firmware distribution for Tamagotchi

The mechanism and ingenuity of the firmware distribution for Tamagotchi

The fleet indexing feature automatically searches for things that meet the conditions and dynamically adds them to the thing group.
In this project, the query conditions for the dynamic thing group were configured into the following four conditions:

  1. The firmware version of shadow.reported is higher than the initial version
  2. The firmware version of shadow.reported is not the latest version to be distributed
  3. The firmware version of shadow.desired is the latest version to be delivered
  4. connectivity.timestamp is greater than the specified UNIX epoch milliseconds

All four of these conditions were combined with the logical operator AND.

Searching for connected devices

Noteworthy among the query conditions is the use of the connection timestamp (connectivity.timestamp) of the device as a fourth search condition. This allows the job to target only those devices that have a proven connection record. The connection status (connectivity.connected:true) could also be included in the query. However, if the connection status is used as a condition, the device will be removed from the dynamic group when the Tamagotchi Uni restarts after an update and the firmware image and job information cannot be verified. This is why the team decided to use the connection timestamp as a condition instead of the connection status. The UNIX epoch milliseconds in the condition is set to one hour before the dynamic group creation timing. This approach enabled us to efficiently distribute updates by adding them to a dynamic group based on the order of customers’ inquiries regarding the availability of updates.

Managing firmware versions with Device Shadow

The first three mentioned search conditions use Device Shadow. Tamagotchi Uni use Device Shadow for the management of update flags for all assets, including updates and additional content. By enabling devices to retrieve data only when there is an update in the shadow, it helps reduce the frequency of communication. Tamagotchi Uni also use Device Shadow to manage firmware versions and search conditions in dynamic group queries 1-3, especially, the shadow.desired condition in query 3. However, this approach presented a challenge. To notify updates for so many targeted devices, it would require updating the shadow of each device individually. Consequently, updating the shadows of all devices took a significant amount of time, which impacted the distribution speed.

As a solution, the team decided to update the shadows in parallel. The following procedures and configurations helped to reduce the update time significantly:

  1. Creating an SQS queue to monitor the progress status of dynamic group creation after it has been executed.
  2. Polling monitoring the progress status of the dynamic group rebuild with updated query conditions.
  3. When all target things become members of the dynamic group and the rebuild completes, retrieve the things that have become members in batches of up to 250 devices at a time, and issue a message to the SQS queue requesting a shadow update.
  4. When a message is issued to the SQS queue, a Lambda is called in parallel to update the shadow.

This flow improved the user experience by efficiently and quickly distributing updates in the order of customer inquiry.

Testing system performance

Finally, as part of load testing, BANDAI created a large number of simulated devices that emulated the access behavior of Tamagotchi Uni and were able to verify the smooth operation and performance of the update. The test allowed the team to feel confident that performance would be stable and could be maintained, even under large-scale access.

Conclusion

Tamagotchi Uni, the first model in the Tamagotchi series to feature wi-fi connectivity, have created a world where Tamagotchi fans can feel connected regardless of gender, age, or nationality. This post provided a detailed view on how Tamagotchi Uni use AWS to achieve secure and reliable connectivity and quickly deliver new content updates without leaving customers waiting.

Japanese version of this blog post can be found here.

Authors

Daisuke Sakamoto

BANDAI CO., LTD.

Technical Design Team / Global Toy Product Development Department / Toy Division

Yoshiyuki Yotsuyanagi

Phoenisys, Inc.

Development group

Shota Iizuka

Amazon Web Services, Inc.

IoT Specialist Solutions Architect

[ad_2]

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top