# Pressing Tools

In order to facilitate the business to do Weixin Mini Program before the official launch or marketing activities before the launch of the real full link pressure measurement, To detect service bottlenecks in a timely manner, the Weixin Mini Program team introduced the value-added capability of "pressure tool" in the WeChat gateway, using WeChat real accounts to request the Mini Program business interface & WeChat open interface for full-chain pressure. Realizing complex scenarios such as massive high concurrency in the business helps developers evaluate the performance and stability of Mini programs in high concurrency situations in order to identify and resolve potential performance issues in a timely manner. We can test the response time, throughput and concurrency of the Mini Program under different loads, so as to determine the maximum load carrying capacity and bottleneck of the Mini Program.

As a value-added capability of the WeChat gateway, the WeChat gateway is supported by the "Standard Edition" and above package versions, and the entry and basic versions need to be upgraded to the "Standard Version."

# I. The Particle Mission

Go to "WeChat gateway - expand capacity - pressure measurement tool" in the new pressure measurement task;The balancing task is a pure balancing logic part, and if you want to perform the balancing, you need to schedule the balancing first.

# 1.1 Task editing

The editor interface consists of two sections on the left and right: the request list and the request settings.At the same time, the compiler supports setting the name of the test task and selecting the Weixin Mini Program of the test.

# A. Name of Pressure Measurement Task

The task name can be used to distinguish between different compression tasks, such as "active compression," and is no more than 32 characters.

# B. Pressure measurement Weixin Mini Program

The task is pressed according to the Weixin Mini Program dimension, in order to determine the identity of the Mini Program used by the pressure test task, including the identity of the WeChat interface, which will affect thewx.loginwx.getUserProfileAnd the value ofx-wx- AppIDreceived by the server in the gateway request.

# C. List of requests

The request list shows the requests used in this compression, and supports dragging to change the order of the requests. Clicking on the request allows you to switch to the request editor.

# D. Additional requests

Supporting compression requests are as follows:

  • The business request, gateway.call, is compression Weixin Mini Program The Mini Program configured in the gateway access layer URL (unconfigured to support compression)
  • WeChat request, that is, the callback API under the wx object, currently supports 8 interfaces such as Weixin Login and Weixin Pay, and more other WeChat open interfaces
  • Cloud function request, that is, WeChat cloud function request in cloud development, only pressure test Weixin Mini Program cloud function created in WeChat cloud development
  • Wx.request (not currently supported)

# 1.2 Request settings

  • Request Name: Each compression request supports a custom request name.
  • Request Gateway Domain Name: Select the gateway domain name that is configured at the gateway access layer.
  • Request Interface: Fill out the request interface content that needs to be pressed on demand.
# WeChat Request

When using WeChat request, you need to refer to the official WeChat document to fill in the required parameters for pressure measurement.Some interfaces do not require parameters (such as wx.login).

# Business Requests
  • The business interface supports setting the request's HTTP Method, the request's Header, URL (Path), and the request's Body.
  • The default request header is Content-Type: application / json, which can be flexibly adjusted according to your needs.
  • The supported request body form is text form, the rest of the format is not supported.

# 1.3 Extract settings

Request support for setting parameter extraction, which can be done in the form of JSONPath.Extracted parameters can be referenced in subsequent interface parameters in the format ${extract_name}.

WeChat The extraction of the interface is set to fixed extraction, and the parameters extraction supported by default are as follows:

wx.request:code
wx.requestPayment:qrcode_img、data

The service interface is used to request the service interface, which can simulate the request of gateway.call.

The gateway interface supports parameter extraction in the form of JSONPath, such as $.data.x.y.z. The gateway backhaul structure is as follows:

{
  data: {}, // 返回的数据包内容
  http_code: 200, // 返回的状态码
  status: 1, // 压测状态,详见下表
  headers: [], // 返回的 Header 列表,结构为 {"k": "key", "v": "value"}
}

When you need to extract the backpacket content of the reference gateway, you can extract it in the form of JSONPath:

  • Ordinary object extraction: $.data.x.y.z
  • Extraction of Array Subscripts: $.data.arr.0.x.y.z
  • Other forms of extraction, you can refer to the JSONPath documentation

# 1.4 Separate gateway requests

The gateway request will carry a special header, according to which the server can determine whether the request is from the pressure measuring tool

  • x-wx-source: wx-pressure-test

# 1.5 List of pressure states

{
  0: '正常',
  10001: '初始化配置失败',
  10002: '转移配置列表为空',
  10003: 'JSON解析失败',
  10004: 'JSLogin失败',
  10005: '网关调用失败',
  10006: '获取返回结果错误',
  10007: 'JSON转PB解析错误',
  10008: '设置缓存错误',
  10009: '获取结果为空',
  10010: '获取序列号失败',
  10011: '创建API失败',
  10012: '解析内容错误',
  10013: '获取UUID失败',
  10014: '获取存储的UUID失败',
  10015: '更新支付UUID存储错误',
  10016: 'JSON解析失败',
  10017: 'DOC解析失败',
  10018: 'BASE64编码失败',
  10019: '校验条件语句错误',
  10020: 'HTTPCODE错误',
  10021: '解析数据错误',
};

# 1.6 Pressing conditions

The request support sets the pressure condition, and if the pressure condition does not pass, the next request pressure is automatically stopped.

Pressuring conditions support expression conditions (custom) and request conditions. Expressions support inclusion, non-inclusion, equal, and not equal.

# Expression Conditions

Expression conditions are determined using JSONPath, as in parameter extraction, using the form$.data.x.y.zto define the left side of the expression and the right side as a character string.

# Request Conditions

Request criteria support the determination of the following conditions:

  • Request Return Status Code: HTTP Status Code
  • Pressure state: Consistent with the state code defined in the Pressure State List above

The left and right sides of the expression are converted to a character string for comparison.

# 1.7 Pressure debugging

In a pressure task, clicking the "debug" button can go to the pressure debugging, which shows the execution of the various interfaces, the execution results, and the corresponding return values / Headers in the current pressure task. If the pressure midway interface reports an error, or the condition judgment does not pass, the pressure task will be automatically stopped.

# II. Appointment Pressure Monitoring

To schedule a compression, click on "schedule compression" in the top right corner of the target compression task card. After the appointment is successful, you can view specific appointment information in the "appointment list."

  • Reservation Name: Used to identify the current pressed appointment task, supports arbitrary naming
  • Target QPS: that is, the QPS quota that is required to perform pressure measurement when booking the pressure measurement task;If the target QPS required for pressure measurement is greater than the current gateway package QPS quota, you need to purchase an additional WeChat gateway resource pack for pressure measurement
  • Pressure measurement duration: currently supports 5 min, 10 min, 15 min, 20 min, 25 min, 30 min
  • Pressing time: Please arrange the appointment time reasonably. Do not exceed the valid time range of the gateway resource pack you have purchased. Only one pressing task per unit time is supported
  • The valid time of appointment task: that is, the valid time of appointment pressure test task can be executed, the valid time of one pressure test appointment task is 30 minutes; If you have scheduled a compression on July 11 at 00: 00, you will be able to click "Execute compression" to start the compression before 00: 30.

Dxplaination:

  1. After the appointment is complete, the specific appointment information will be displayed in the appointment list. It is only necessary to apply the pressure on time. If the pressure is not applied beyond the appointment period, the appointment task will expire and the appointment will need to be re-booked
  2. After performing the appointment pressure measurement task, the platform will carry out real-time pressure measurement on line according to the appointment pressure measurement QPS; If there is a problem in the middle, you can terminate the compression at any time. Terminating the compression is the end of the compression and does not support restarting.
  3. The pressure test is a real user request to Weixin Mini Program. In order to ensure the normal operation of the back end of the business, please prepare resources before booking the pressure test task
  4. Because a pressure test appointment task is valid for 30 minutes, only one pressure test task is supported in 30 minutes. If you have booked the pressure test at 000000 on July 11, the next appointment task needs to start at 000031 on July 11, because the effective time is 30 minutes.

# III. Purchasing pressure control resources

As a supplement to the WeChat gateway package, after purchasing the gateway resource package, you can increase the QPS amount on the basis of the original gateway package.When a purchase is successful, it will be displayed in the appointment list.

  • Pressure measurement QPS: Purchase according to business pressure measurement needs, the purchased resources QPS need to be 100 multiples, maximum support 10wQPS
  • Pressing time: Purchases are only supported on a day-by-day basis. The default effective time is 00: 00: 00 - 23: 59; If the pressure time is selected on July 12, the gateway resource pack is valid from 00: 00: 00 to 23: 59 on July 12.
  • QPS billing unit price: 99.9 yuan / 100 (QPS * 2Mbps) / day, if there is a discount will be reflected in the price calculation

Dxplaination:

  1. After the purchase of the gateway resources, they are valid for the period of time under the gateway resource quota, supporting arbitrary appointments and performing pressure tasks
  2. The QPS quota that can support pressure measurement is the sum of WeChat gateway package QPS quota and gateway resource package QPS quota;If the WeChat gateway package QPS is 1000, and the additional 9000 QPS pressure measurement gateway resource package is purchased, the maximum pressure measurement QPS amount can be supported as 1000 + 9000 = 10000 QPS.

# IV. Pressurisdiction reports

After performing an appointment pressure task, a pressure report can be generated. Click on the report of the pressure task corresponding to the appointment to view the pressure report.

# V. FAQS

# 1. Is the ballast of a pressure tool performed directly online?

A: Here is a distinction between the WeChat interface and the business interface:

A. WeChat interface, is conducted online Yes, performing pressure testing is an actual online stress test using a real WeChat account on the targeted WeChat interface Weixin Mini Program.Here is a pre-conditional risk. Please know that WeChat API compression is online compression. Please pay attention to the WeChat API limit frequency. After compression exceeds the WeChat Interface limit frequency, there will be a situation where WeChat API request fails;

B. Business interface, according to whether the business interface domain name is the test environment domain name or the formal environment domain name, if the business interface domain name is filled in the online environment domain name, it is carried out online; In addition, please evaluate the business itself whether the backend resources are sufficient, and how much pressure measurement can be supported, in case the pressure measurement is too large to cause the backend service to collapse.

# 2. How can I tell if the Weixin Mini Program business request is from the pressure test task?

The HTTPS request for the pressure test, the header will be xwx-source: wx_gw_load_testing

# 3. The added business request does not work debugging and the prompt is not whitelisted?

At present, the service interface supported by the pressure measurement tool is to read the Mini Program Weixin Mini Program configured in the gateway access layer URL. The unconfigured ones do not support pressure measurement; You can go to the "access layer - target access domain name - modify" to choose to add the corresponding Mini Program URL. If you are worried that configuring the Mini Program URL will affect the online business, you can directly select the version configuration "do not access," which does not affect the online business at all.