Abstract
When the number and scale of online users is large, there will be massive access request for the system caused by user operations. In this case, some bottlenecks are most likely to occur in computing resources, database performance and network transmission. Ajax technology, dynamic page static technology, and caching technology all have their own advantages and limitations in solving these problems. To fully make use of their advantages and avoid their limitations, it is necessary to integrate and improve these three key technologies. Thus, this design model based on the idea of integration and improvement has come into existence, which is a good solution to the high concurrency problem of web system at present.
Introduction
When there is large scale of users online simultaneously, their online operations will lead to a huge quantity of access requests for the system, so the system needs to handle massive requests at the same time, which may bring various problems. This is the high-concurrency problem in web system [1]. Under high concurrency, the system is required to simultaneously process a variety of access requests and operate massive business logic, which usually results in all kinds of performance problems, and all the computing resources, database and network of the whole web system may reach its limit [2]. Figure 1 well illustrates the three easily occurring performance bottlenecks in computing resource, database performance and network transmission under high concurrency.
Typical processing of access request to web system.
Design thinking of integrated improved model
Traditional ajax technology, dynamic page static technology and caching technology are all important methods to improve the performance of web system [3]. However, the three technologies have advantages and disadvantages. For example, ajax technology can reduce redundancy in the transmission between the server side and the client side, and decrease resource demands through rational reuse of operation resource of application server, but it’s not effective in aspects of network transmission of database server and database performance [4]. In comparison, with static technology and caching technology, the network transmission quantity of database server and performance pressure of database can be well decreased, though it had no effect on the network transmission between the server side and the client side [5].
That is to say, ajax technology, dynamic page static technology and caching technology all have advantages and limitations. At the same time they play their advantages, conflicts may exist [6]. On the basis of our deep-going study on the advantages and limitations of the three key technologies, we integrated and improved them, trying to avoid their disadvantages while fully utilizing their advantages. In our study, we lay particular focuses on the problems of the conflict between ajax technology and dynamic page static technology, spacial limitations of static technology, frequent page invalidation of dynamic page static technology, caching invalidation risk and hit rate of caching technology, and combination of static technology and caching technology [7]. And optimized integrated improved model of ajax technology, static technology and caching technology as well as the processing model of high-concurrence access requests to web system are designed, as Fig. 2 shows.
Processing model of high-concurrence web system access requests.
The processing steps of access requests from client side are as follows:
Client send access request to the server side. Server side analyzes the URL of access request. If it is page access request, send static page code back to client side. If it is ajax asynchronous access request, invoke the ajax request processing port of server side (AjaxController). The port carry out relative logic and return the responsive result to client side in format of json, XML and others.
The executing steps of AjaxController are as follows:
Check whether there is usable static responsive result. If yes, send directly the responsive content to the client side. If no, carry out business logic, database access, etc., finally generate responsive results in format of json, XML and other formats and send them to client side.
Progress of reading static result is as follow:
If static result exists in memory cache, use it directly. Otherwise load it in hard disk storage.
Realized the integration of Ajax technology and static technology
As mentioned before in this paper, Ajax technology and traditional dynamic page static technology are incompatible for each other to some degree. However, the model proposed in this paper is compatible for the two technologies and combined the advantages of them.
Realized the integration of static technology and caching technology
Both caching technology and static technology can cut down the resource consumption for execution of business logic and reduce the access pressure of database. The integrated and improves model in this paper properly integrated the two technologies and thus avoid repetition and redundancy [8].
More reasonable settings for caching location and granularity, which brings better effects
In this model, caching is located in the presentation layer, and AjaxController is used as controller interface. That means the interface which processes ajax asynchronous access requests sets cache for nodes. The granularity of caching data establishment and invalidation is ID level, or in other words record level. The invalidation of some record won’t affect the validity of other data cache. In addition, the position of cache in presentation layer is closer to client side, which can reduce the repetition of execution of service-side logic code. Therefore, the settings for caching location and granularity in this model is more reasonable and has better effects [9].
Fastened the processing of access requests
On the basis of this model, system no longer needs server side to carry out relevant business logic or invoke database to process access requests from many users. Instead, it returns the temporarily stored static contents to client side. What’s more, the memory caching mechanism has been built, so the access request will be sped up to a great degree.
Reduced the computing pressure of web application server
With ajax technology in this model, the server side no longer needs to execute to much computation to generate html pages, instead, it only needs to send the existing static html pages to client side, which reduces the computing pressure of server side to some degree.
In the model, the data result of ajax asynchronous requests has realized static caching, so the server side does not need to execute business logic repeatedly any more when processing the access requests from client side, on the contrary, it can invoke to the static results in cache to send to client side. Hence, the computing pressure in service-side execution of business logic has been greatly reduced and enormous computing resource of server side can be saved especially under high concurrence.
Reduced the pressure of database
On the basis of this model, system no longer needs server side to execute relevant business logic or invoke database to process access requests from users, but search it from static cache, which thus greatly reduced the accessing pressure of database.
Reduced the pressure of network communication between client side and server side
With ajax technology in this model, there is no need to reload the whole page for page visiting and refreshing, but only the dynamically changing part, thus the redundancy of page content sent from server side to client side is decreased enormously. It’s undoubted that the slash in the amount of data transmission between client side and server side can greatly reduce the pressure of network communication.
Architecture design and key realization of integrated improved model
Overall architecture design of integrated improved model
Technology architecture of high concurrent web system.
As Fig. 3 shows above, the system employs B/S structure in its design, with which users visit web system through client side which runs in browser, and the server side is arranged in application server (Tomcat). The database system is arranged in a independent server and is visited by server side through network IO.
Technologies such as html, css, JS, Jquery, bootstrap and Ajax are adopted in the server side. All the pages of the system, in principle, are static pages, and the part of dynamic data should be asynchronously loaded through ajax codes.
The server side, based on j2ee technical system, adopts the three-layer architecture including representation layer, business logic layer and data access layer.
Mybatis persistent framework is adopted in the data access layer to enable data accessing. The data access interface is realized by the Dao type built in Mybatis framework. The framework also integrates spring affair handling mechanism to ensure the consistency and integrality of data.
Business logic layer is built in springIOC control inversion container, and business logic codes are realized by a number of Service types. The presentation layer can realize business logic by invoking Service type and other interfaces by means of dependency injection [10].
Presentation layer adopts mvc framework which is realized on basis of springmvc. The processing of client-side access requests is realized by a number of Controller types which has two main types: one is page Controller, used to analyze URL and localize static page. This kind of Controller can match page request from client side with corresponding html view; another is AjaxController, used to process ajax asynchronous access requests sent from client-side page. This Controller can process client-side requests and return the json and XML types of view needed by ajax recall function to client side. The presentation layer also realized caching mechanism and static mechanism. Static mechanism is extended and implemented in springmvc framework. Usable static results will be checked before every AjaxController executes business logic. If static result exists, skip business logic and return to result directly. The content storage of static result is realized by Oscache caching frame which stores content into internal storage. If the storage surpasses limitation of capacity, use LRU algorithm (least recently used algorithm) to make the least recently used contents persistent in hard disk storage [11].
This paper will not expatiate on the whole designing and realizing progress of the overall architecture of web system, but emphasize the design and realization of key parts related to this paper.
Diagram of key link of high-concurrency web system architecture.
As it shows above in the red parts of Fig. 4, this paper mainly represents the design and realization of Ajax mode, static mechanism and graded cache mechanism.
3.2.1.1. Design
All the functional pages of the system adopt static realization, namely they all use html pages embedded with Ajax script code for realization. When users visit the system, static page is loaded first, and the contents which needs to present dynamic data on the static page will be asynchronously loaded through Ajax script code. If the contents visited by users are reusable, the client side will not resend page request, instead, it asynchronously refreshes the content region through Ajax.
For example, is a user visits the information presenting page, client side will load static information to present page code for the first, excluding any information data. After the page finishes loading, a number of Ajax codes of the page runs to send request of loading information titles, information contents, amount of visits and other data to server side. After receiving the responsive result from server side, callback function renders the part of dynamic data. Then the information titles, information contents amount of visits and other data can be presented at the client side. If the user wants to check another piece of information, the client side won not sent the access request of information presenting page to the server side, but reload the data of new information through Ajax asynchronous interface [12].
3.2.1.2. Realization sample
Realization of codes for Ajax asynchronous loading of information title
Design and realization of static mechanism
The system designed and realized the AjaxResultContainer type to realize static mechanism. When certain AjaxController needs data of static result, the AjacResultContainer type needs to be invoked. A storage pool to store static contents is realized inside the AjaxResultContainer type. The storage pool has two poles: internal storage pole and hard disk pole.
The steps of AjaxController’s processing of access requests are as follows:
Client side sent access request to server side. Server side analyzes URL and calls relevant AjaxController type.
AjaxController type calls the isValid() interface of AjaxResultContainer. If it returns true, then the static contents are usable; if it returns false, then the static contents do not exist.
If the static contents are usable, AjaxController type calls the getReault() interface of AjaxResultContainer. This interface returns the data flow in json format, and AjaxController returns data flow to client side.
If static contents are not usable, AjaxController executes normal business logic, visit database to read data and finally generate static data flow in json format as responsive result, which will be returned to client side. Meanwhile, AjaxController type needs to call the pushResult() interface of AjaxResultContainer type, and store the static result into storage pool of static contents, in order for the AjaxController’s future processing of access requests from client side.
Certainly, we also need to design and realize the invalid mechanism of static contents. When users send access request to server side to revise data, relevant AjaxController type will call the invalid() interface of AjaxRaultController. The interface can eliminate specified static contents and change it into downstate.
Design and realization of graded cache
The storage pool for static contents is realized inside AjaxResultContainer type. The storage pool is actually a cache which is realized by StringCache type. StringCache type stores data into memory in prior. If the memory size surpasses the setup of StringCache, then the data is persisted and stored into hard disk.
StringChache designed and realized following main functional interfaces:
setAlgorithm() Set graded elimination algorithm of cache, namely the algorithm of how to eliminate data when the data capacity of internal storage reaches to the set upper limit. getAlgorithm() Get the graded elimination algorithm of cache which is in use at present. setMemMaxSize() Set the maximum capacity parameter of content cache. getMemMaxSize() Get the maximum capacity parameter of internal storage cache. getMemSize() Get the capacity occupied by present internal storage cache. getSize() Get the capacity occupied by total present cache. countData() Get the record count of present cache. addStringData() Add a cache datum. delStringData() Delete a cache datum. getStringData() Get a cache datum. clearMem() Clear all internal storage cache. All the cache data still exist in hard disk, and will be rebuilt in internal storage gradually. clearAll() Cleat all of the cache. All the cache data, including the data in hard disk, are cleared.
Based on the aforementioned architecture design and improved model, we carried out simulation test on the rebuilt technology especially aiming at its performance in solving high concurrence in web system. Through our statics in the test we find that the system’s user experience and responsive speed have been improved. And its most frequent operations are: single message checking, information-annotation-related operation, and multi-condition conjunctive information query. Among them the amount of requests related to single message checking accounts for 45% of total access requests from client side, and that related to information-annotation-related operation takes 18% of the total, while the amount of requests of multi-condition conjunctive information query holds 13% of total system requests. These operation types are most used and relied by users in their daily work.
Next let’s have a look at the performance of the new-architecture-based web system in processing these operations.
In the system, apart from unchecked information, the content data of most information will not be changed any more, so the static content cache of most information rarely becomes invalid. When a single message is checked, the loading of most data does not need to visit database again nor carry out the business logic code apart from a minority of data such as information click rate. Instead, it searches generated static contents in graded cache and return them directly to client side, which greatly improves the speed of response to requests of this type of users. What’s more, in that the requests of this type of users account for 45% of total access requests from client side, the pressure of system computation and database access are decreased remarkably.
In the operation of information annotation, frequency of write operation is not very high, accounting for around 5%, while the operation of checking annotation, in other words, reading data, takes about 95%. Most of the time, static contents can be found in cache for the requests for the loading of annotation data. The cache goes invalid only when the annotation of a certain piece of information has changed occasionally. What’s more, the Controller interface based on and related to annotation builds cache with the granularity of the data of a single annotation, thus the change of a certain information annotation won’t make the static content cache of other annotations lose efficacy. Therefore, the performance of access requests related to information annotation in the system has been improved enormously, and a similar way, the pressure of system computation and data base access has been reduced to a great degree.
The operation of multi-condition conjunctive information query is also a frequent operation in system which can not be ignored. In this operation, the query result depends on the conjunctive status of multiple conditions, and the change of any piece of information can affect the result data of this kind of queries. As a result, when there are multiple query conditions or the query contents include new and under-review information, it’s difficult for the static cache of request result contents and the cache validity won’t be high. Thus, in the new architecture, there is no great development in the speed of response to the access requests of multi-condition conjunctive queries. However, there is a noteworthy decrease in the pressure of access to database system in the new architecture, and the database resources for SQL requests that can be used to process conjunctive query information are more abundant. Therefore, the speed of the response to the access requests of this kind of users has improved to some degree indeed.
The test proves that the system, based on a new architecture, has an average speed of response to users’ access requests improved by 275%, which is quite remarkable. Meanwhile the average memory footprint rate of database system and average CPU utilization rate has dropped from 63% and 47% to 33% and 11% respectively. In addition, the average daily amount of data transmission between web system and the client side reduced by approximately 22%, and the amount of data transmission between web application server and database server declined by 59%.
Conclusion
To sum up, the rebuilt sample system based on the improvement of integrated three technologies aforementioned in this paper has great promotion in its performance. In addition, the system with new architecture has notable improvements in the key links of the problems easily causing bottlenecks of system performance, including network transmission, computation resources, database performance and so on. That is to say, the system’s user experience and its response speed to users’ operation have been greatly improved. Therefore, for the establishment of web system with similar characteristics discussed in this paper, the integrated improved high-performance architecture for high-concurrence web system is applicable and effective.
Footnotes
Acknowledgments
This work is supported by the 2016 Special Project on the Integration of Industry, Education and Research of Science and Technology Program of Guangzhou, China (201604010103), and 2018 Science and Technology Program of Guangzhou, China (2018-1002-SF-0050).
