AMP for E-Commerce Part 2: Creating Backend with Alibaba Cloud ApsaraDB for MongoDB

Relational vs. Non-Relational Databases

In general, there are two types of databases:

  • Relational databases
  • Non-relational databases

Benefits of MongoDB

Now we will talk more about the MongoDB and the benefits of using the MongoDB over relational databases like MySQL.

Mongo DB Is Schemaless

In relational databases, we define the table schema before any other data operation. Whenever we insert some data into the table we need to make sure we adhere to the schema of the table. If you think there is a change in the model of the data then we need to change the entire table schema or we need to create a new table and normalize it. But in MongoDB the data is stored in JSON like structures.

MongoDB Is Reliable

We can all agree that relational databases available in the market are backed by years of research and proven industry adoption. However, we should also notice that the MongoDB is also adopted by big companies like T-mobile, Sony, Surveymonkey, Foursquare, Invision, and many others.

MongoDB Is Easy to Scale (Sharding and Replication)

Sharding refers to dividing your dataset up over multiple MongoDB servers. You pick a field to act as a division point in your dataset, referred to as a shard keys. Based on this shard key, data is distributed across multiple servers. Sharding allows for horizontal scaling, which is difficult to implement in MySQL.

Deep Query-Ability, Security, and Developer Friendly

MongoDB supports dynamic queries on documents using a document-based query language that’s nearly as powerful as SQL. From the security perspective, MongoDB is more secure because traditional databases can suffer with the SQL injection attacks. For MongoDB, the likelihood of having injection attacks is much lower because of the variable data it stores in the name of its documents.

Alibaba Cloud ApsaraDB for MongoDB

Alibaba Cloud ApsaraDB for MongoDB is a secure, reliable, and elastically scalable cloud database service. It currently supports the ReplicaSet and Sharding architectures and can be quickly deployed in just a few steps. The benefits of using Alibaba Cloud ApsaraDB for MongoDB include:

Reliable Storage

  • Built based on Alibaba Cloud Apsara distributed file system and SSD high-performance storage.
  • Three-node ReplicaSet architecture, ensuring redundant data storage.
  • Periodic automatic backup, ensuring reliable data storage.

Elastic Scaling

  • Supports both the ReplicaSet and Sharding architectures.
  • Nodes of the ReplicaSet and Sharding can be upgraded or downgraded as required to scale resources.
  • The number of mongoses and shards in Sharding instances can be scaled out at any time.

Professional Services

  • Senior Alibaba Cloud technical team members available to provide professional services to boost security and resource elasticity.
  • Optimized kernel for performance, security, and other dimensions managed by the source code team.


  • Cost-effective with no upfront cost or long-term commitment.
  • Offers flexible payment options including Monthly Subscription and Pay-As-You-Go.

Details of ApsaraDB for MongoDB


Alibaba Cloud ApsaraDB for MongoDB supports both ReplicaSet Architecture & Sharding Architecture. There will be minimum of three nodes operating in the replica set architecture by default, where one will be primary, another will be secondary and other will be the hidden. If the primary files the system will choose the secondary, for some reason if the secondary is not available then the system switches to the hidden database to make sure the service is available.


Alibaba Cloud is well known for its security measures across all its products. ApsaraDB for MongoDB provides built-in backup mechanism and recovery which helps in preventing Data loss and minimising the cost of in proper operation it is also equipped with and Anti-DDoS and supports IP whitelist configuration which supports a maximum of 1000 whitelist rules and performs risk control from the access source.


ApsaraDB for MongoDB also comes with visualized operations and management platform. You can monitor the instance information, such as youth CPU utilization connections, and obtain other information visually. The visualized IT management platform simplifies high-frequency and high-risk operations, such as instance restart. ApsaraDB for MongoDB makes data recovery into a single click operation. It also proactively performs subgrade for database kernel version management, and quickly repairs the defects, freeing you from daily version management.

E-Commerce Store Backend

Now we will create the actual setup for our e-commerce store backend and little bit of networking. We create an architecture something like this going further. Please find the diagram for reference

Creating an ApsaraDB for MongoDB Service

Now we will create backend database of the ApsaraDB for MongoDB Service in Alibaba Cloud. On the console, navigate to Products > ApsaraDB for MongoDB.

Next Steps

We will create a simple Express based node API to query data for our database and serve the E-Commerce App built by leveraging the open source templates provided by the AMP Site. The whole integration will happen in the next tutorial, so please be sure to check it out.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website: