Blog: Mobile commerce, AWS, and the Great Chinese Firewall

As a technology company there is a stark truth that exists every day: not all tech is created equal. For us, there was no greater example of this than when we crafted a global mobile app that had to work in China. While China has continued its upwards trajectory over the past two decades, they have maintained an increasingly strong approach regarding internet access and technologies available to their citizenry. When our client approached us to build their global app, we knew that we would face a myriad of technological hurdles related to the Chinese government’s rules and regulations. Our goal was to deliver the same high standards that our clients expect from us regardless of limitations set by any government.

The challenges in building an application for the Chinese market

From the moment we began to sketch out the development of the application we saw that there would be multiple obstacles. To develop a truly mobile application, one that can satisfy both the U.S. and Chinese markets, it’s critical to overcome several crucial barriers.

1. Limited access. Many Internet services in mainland China are blocked. You can see the full list of websites blocked in China on Wikipedia. Just imagine, there’s not even a Google Play Store in China! Google, Facebook, Twitter — all these popular services that you would like to use in your mobile application are hardly accessible in China. So, we had to use specific local services instead of these popular blocked services.

firewall

Due to these firewalls and limitations, there is a significant network latency in mainland China, which should always be in the back of your mind when creating your system architecture design.

2. Scalability. From the moment that the application launched, our customer expected upwards of a million users. While these numbers sound staggering, this is very typical for the internal Chinese market due to the large number of mobile users in China. We had to find an auto-scaling solution, which would wisely balance the load, distributing the requests between multiple virtual machines.

3. Support of local services. You may need to integrate into your mobile applications specific Chinese services such as Baidu, WeChat, QQ, Sina Weibo, etc. Finding popular and effective replacements for key services such as Google Maps was a critical element of ensuring that the functionality of the app remained consistent throughout the world. Get ready to read tons of manuals in Chinese, and may Google Translate bless you.

4. QR codes. We found out that QR codes are extremely popular in China. Using them in a mobile application is not a big deal, however, we can admit that our Chinese colleagues insisted on using QR codes everywhere when it’s possible. No surprise that we ended up with integrating QR codes into registration and login operations, and even payments.

qr

5. Licensing. You can deploy an online application or website in China only after receiving a license from the Ministry of Industry and Information Technology. Bureaucracy, it seems, is the same in every language.

Background on Amazon Web Services in China

The AWS advantages, security, scalability, and dynamic pricing are still available in China. So, building web services and applications based on AWS remains a profitable solution, which is ideal for companies ranging from startups to Enterprise.

However, you should consider a number of specific features, which are inherent in the AWS in China. For example, AWS in China has only 2 available regions — Beijing and Ningxia.

One of the main obstacles is that you can’t use your regular Global AWS account in China. This forced us to create a local account with separate billing (not consolidated with your Global AWS account). First of all, you need to submit your information at amazonaws.cn.

After AWS verifies and authorizes your account, you can use Amazon Web Services in China.

AWS in China provides you with a very limited number of available services compared to the US or European Amazon Web Services list. Check the full list of supported Amazon Web Services for both available Chinese regions at amazonaws.cn.

aws

Usually, we use the CloudFront content delivery network in our applications. One of the major drawbacks of AWS in China is that the CloudFront is unavailable here. So, we had to deliver content to the Chinese users directly from our Chinese S3 bucket. In addition, we keep it synchronized with our Global AWS account, leveraging the Amazon CloudFront there to deliver content all over the world, except for the internal Chinese market.

Specific application features and how we approach them

The general purpose of the application is to match customers with service providers and product suppliers across the globe. Here are the key features that we implemented in the application.

1. Matching

The core feature of the application is matching users. There are quite a few proven matching algorithms, which we had already tested. The only problem that we’ve faced is typical for all Uber-like applications in our new ‘gig-economy’. The thing is that the service providers, for example, photographers, can be moving around the city or even travel to different countries. So, the application needs to update their geolocation automatically in order to display their current location on the map.

2. Geo search

Geolocation services are extremely popular in China. For example, Momo, one of the most popular apps in China, began as a service to connect with strangers around you and has since expanded to include dating and local shops. Most of the mobile applications in China have additional features based on geolocation data.

map

The application that we developed was not an exception. We used the customer’s location for the geo search. This operation requires significant computer power because you need to find all the service providers within a certain range very quickly. We used geohash indexes to simplify the search. Moreover, we found out that MongoDB provides support for geohash indexes and allows for running geospatial queries. A great surprise for our beleaguered developers. That’s why we decided to use this database, changing the initial application’s architecture.

3. Maps

Maps are a key component of any geo-based app and ours was no exception. Integrating maps into the iOS app was simple because Apple Maps work perfectly there but Google Maps is a whole other story. Our goal was now to ensure that Android users could have the same experience as our iOS users. Baidu Maps, a service with almost 350 million monthly active users, became our go-to mapping system on Android in the Chinese market.

4. Chats

We leveraged MongooseIM chat service, customizing it according to the application’s needs.

We stored all users’ data (for example, pictures and videos sent from one user to another) in the Amazon Simple Storage Service, also known as Amazon S3. In order to deliver this content really fast all over the world, we integrated Amazon CloudFront secure content delivery network. This CDN works well for international users but is unavailable in mainland China. So, we delivered the files to the Chinese users directly from the Amazon S3 bucket.

Also, we configured hot storage Redis replica set for high availability and disaster recovery of the instant messages. For cold storage, we used Amazon Aurora for MySQL primary and replica databases.

We integrated Bing Microsoft Translator service into the chat module to make the communication even more convenient for the users from all around the world.

5. Payments

We used PayPal and HantePay, which is a popular solution for cross-border payments. It uses China’s advanced payment technologies (for example, scanning QR codes with WeChat messenger to confirm the payment) to target US market.

payments-paypal-hantepay

Customer’s benefits

The DB Best application development team delivered a bespoke solution that works well both in mainland China and in the US. So, our customer was absolutely thrilled with the iOS and Android mobile applications that they received. Here’s the short list of the customer’s benefits:

  1. The application uses the appropriate stack of services depending on the user’s location.
  2. It bypasses the Great Chinese Firewall and allows for secure and reliable international messaging, data transfer and payments.
  3. The app takes full advantage of the Amazon Web Services in China and the AWS Global infrastructure.

Our developers have had an incredible experience taking on this increasingly common challenge. As the profitable Chinese market becomes accessible to companies both large and small, we are fielding more and more requests from customers to build truly global applications. Development of these apps involves crafting a balancing strategy that both satisfies our customer’s goals as well as adheres to China’s stringent rules. Our global team took on this challenge because we are one of the few companies that can leverage our unique knowledge of app development and infrastructure to ensure that no matter where in the world your customers are using your service, they’ll be rewarded with the best experience possible.