1. Project background

This APP is an NFC-based secure payment product for users. This APP combines the principles of cryptography, computer technology, NFC communication technology and digital currency ideas organically, which maximizes the consumer's payment experience while fully guaranteeing security. Compared with traditional solutions, this work has the following features: 1) Realize currency digitization; 2) Merchant and user two-way identity authentication; 3) Security guarantee for the transaction process; 4) Complete mobile payment system; 5) Offline payment, disconnected from the network; 6) Account loss can be retrieved; 7) Error negotiation to protect the interests of both parties in the transaction; 8) Label mall, which maximizes convenience; 9) Low cost and easy to promote.
The user is a customer who needs to use this product for consumption and needs to install the user wallet client. The main function structure diagram is as follows:

A merchant is a provider of goods or services and needs to install a merchant client. The main function structure diagram is as follows:

2. Challenges encountered

Users of this APP reported that there were problems such as freezing during the use of the APP. For mobile apps, the importance of fluency is self-evident. In order to improve fluency, Google has made a lot of optimizations to the Android system, including the use of GPU hardware acceleration, the introduction of VSync, and the replacement of Dalvik with Art. So for our APP, the stuttering problem will inevitably affect the user experience, so the problem of APP stuttering must be analyzed and resolved.

Third, the steps to solve the problem

First, we conducted several rounds of code reviews to try to optimize the code structure from a logical level to reduce the occurrence of lag problems. The optimization in this area is mainly to find out the time-consuming functions in the main thread, optimize the logic to reduce the time-consuming API, analyze the work of the CPU, and try to let the CPU perform the work in the main thread. There are a lot of work in this area, such as optimizing logic to reduce API time-consuming, caching data to facilitate faster loading of data, and moving time-consuming operations out of the main thread and operating in sub-threads.

Second, optimize the database table structure, put some commonly used data in the cache, and update it to the database asynchronously. All database operations can be unified into a thread queue.

Finally, the monitoring system needs to be improved. Because although the product will inevitably go through rigorous testing work before it goes online, it is also due to the fixed mode and the existence of test blind spots. For example, for larger-scale APP products, testers are basically unable to cover all mobile phone models. And ROM, so many problems must still depend on the feedback of users after the real launch. In this case, a complete quality monitoring program is very necessary, so it is necessary to establish a solid monitoring system. In this way, APP quality problems for online products can be recalled as soon as possible and quickly repaired. As for how to improve the monitoring system, at present, there are two choices. One is based on the open source Skywalking, Cat, Zipkin, Pinpoint and other APM systems. Taking Skywalking as an example, it is based on distributed tracking. Application performance monitoring system. The core of SkyWalking is a storage platform for data analysis and measurement results. It submits analysis and measurement data to SkyWalking Collector through HTTP or gRPC. SkyWalking Collecter analyzes and aggregates the data and stores it in Elasticsearch, H2, MySQL, TiDB, etc. , And finally we can view the final result through the visual interface of SkyWalking UI. Skywalking supports collecting data from multiple sources and multiple formats: Skywalking Agent in multiple languages, Zipkin v1/v2, Istio survey, Envoy metrics and other data formats. The overall architecture seems to have a lot of modules, but in fact it is relatively clear, mainly by collecting data in various formats for storage and then displaying. So we need to pay attention to SkyWalking Collecter, SkyWalking UI and storage devices to build the Skywalking service. The official download and installation packages of SkyWalking Collecter and SkyWalking UI are included. In the end, we only need to consider storage devices. But using this system will face problems such as unfamiliar engineers and tight schedules. The second option is to use a mature APM system. It goes without saying that there will be greater short-term funding pressure, but in view of the urgency of our project, we choose to use U-Meng + application performance monitoring platform U-APM. U-meng+'s U-APM application performance monitoring platform is based on powerful capture and collection capabilities to quickly locate the root cause of errors, provide user-dimensional crash statistics, quickly restore the crash scene, and set up multiple warning channels to help developers monitor applications 7*24 Condition. Very suitable for our APP.

Four, project summary

Transaction security is the top priority of the current Internet + payment storage application design. In order to realize the safety and speed of the transaction process, our APP designed the following transaction process to enhance security while using the NFC function for short-distance secure transmission. This APP has the advantages of digitalization, mobility and high efficiency. However, during the running of the APP, there was a lag problem, which affected the user experience. So we solved and optimized this problem by modifying the code logic and database table structure, and at the same time improving the monitoring system.

Author: Chen Jingru


性能优化实践者
11 声望220 粉丝