# Weixin Mini Program Pressure measurement

# Requirements scenario

A lot of Weixin Mini Program will carry out some operational activities, and there will be a lot of users at the same time. When the number of users is relatively large, the business side may be concerned that the excessive pressure will lead to abnormal functions of the Mini Program.

At this point, the development class / test class would like to be able to perform a ** stress test ** on Weixin Mini Program, for example, to simulate 1,000 users and open a Mini Program scene at the same time.

Naturally, a common idea is to use 1000 phones and open Weixin Mini Program at the same time to simulate user concurrency.However, using a pure UI autodynamic method to pressure measurement, you will encounter the following problems:

  1. Due to the different performance of each phone, controlling multiple phones is basically impossible to open at the same time.
  2. It's expensive to do an end-to-end pressure test with 1,000 phones.And because the number of phones is limited, the pressure bottleneck has a clear upper limit

# Solutions

The [WeChat Gateway launched by WeChat supports the Weixin Mini Program suppression capability, which can generate WeChat code, enabling full-link suppression of real user requests to the business interface and the WeChat open interface

Donut tools focus primarily on whether server-side requests are responding normally, unperceived Weixin Mini Program UI performance and performance in stressful situations .

Here you can combine the Weixin Mini Program cloud test automation / performance testing capabilities with the Donut gateway.Firstly, the Donut gateway is used to press the background server, for example, the concurrent user volume is adjusted to 1000. After pressure rises, the corresponding test tasks are normally performed in cloud testing. This is equivalent to using several mobile phones to simulate a situation where "1,000 mobile phones open the Mini Program at the same time."

Automated testing and aptitude testing capabilities through a combination of cloud testing (such as collected screenshots, video recordings, experience scores, startup performance, network requests, whether there are black-and-white JSErrors, etc.), users can ** get a full view of the actual UI performance under stressful conditions. Weixin Mini Program**

# Practical examples

Requirements: Weixin Mini Program A hope to pressure test the content of the home page, observe 100 users at the same time to open the home page of the performance is abnormal.You can follow the following steps:

# 1. Donut pressure

After the user establishes a gateway in Donut, debug the background pressure test request link, for example Weixin Mini Program A wants to pressure test the home page, the requested link is:

  1. First get the user code
  2. Use WeChat code to access the server background and identify the user
  3. Once the user is identified, generates home page content data

After the debugging is successful, you can schedule a compression task according to the actual requirements, such as configuring 100 concurrent users and a compressor duration of 30 minutes.

# 2. Cloud testing quality inspection task

Once the pressure task is started, it is recommended to start the cloud testing task immediately (because cloud testing requires initialization of the real machine, it generally takes 2-5 minutes to actually pull up Weixin Mini Program).

The types of tasks performing cloud testing are recommended to use Weixin Mini Program quality inspection capabilities, because quality inspection initiates both startup performance testing and automated testing tasks:

  • Startup Capability Test: To see if the Weixin Mini Program startup time slows down under stress
  • Automatic test: automatic task can be based on the actual needs of the business, using Monkey, recording playback, a Minium. The main purpose is to observe whether there are functional anomalies or performance problems under stress (e.g., the Monkey test can detect JSError, black and white screen, etc.)

Here Weixin Mini Program A Monkey is used as an automated test solution. Generally, the homepage content is loaded normally, but when the server is under a lot of pressure and the network returns slower, Mini Program A has JSError problem

# Follow-up planning

At present, users need to manually start tasks in Donut and Cloud Measurement respectively.

The combination of the follow-up cloud test and Donut allows users to choose to start the cloud test task at the same time when performing the pressure test task in Donut, bringing a better pressure test experience.

If you have any questions about the pressure measurement, welcome to the help page , join the official enterprise micro group, and discuss with the cloud measurement assistant