Front-and-back business city sales and management system
Through the combination of RedisTemplate, Elasticsearch and RabbitMQ, data inconsistency and performance degradation caused by Redis downtime and high concurrent queries are solved, efficient data access and stability of the mall system are achieved, and user experience and system availability are ensured.
Patent Information
- Application Number
- CN202411211306.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-22
AI Technical Summary
In the case of Redis downtime or high concurrent query, existing mall systems may cause data inconsistency, cache breakdown or avalanche, affecting system performance and user experience.
RedisTemplate is used to directly operate Redis, combined with Elasticsearch advanced query module and RabbitMQ message processing, Redis performance optimization and high availability are achieved through cache failure strategy, active update mechanism, sentinel mode, automatic sharding, face-oriented programming technology and circuit breaker mode, and Improve data retrieval and message processing efficiency through Elasticsearch and RabbitMQ.
It improves the system's data access speed and response performance, ensures data consistency and high availability, avoids cache breakdown and avalanche problems, and ensures continuous operation of business logic and system stability.
Smart Images

Figure CN119003597A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database management, and in particular to a front-end and back-end shopping mall sales and management system. Background Art
[0002] For a mall system that supports real-time transactions and a large number of front-end and back-end query interactions, the user interaction volume is relatively high, and there are also requirements for data query efficiency. Under limited server resources and bandwidth, Redis may crash. Therefore, as a cache, what we hope is that if Redis crashes, our business logic will not be affected, because Redis crashes for an interactive system, which is extremely unfriendly to users. If Spring Cache is used to implement it, when Redis crashes, various operations that require Redis such as user login will not be possible. In addition, there is no problem with using MySQL to query data. Usually in production, front-end users perform a fuzzy query, and the back-end code uses a sql wildcard to query. When the amount of data is too large, the query efficiency will be seriously affected. For the Mall system, a large number of concurrent queries are also inevitable. The system uses an independent MySQL data server, and the maintenance and use costs must also be considered. Therefore, IKAnalyzer is integrated through Elasticsearch to implement Chinese keyword data query, and the CPU and database server load can be reduced as much as possible through a small amount of memory usage.
[0003] For user requests for product information and user requests for order information. First check whether the information of the required product exists in the Redis cache. If there is a cache in Redis, the product information is directly obtained from Redis and returned to the user. If there is no cache in Redis, query the MySQL database for product information and store the result in the Redis cache for use in the next query. First check whether the user's recent order information exists in the Redis cache. If there is a cache in Redis, the order information is directly obtained from Redis and returned to the user. If there is no cache in Redis, query the MySQL database for user order information and store the result in the Redis cache for use in the next query. In this way, a large number of product queries and order queries can be accelerated through the Redis cache, reducing the access pressure on the MySQL database and improving the response speed and performance of the system. At the same time, MySQL is still responsible for the persistence and consistency of stored data, ensuring the security and integrity of the data.
[0004] Although the combination of MySQL and Redis can improve query performance and response speed, you may need to consider the following issues:
[0005] Data consistency issues: Since Redis is an in-memory database, data is stored in memory and is not persistent. If a system failure occurs or the Redis cache is cleared, data inconsistency issues may occur, such as the product information cached in Redis being inconsistent with the actual data in MySQL.
[0006] Cache breakdown and avalanche: If a popular product or user's order is frequently queried, but the cache in Redis is invalid, a large number of query requests will be directly hit to the MySQL database, which may cause cache breakdown or cache avalanche problems, resulting in a sharp increase in database pressure and a decline in system performance.
[0007] Cache update delay: If product information or order information changes, the cached data in Redis will not be updated immediately after the data in MySQL is updated. This may cause the data obtained by the user to be not the latest, resulting in inaccurate or inconsistent information. Summary of the invention
[0008] In view of the above problems, the present invention is proposed to provide a front-end and back-end mall sales and management system that overcomes the above problems or at least partially solves the above problems.
[0009] According to one aspect of the present invention, a front-end and back-end mall sales and management system is provided, the management system comprising:
[0010] Database bottom-level optimization and permission management module, Redis performance optimization and high-availability strategy building module, Elasticsearch advanced query module, efficient message processing module, and exception handling and system stability enhancement module;
[0011] The optimization and authority management module at the bottom layer of the database is used to implement fine-grained management of authority;
[0012] The Redis performance optimization and high availability strategy building module uses RedisTemplate to directly operate Redis;
[0013] The advanced query module of Elasticsearch is used to find query data from big data;
[0014] The efficient message processing module is used to design RabbitMQ and system architecture;
[0015] The exception handling and system stability enhancement module is used to centrally handle cache operation exceptions in the system.
[0016] Optionally, the database bottom layer optimization and authority management module realizes fine-grained management of authority by optimizing the database bottom layer;
[0017] Allows the system to control user permissions more flexibly;
[0018] The optimized database design takes into account both performance and flexibility. Through technical means such as partitioning and index optimization, it ensures that even if the permission rules are increased, the system response time will not be significantly affected.
[0019] Optionally, the controlling of user rights specifically includes: dynamically adjusting rights according to time, location, and access frequency conditions.
[0020] Optionally, the Redis performance optimization and high availability strategy building module specifically includes:
[0021] When using Redis to cache user information and resource information, a cache invalidation strategy and active update mechanism are added;
[0022] Deployed in Redis cluster mode, using sentinel mode and automatic sharding to ensure high availability of services and data integrity;
[0023] Prevent and promptly address potential performance bottlenecks by continuously monitoring Redis.
[0024] Optionally, the advanced query module of Elasticsearch specifically includes:
[0025] As an efficient distributed search engine, Elasticsearch provides rich data retrieval capabilities through its advanced query functions.
[0026] Use function_score query to enhance the relevance ranking of documents;
[0027] Elasticsearch is also used for performance optimization.
[0028] Optionally, the Elasticsearch is also used for performance optimization, specifically including: improving retrieval performance and data processing speed by reasonably setting the number of index shards and replicas, optimizing data model design, and using a lightweight document structure method.
[0029] Optionally, the efficient message processing module is used to design RabbitMQ and the system architecture and specifically includes:
[0030] As an efficient message middleware, RabbitMQ plays an important role in the system. It decouples system components and ensures reliable message delivery through mechanisms such as message buffering, message confirmation, and callback processing. When designing a delayed message processing solution, the dead letter queue (DLX) and time wheel method are used to achieve reliable processing of delayed messages. In addition, RabbitMQ performance tuning is also very critical, including the reasonable configuration of queues and switches, and the selection of the best message confirmation mechanism for specific business scenarios.
[0031] Optionally, the message confirmation mechanism specifically includes: automatic confirmation or manual confirmation.
[0032] Optionally, the exception handling and system stability enhancement module specifically includes:
[0033] Centrally handle cache operation exceptions in the system through aspect-oriented programming technology;
[0034] The custom CacheException annotation provides fine-grained control capabilities for the system, allowing key business processes to be processed according to expected logic when external services are unavailable;
[0035] When building a high-availability system, circuit breaker mode, current limiting and degradation strategies are also introduced.
[0036] The present invention provides a front-end and back-end mall sales and management system, which includes: an optimization and authority management module of the database bottom layer, a Redis performance optimization and high-availability strategy construction module, an Elasticsearch advanced query module, an efficient message processing module, and an exception handling and system stability enhancement module; the optimization and authority management module of the database bottom layer is used to realize fine-grained management of authority; the Redis performance optimization and high-availability strategy construction module uses RedisTemplate to directly operate Redis; the Elasticsearch advanced query module is used to find query data from big data; the efficient message processing module is used to design RabbitMQ and system architecture; the exception handling and system stability enhancement module is used to centrally handle cache operation exceptions in the system. It solves specific business needs and also lays a solid foundation for the scalability of the system and future technical upgrades.
[0037] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0039] Figure 1 A flowchart of the database bottom-level optimization and authority management module provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0041] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.
[0042] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0043] When discussing this technical solution in depth, we must note that each technology implementation is not only to solve current needs, but also to maintain a certain degree of foresight in future technological evolution. The following is an expansion and more in-depth discussion of each key technical point.
[0044] 1. Database underlying optimization and permission management, such as Figure 1 As shown:
[0045] Generally speaking, the system's permission management module is the cornerstone of the entire system's security. In traditional designs, permissions are often bound to roles, which makes it difficult to meet complex and dynamically changing permission requirements. By optimizing the underlying database, we have achieved fine-grained management of permissions. This management method allows the system to control user permissions more flexibly, such as dynamically adjusting permissions based on time, location, access frequency and other conditions. These are functions that modern enterprises urgently need when facing complex businesses. The optimized database design takes into account both performance and flexibility, and ensures that even if the permission rules are increased, the system's response time will not be significantly affected through technical means such as partitioning and index optimization.
[0046] 2. Redis performance optimization and high availability strategy:
[0047] Redis' high performance and high availability play an important role in the business. By using RedisTemplate to directly operate Redis, the readability of the code is improved, and the atomicity and consistency of the operation are guaranteed. When using Redis to cache user information and resource information, cache invalidation strategies and active update mechanisms are added, which greatly reduces the pressure on the database. In order to improve the availability and fault tolerance of Redis, Redis cluster deployment can be adopted, and the high availability of services and data integrity can be guaranteed by using the sentinel mode (Sentinel) and automatic sharding. By continuously monitoring Redis, potential performance bottlenecks can be prevented and handled in a timely manner.
[0048] 3. Elasticsearch’s advanced query techniques:
[0049] In the era of big data, how to quickly and accurately find the required information from massive data is a challenge. As an efficient distributed search engine, Elasticsearch provides a very rich data retrieval capability with its advanced query functions (such as bool query, aggregate query, etc.). Using function_score query to enhance the relevance ranking of documents is an effective means. In addition, the performance optimization of Elasticsearch is also extremely critical. For example, by reasonably setting the number of index shards and replicas, optimizing the data model design, and using lightweight document structures, the retrieval performance and data processing speed can be further improved.
[0050] 4. Efficient message processing: RabbitMQ and system architecture design:
[0051] As an efficient message middleware, RabbitMQ plays an important role in the system. It can not only decouple system components, but also ensure the reliable delivery of messages through mechanisms such as message buffering, message confirmation, and callback processing. When designing a delayed message processing solution, the dead letter queue (DLX) and the time wheel method are used to achieve reliable processing of delayed messages. In addition, the performance tuning of RabbitMQ is also very critical, including the reasonable configuration of queues and switches, and the selection of the best message confirmation mechanism (automatic confirmation or manual confirmation) for specific business scenarios.
[0052] 5. Enhanced exception handling and system stability:
[0053] Through aspect-oriented programming (AOP) technology, cache operation exceptions in the system are centrally handled, which not only optimizes the maintainability of the code, but also improves the stability of the system. In particular, the custom CacheException annotation provides the system with more refined control capabilities, so that key business processes can be processed according to the expected logic when external services (such as Redis) are unavailable. When building a high-availability system, in addition to strengthening exception handling, circuit breaker mode, current limiting and degradation strategies are also introduced to further improve the robustness and reliability of the system.
[0054] In summary, this technical solution not only solves specific business needs through in-depth research and application in database design, caching strategy, search engine application, message processing and exception handling, but also lays a solid foundation for the scalability of the system and future technological upgrades.
[0055] Dynamic permission management and optimized menu display: In the front-end development, the present invention uses Vue Router and Vuex technology to achieve dynamic permission control and menu display. By splitting the routing table into static routes that must be displayed and dynamic routes that are displayed dynamically, the core GenerateRoutes method is used to generate routes that the current user has permission to access. This design ensures that each user can obtain a personalized interface experience that meets their specific permission requirements, fully reflecting the flexibility and meticulousness of permission control design.
[0056] Optimized cache operation exception handling: This innovation uses aspect-oriented programming (AOP) to handle cache operation exceptions, effectively avoiding business interruptions caused by cache problems, while ensuring the stability and reliability of the cache aspect management system. Through intelligent degradation processing, we can still ensure the continuous operation of the business when the Redis service is unavailable, improving the robustness and availability of the entire system.
[0057] Efficient data search solution: This innovation uses the derivative query of Elasticsearch Repositories to convert the method names of fixed rules into Elasticsearch's Query DSL statements, reducing the query load of the source server and improving data search efficiency. By customizing the mapping mechanism between domain objects and Elasticsearch documents, the convenience and efficiency of business queries are achieved.
[0058] Delayed message processing: RabbitMQ is used to implement delayed message processing. This design flexibly controls information transmission and processing time, and fully utilizes the advantages of asynchronous message services in terms of traffic peak reduction and system decoupling, thereby improving the system's processing capacity and response speed.
[0059] Optimized permission management function: By integrating Redis and AOP technology, the permission management function is optimized. Redis's high-performance caching characteristics and AOP's flexible processing mechanism provide an effective solution for large concurrency and high availability scenarios, significantly improving system performance.
[0060] First, by cleverly combining Redis with aspect-oriented programming (AOP) technology, we successfully built an efficient Redis cache aspect management system. The system not only significantly improves the speed and efficiency of data access, but also, in extreme cases where the Redis service is unavailable, the AOP surround notification mechanism can intelligently downgrade the processing to ensure the smooth operation of business logic and effectively prevent business interruptions caused by Redis downtime. This greatly enhances the stability and robustness of the system.
[0061] Secondly, in the application of Elasticsearch, the Spring Data Elasticsearch framework is adopted. This decision greatly simplifies the complexity of operating Elasticsearch and improves development efficiency. Through the warehouse concept of Spring Data, it is possible to avoid writing lengthy boilerplate code while enjoying the unified data access mode and query abstraction brought by Spring Data. In addition, the automatic mapping and metadata type specification mechanism between domain objects and Elasticsearch documents are customized, so that at the business logic level, developers can easily use SQL-like syntax for complex queries without having to worry about the query implementation details behind it, effectively improving development efficiency and system maintainability.
[0062] Finally, in order to further improve the user experience and business response speed, RabbitMQ was integrated as a message middleware, and it was used with Redis to implement an efficient and reliable full-process ordering engine. Through the delayed message feature of RabbitMQ, the message delivery and processing timing can be flexibly controlled to achieve advanced functions such as asynchronous processing and traffic peak shaving, while ensuring the reliable delivery of messages. It not only improves the response speed of the front-end user ordering process and the overall throughput of the system, but also enhances the scalability and maintainability of the system by decoupling the direct dependencies between services.
[0063] Beneficial effects: It effectively solves key issues such as how to optimize data access efficiency, ensure business continuity and improve system response speed under high concurrency and high availability requirements, and has strong practicality and broad application prospects.
[0064] The intelligent degradation processing of the Redis cache aspect management system is implemented through aspect-oriented programming (AOP) technology, which is designed to deal with problems such as Redis operation exceptions or connection failures to ensure high availability of the application.
[0065] It mainly includes defining a cache aspect to handle normal cache logic, and adding an exception capture mechanism on this basis. Once a Redis operation exception is detected, the system will automatically trigger the predefined downgrade processing logic, such as returning to the default value, directly querying data from the database, or recording exception information, to ensure the continuous operation of the business. At the same time, the entire downgrade mechanism is dynamically controlled by configuring switches to adapt to different operating environments and requirements. It not only improves the robustness of the system, but also ensures that the application can continue to serve in an elegant way when the Redis service is unavailable.
[0066] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A front-end and back-end mall sales and management system, characterized in that: The management system comprises: Database bottom-level optimization and permission management module, Redis performance optimization and high-availability strategy building module, Elasticsearch advanced query module, efficient message processing module, and exception handling and system stability enhancement module; The optimization and authority management module at the bottom layer of the database is used to implement fine-grained management of authority; The Redis performance optimization and high availability strategy building module uses RedisTemplate to directly operate Redis; The advanced query module of Elasticsearch is used to find query data from big data; The efficient message processing module is used to design RabbitMQ and system architecture; The exception handling and system stability enhancement module is used to centrally handle cache operation exceptions in the system.
2. A front-end and back-end mall sales and management system according to claim 1, characterized in that: The database bottom layer optimization and authority management module realizes fine-grained authority management by optimizing the database bottom layer; Allows the system to control user permissions more flexibly; The optimized database design takes into account both performance and flexibility. Through technical means such as partitioning and index optimization, it ensures that even if the permission rules are increased, the system response time will not be significantly affected.
3. A front-end and back-end mall sales and management system according to claim 2, characterized in that: The control of user rights specifically includes: dynamically adjusting rights according to time, location, and access frequency conditions.
4. A front-end and back-end mall sales and management system according to claim 1, characterized in that: The Redis performance optimization and high availability strategy building module specifically includes: When using Redis to cache user information and resource information, a cache invalidation strategy and active update mechanism are added; Deployed in Redis cluster mode, using sentinel mode and automatic sharding to ensure high availability of services and data integrity; Prevent and promptly address potential performance bottlenecks by continuously monitoring Redis.
5. A front-end and back-end mall sales and management system according to claim 1, characterized in that: The advanced query module of Elasticsearch specifically includes: As an efficient distributed search engine, Elasticsearch provides rich data retrieval capabilities through its advanced query functions. Use function_score query to enhance the relevance ranking of documents; Elasticsearch is also used for performance optimization.
6. A front-end and back-end mall sales and management system according to claim 5, characterized in that: The Elasticsearch is also used for performance optimization, specifically including: improving retrieval performance and data processing speed by reasonably setting the number of index shards and replicas, optimizing data model design, and using lightweight document structure methods.
7. A front-end and back-end mall sales and management system according to claim 1, characterized in that: The efficient message processing module is used to design RabbitMQ and system architecture and specifically includes: As an efficient message middleware, RabbitMQ plays an important role in the system. It decouples system components and ensures reliable message delivery through mechanisms such as message buffering, message confirmation, and callback processing. When designing a delayed message processing solution, the dead letter queue (DLX) and time wheel method are used to achieve reliable processing of delayed messages. In addition, RabbitMQ performance tuning is also very critical, including the reasonable configuration of queues and switches, and the selection of the best message confirmation mechanism for specific business scenarios.
8. A front-end and back-end mall sales and management system according to claim 7, characterized in that: The message confirmation mechanism specifically includes: automatic confirmation or manual confirmation.
9. A front-end and back-end mall sales and management system according to claim 1, characterized in that: The exception handling and system stability enhancement module specifically includes: Centrally handle cache operation exceptions in the system through aspect-oriented programming technology; The custom CacheException annotation provides fine-grained control capabilities for the system, allowing key business processes to be processed according to expected logic when external services are unavailable; When building a high-availability system, circuit breaker mode, current limiting and degradation strategies are also introduced.
