Help Center/ GeminiDB/ GeminiDB DynamoDB-Compatible API/ Best Practices/ GeminiDB Serverless for Real-Time Flash Sales
Updated on 2026-01-30 GMT+08:00

GeminiDB Serverless for Real-Time Flash Sales

Overview

Databases, the core of application systems, play a pivotal role in shaping user experience during digital transformation. This practice explores how to use GeminiDB to quickly create data tables and implement real-time storage and retrieval of massive amounts of data.

GeminiDB is a cloud-native distributed NoSQL database service, with response latency of just sub-milliseconds and almost unlimited scalability. Architected to scale effortlessly, GeminiDB evolves with your demands, whether your applications are starting from scratch or are growing fast from tens of thousands to hundreds of millions of concurrent connections. Developers can easily interact with databases through standard HTTP APIs or secure HTTPS endpoints. As a flexible NoSQL solution, GeminiDB supports dynamic schema design, making it ideal for rapid application iteration.

Background

During peak events like Double 11 shopping festival, large-scale promotion activities, and live commerce, there are often traffic spikes due to hundreds or even thousands of times in user growth.

Because manual scale-up in traditional databases can take hours, applications may fail to respond in time to sudden traffic peaks. To handle only several promotions each year, companies had to keep high-spec clusters running continuously, leading to resource waste and additional costs.

This is where GeminiDB Serverless comes in. It delivers:

  • High scalability: Storage can automatically scale up in seconds. You do not need to estimate the capacity in advance.
  • Low latency: I/O operations respond within 10 ms, ensuring smooth ordering experience.
  • Pay-per-use billing: Paying only for consumed RCUs and WCUs effectively lowers operational costs.

Data Model and Write

Query-driven modeling is a core principle in NoSQL design. During promotions, the order service is streamlined by keeping only the core order table and two essential indexes, improving query efficiency and system responsiveness.

Retrieval Example

When creating a secondary index in GeminiDB, you can select which fields need to be synchronized to the index. The fields include:

  • ALL: All fields are synchronized. This method is simple but requires the most storage.
  • INCLUDE: Only key fields frequently queried are synchronized, such as status and amount, to enable index-only searches and avoid additional latency caused by table lookups.
  • KEYS_ONLY: Only the primary key field is retained. This method requires the minimum amount of storage but may introduce additional response time due to table lookups.

INCLUDE is recommended in promotions and other high-concurrency query scenarios. Projecting common fields to indexes can significantly improve query efficiency and overall system performance.

UserIdIndex can quickly fetch data in milliseconds, even if the primary table stores billions of records.

response = table.query( 
     IndexName='UserIdIndex',  
     KeyConditionExpression='user_id = :val',   
     Limit=10,               # Pagination
     ExpressionAttributeValues={ 
         ':val': 'user_01'
     } 
 )

Operations personnel need to view the order trend of the promo_01 activity. PromoIdIndex simplifies complex analysis and queries and efficiently scans the key range.

response = table.query(
    IndexName='PromoIdIndex', 
    KeyConditionExpression='promo_id = :val',  
     Limit=10,             # Pagination
    ExpressionAttributeValues={
        ':val': 'promo_01'
    }
 )

Summary

The high-concurrency promotion system built on GeminiDB Serverless fully leverages cloud-native capabilities to strike a good balance between development efficiency and operating costs.

The system design is based on query-driven modeling. order_id is used as the distributed primary key to effectively distribute writes and ensure system stability in high-concurrency scenarios. The system builds multi-dimensional global secondary indexes to retrieve user views and operations dashboards in milliseconds, ensuring excellent responsiveness across the entire workflow.

To ensure data consistency during promotions, the system deeply integrates conditional expressions of GeminiDB. Atomic and idempotent writes and status transfer to databases avoid repeated orders and logic conflicts. With autoscaling in seconds and pay-per-use billing of Serverless, enterprises can handle traffic spikes smoothly without having to estimate capacity in advance. This significantly improves system availability while reducing O&M costs caused by idle resources.