CN1277196C - Method for applied server of computer system - Google Patents

Method for applied server of computer system Download PDF

Info

Publication number
CN1277196C
CN1277196C CN 200410046278 CN200410046278A CN1277196C CN 1277196 C CN1277196 C CN 1277196C CN 200410046278 CN200410046278 CN 200410046278 CN 200410046278 A CN200410046278 A CN 200410046278A CN 1277196 C CN1277196 C CN 1277196C
Authority
CN
China
Prior art keywords
thread
computer system
pool
receiving
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN 200410046278
Other languages
Chinese (zh)
Other versions
CN1584842A (en
Inventor
张长丰
强宇红
郑扬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CN 200410046278 priority Critical patent/CN1277196C/en
Publication of CN1584842A publication Critical patent/CN1584842A/en
Application granted granted Critical
Publication of CN1277196C publication Critical patent/CN1277196C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The present invention provides a method for realizing application servers in computer systems in the field of computers. A thread pool of a computer system is constructed by combining an asynchronous I/O technique and a computer system thread pool technique in a JAVA platform of the computer system, and a thread in an application server is divided into a link management thread, a receiving thread and a service thread; each service logic processing process is divided into a plurality of service sections, and each section is composed of 'receiving', 'processing' and 'transmission'; other threads all carry out application in the thread pool of the computer system besides a master thread which needs to exist for a long time and a timer thread, every time data is received for one time, or one service section is processed, the thread is returned to the thread pool of the computer system, and the link or the service logic processing process is stored in a memory through a data area recorded with a state value. The present invention can fully utilize the advantages of various I/O modes, practicability and the maintenance of codes are improved based on that the occupancy rate of CUPs is improved maximally, and the complexity of systems is lowered.

Description

A kind of method that realizes the computer system application server
Technical field
The present invention relates to computer realm, relate in particular to a kind of method that realizes the computer system application server.
Background technology
Computing machine has become indispensable instrument in production and the sphere of life day by day, also in the deep live and work method that is changing people.In computer application field, the application server technology along with people for the demand of network system and develop rapidly, generally speaking, application server has powerful client requests processing power, and server is handled a large amount of client requests within the reasonable time ability depends on that server uses the efficient of I/O (I/O) stream.For providing the server of service, hundreds and thousands of client computer must use the I/O service concomitantly simultaneously, development along with computer system Java platform, in Java language development kit JDK1.4, begin the function of supporting that asynchronous (being unblock) I/O calls, thereby made application server that the possibility of bigger processing power arranged.
Use the application server of Java platform at present, owing to adopt (obstruction) I/O mechanism synchronously more at large, the ratio of its thread and client computer almost is one to one relation, thereby be easy to be subjected to the influence of a large amount of thread expenses, add many threads in a treatment scheme consuming time probably the most of the time all be in suspended state, consequently not only caused performance issue but also lack scalability.In order to address this problem, the Java platform has been supported asynchronous I/O in its recent development, comprise new passage (Channel) class and selector switch (Selector) class, passage is a kind of communication mode between the client-server, and selector switch is then caught variety of event and they are assigned to the events corresponding handling implement from different client computer.
Multithreading mainly solves the problem of a plurality of thread execution in the processor unit, it is not only balanced the wait-for-response time of client computer, simplified the logical process flow process, and can significantly reduce standby time of processor unit, increase the handling capacity of processor unit, and be fit to very much the upgrading of server to many CPU.If but, can increase processing time to individual task to the multithreading misapplication.For example, be T=T1+T2+T3 in the time that a station server accomplishes a task, wherein T1 is the time of creating thread, and T2 is the time (comprising the synchronous required time of cross-thread) of executing the task in thread, and T3 is the time that thread is destroyed.As can be seen, T1, T3 are the expenses that multithreading self brings, and create continually in program or the destruction thread, will cause T1 and T3 to occupy quite a lot of ratio in T, and this obviously is the weakness (T1, T3) of having given prominence to thread more, rather than the advantage of its concurrency.
Produced computer system thread pool technology just under this background, computer system thread pool technology is conceived to how to shorten or adjusts T1, T3 time, thereby improves the server program performance.It is arranged in the startup of server program and concluding time section or time period that some are idle to T1, T3 respectively, when server program is handled client requests, will the expense of T1, T3 can not take place like this, and it can also significantly reduce the number of threads of establishment simultaneously.
As can be seen, when need be in flow process of individual task at the first-class pending data of a plurality of sockets (SOCKET) interface (such as connect the sockets interface that 4 tuples constitute by a TCP), for the quantity that reduces concurrent thread, the utilization factor that improves CPU, adopt the asynchronous I/O pattern to realize usually by single-threaded.When the individual task logic is simple, but when wherein comprising time-consuming operation, it is an optimal selection that synchronous i/o adds the computer system thread pool.
Yet, when a big traffic server externally has a plurality of interfaces, if and handled each task all is divided into many sections by the I/O operation, comprise time-consuming operation (resolving encapsulation etc.) in each section again such as encryption and decryption, database manipulation, XML, after all sections are all finished in proper order, just give client from the porch return results.If still adopt synchronous i/o to add the computer system thread pool in this case, will certainly hang up a lot of threads at interface, can not be returned in the pond, thereby cause the shortcoming of inefficiency; If only adopt asynchronous I/O, then can't solve the queuing problem that mainly causes again by time-consuming operation.General solution is at present, and bottom adopts the asynchronous I/O mode, then opens the worker thread or the process of some and handle in the time-consuming operation section.To improve to some extent to system performance largely like this, but still there are problems: at first, the number of thread is an empirical value, best value is to be difficult for obtaining under different environment, if especially in a plurality of sections, use thread, coordination between these number of threads more difficult (being poor practicability), and the modes of configuration files of using are revised more when realizing, may need to restart system after the modification; Secondly, reading and writing data from bottom, also is system's copy function of a consumption CPU consuming time who can not be ignored when big flow, and if be placed in the thread (especially for many CPU system), the performance of elevator system significantly then; At last, not only to consider distinct interface during system design, also need a section business flow process is segmented from " consuming time ", " not consuming time " these two angles, thereby make the level of system and code complexity, maintainability and secondary development all relatively poor.
Summary of the invention
The objective of the invention is to overcome that prior art exists can't realize that CPU usage, code can degree of maintenance and the shortcoming of effective combination of practicality (as whether needing to obtain empirical value etc.), in the hope of proposing a kind of strong point that can make full use of various I/O patterns, on the basis of at utmost improving CPU usage, strengthen safeguarding of practicality and code, reduce the method for system complexity.
Core concept of the present invention is: by being used in combination asynchronous I/O and the computer system thread pool technology in the computer system JAVA platform, construct a kind of application server realizing method, thread is divided into three kinds of link management thread, receiving thread and professional threads, and the thread resources of wherein back two kinds of uses is all from the computer system thread pool; Task is operating as boundary with I/O is divided into a plurality of sections, each section is all moved in above-mentioned thread; Simultaneously when handling simple disposable transmission task, adopt the mode of synchronous i/o again.
The method that realizes application server in the computer system that is implemented in of the present invention is characterized in that, may further comprise the steps:
(1) structure computer system thread pool is provided with the wait strategy after the maximum and minimum Thread Count of computer system thread pool and Thread Count reach maximal value, and the concrete Thread Count that at a time needs to use is regulated automatically by the computer system thread pool;
Described wait strategy is included in the invokes thread and carries out immediately, abandons, invokes thread is hung up and to be occurred carrying out after the idle thread in thread pool etc. again.
(2) thread in the application server is divided into link management thread, receiving thread and professional thread;
(a) the link management thread receives external connection request by safeguarding an asynchronous I/O major cycle; When the link management thread receives the incident that the data arrival is arranged on certain link, from the computer system thread pool, access an idle thread, by Runnable (the thread base class of the java) example that passes to this thread, make this idle thread enter duty, on this link, receive processing, thereby change receiving thread into;
(b) receiving thread is responsible for from transport layer (SOCKET interface) reading of data, and transport layer data cut apart or recombinates, and transport layer data converts the message (as the HTTP message) of application layer to the most at last; After collecting one or more complete application layer message, receiving thread transfers one or more idle thread to carry out business processing from the computer system thread pool, and receiving thread self is returned in the computer system thread pool;
(c) professional thread is responsible for handling a traffic segment, comprises concrete business logic processing, and sends data etc. from the SOCKET interface.
SOCKET interface at a time can only corresponding maximum 1 receiving thread, or does not have correspondence to accept thread (when not receiving data on the interface).Each professional thread is responsible for handling a traffic segment.
(3) each business logic processing flow process is divided into a plurality of traffic segment, every section all by " reception "---" processing "---, and " transmission " formed;
" reception " carried out in receiving thread, and " processing " and " transmission " then finished in professional thread, do not need to consider in the section whether module consuming time is arranged; A described business logic processing flow process is equal to a task, comprises processing such as parsing, authentication, note, location, charging, alarm such as a location logic flow;
(4) except that long-standing master control thread of needs and timer thread, other all threads (as receiving thread and professional thread) are all applied in the computer system thread pool, whenever receive a secondary data (receiving thread) or whenever handle a traffic segment (professional thread), this thread is returned in the computer system thread pool, and this link or business logic processing flow process are kept in the internal memory by a data field (comprising the current state information as TCP link or business logic processing) that records state value;
When (5) handling simple transmission task (connect, once mutual then close immediately), adopt the mode of synchronous i/o as HTTP is short.
The method of the invention is by being used in combination asynchronous I/O and the computer system thread pool technology in the computer system JAVA platform, compared with prior art, in application server, neither can on each SOCKET interface, there be the thread of hanging up, also do not need module consuming time in each flow process is made special consideration; Because the computer system thread pool can reach self-regulating effect, do not need to dispose the number of each module thread simultaneously rigidly; Carry out owing to comprising that the I/O operation all is placed in the multithreading,, provide maximum performance room for promotion for the upgrading of system to many CPU.
Description of drawings
Fig. 1 is a JAVA platform application server overall architecture synoptic diagram.
Fig. 2 is that each thread concerns synoptic diagram in the server.
Fig. 3 is the method for the invention process flow diagram.
Fig. 4 is as task section, link, state relation figure in the complete task of the embodiment of the invention.
Fig. 5 resolves the invoked procedure synoptic diagram as the receiving thread of the embodiment of the invention.
Embodiment
Below in conjunction with accompanying drawing, illustrate at an embodiment that designs big flow application server in conjunction with asynchronous I/O and computer system thread pool.
The integral frame of system as shown in Figure 1, the asynchronous I/O module among the figure takies the link management thread, mainly carries out the SOCKET interface and creates, monitors and open operation such as receiving thread; The computer system thread pool is mainly safeguarded the conversion work between an idle thread and reception, the professional thread, and can dynamically adjust Thread Count in the computer system thread pool according to the busy extent of system; When handling simple transmission task (connect, once mutual then close immediately), also adopted the mode of synchronous i/o among the figure as HTTP is short.
Relation in the server between the various threads is to transform mutually between idle thread in the computer system thread pool and receiving thread, the professional thread as shown in Figure 2.Link management, timer background thread then take fixing thread resources.
Concrete embodiment at first needs to carry out initialization preliminary work, mainly finishes three tasks:
1) creates a computer system thread pool, configure the wait strategy after the maximum and minimum Thread Count of computer system thread pool and Thread Count reach maximal value.
2) interface of link management thread of design and receiving thread designs the interface of a receiving thread and business processing thread, and two interfaces are all inherited the Runnable interface of JAVA.Receiving thread is mainly realized the assembling of data read, decoding and business data packet.
3) with each operation flow basis " reception ", " processing ", " transmission ", be divided into different sections, as shown in Figure 3, a logical process flow process among the figure is divided into 3 active sections, and the user mode machine is state value of every section distribution.Fig. 4 be for illustrate traffic segment in the complete service logic flow process, link, state, and thread between the synoptic diagram of graph of a relation, the service logic flow process is from link 1 request of receiving, up to from link 1 return results end of message (EOM).The different business flow process is used different internal memory business datums district, and the data field index is decided by professional.
Receiving thread withdraws from after calling one or more professional thread immediately.Be about to thread and be returned in the computer system thread pool, the application protocol information of link information and low layer is kept in the link data district in the internal memory.If a read operation parses a plurality of business data packet, promptly enable a plurality of professional thread process (as Fig. 5) from the computer system thread pool; If do not read a full business data packet, in the link data district, preserve this segment data, return this thread, wait for next read operation.
When receiving a packet, cause following incident:
1) the link management thread is handled respectively according to the difference of event number: treatment step is as follows:
A) if insert the link setup request, then accept this request, and be that newly-built sockets interface (abbreviation link) distributes a link data district.
B) if the packet on the link then takes out an idle thread as receiving thread from the computer system thread pool, and the operation of reading therein, resolve, recombinate.The link management thread then enters in the new circulation.In order to simplify flow process, also can raise the efficiency simultaneously, in the link management thread, also need to do following control: can only take a receiving thread on arbitrary link of arbitrary moment.
C) if read one or more complete application protocol bag, after starting one or more professional thread, this receiving thread is returned in the pond.
D) if not a complete application protocol bag, receiving thread does not start professional thread, and after the Load Game state was saved in the link data district, this receiving thread was returned in the pond.
2) the business processing thread is according to the state of current flow process, carries out this section business and handles, no matter whether time-consuming operation is wherein arranged, because be in thread independently, so do not need to do any consideration.After this section was finished dealing with, professional thread need be carried out following a few step:
A) business processing adds port numbers according to the IP address of the destination that will send and finds (or newly-built one a) link and finish (promptly guaranteeing to send success fully) in this thread, and transmit operation if send unsuccessfully, need be attempted retransmit operation in this thread.
B) preserve the new state of flow process to the data field, give back this thread in the pond.
Often may run on the link operation that only once sends, do not need wait-for-response when 3) sending, at this moment adopt synchronous i/o can reach very big simplification effect.
Neither can there be the thread of hanging up in the method for the invention on each SOCKET interface, also do not need module consuming time in each flow process is made special consideration; Because the computer system thread pool can reach self-regulating effect, do not need to dispose the number of each module thread simultaneously rigidly; Carry out owing to comprising that the I/O operation all is placed in the multithreading,, provide maximum performance room for promotion for the upgrading of system to many CPU.
Above-described embodiment is the realizing property description of the inventive method on the java platform, and the server framework thought that the inventive method proposed then is not limited only to the java platform.Under the situation that does not break away from the spirit and scope of the invention, all variations and modification are all within the scope of the present invention.

Claims (7)

1, a kind of method that realizes application server in computer system is characterized in that, may further comprise the steps:
(1) structure computer system thread pool is provided with the wait strategy after the maximum and minimum Thread Count of computer system thread pool and Thread Count reach maximal value, and the concrete Thread Count that at a time needs to use is regulated automatically by the computer system thread pool;
(2) thread in the application server is divided into link management thread, receiving thread and professional thread;
(3) each business logic processing flow process is divided into a plurality of traffic segment, all forms for every section by " reception ", " processing ", " transmission ";
(4) setting takies fixedly the master control thread and the timer thread of thread resources; Not taking fixedly the thread of thread resources applies for obtaining from the computer system thread pool, whenever receive a secondary data or whenever handling a traffic segment, this thread is returned in the thread pool of computer system, and thread-data is kept in the internal memory by a data field that records state value;
When (5) computer system processor adopts the transmission task of the short connection of HTTP, adopt the mode of synchronous i/o.
2, the method that in computer system, realizes application server as claimed in claim 1, it is characterized in that the strategy of wait described in the step (1) is included in the invokes thread and carries out immediately, abandons, invokes thread is hung up and occurred carrying out after the idle thread again in thread pool.
3, the method that realizes application server in computer system as claimed in claim 1 is characterized in that three threads specifically comprise described in the step (2):
(a) the link management thread receives external connection request by safeguarding an asynchronous I/O major cycle; When the link management thread receives the incident that the data arrival is arranged on certain link, from the computer system thread pool, access an idle thread, a succession by passing to this idle thread is from the class example of Runnable class, make idle thread enter duty, on this link, receive processing, thereby change receiving thread into;
(b) receiving thread is responsible for from transport layer SOCKET interface reading of data, and transport layer data cut apart or recombinates, and transport layer data converts the message of application layer to the most at last; After collecting one or more complete application layer message, receiving thread transfers one or more idle thread to carry out business processing from the computer system thread pool, and receiving thread self is returned in the thread pool;
(c) professional thread is responsible for handling a traffic segment, comprises concrete business logic processing, and sends data from the SOCKET interface.
4, the method that realizes application server in computer system as claimed in claim 3 is characterized in that, SOCKET interface at a time can only corresponding maximum 1 receiving thread, when not receiving data on interface, does not then have corresponding receiving thread.
5, the method that realizes application server in the computer system that is implemented in as claimed in claim 3 is characterized in that each professional thread is responsible for handling a traffic segment.
6, the method that realizes application server in computer system as claimed in claim 3 is characterized in that the application layer message is the HTTP message described in the step (b).
7, as claim 1 or the 3 described methods that realize application server in computer system, it is characterized in that in the step (3), " reception " carried out in receiving thread, " processing " and " transmission " then finished in professional thread; A described business logic processing flow process is equal to a task.
CN 200410046278 2004-06-09 2004-06-09 Method for applied server of computer system Expired - Fee Related CN1277196C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200410046278 CN1277196C (en) 2004-06-09 2004-06-09 Method for applied server of computer system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200410046278 CN1277196C (en) 2004-06-09 2004-06-09 Method for applied server of computer system

Publications (2)

Publication Number Publication Date
CN1584842A CN1584842A (en) 2005-02-23
CN1277196C true CN1277196C (en) 2006-09-27

Family

ID=34601975

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200410046278 Expired - Fee Related CN1277196C (en) 2004-06-09 2004-06-09 Method for applied server of computer system

Country Status (1)

Country Link
CN (1) CN1277196C (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100450105C (en) * 2005-09-13 2009-01-07 中兴通讯股份有限公司 Synchronous information interface realizing method based on JAVA information service
CN100430898C (en) * 2006-12-20 2008-11-05 金魁 Application system for high grade multiple line distance management
CN101141474B (en) * 2007-09-27 2010-06-16 中兴通讯股份有限公司 Hypertext transfer protocol based communication system and method
CN101882089B (en) * 2009-05-07 2013-05-08 中兴通讯股份有限公司 Method for processing business conversational application with multi-thread and device thereof
CN102323894B (en) * 2011-09-08 2013-07-10 上海普元信息技术股份有限公司 System and method for realizing non-blockage mutual calling in distributed application of enterprise
CN104932932B (en) * 2014-03-20 2019-08-23 腾讯科技(深圳)有限公司 A kind of business asynchronous processing method, device and system
CN104717096B (en) * 2015-03-31 2018-10-09 新华三技术有限公司 A kind of event-handling method and device
CN106325977B (en) * 2015-06-19 2020-05-01 北京京东尚科信息技术有限公司 Method and system for executing task based on thread pool
CN105187519B (en) * 2015-08-26 2019-01-08 福建星网锐捷通讯股份有限公司 A kind of socket transmission system based on AIO
CN106897299B (en) * 2015-12-17 2020-03-10 阿里巴巴集团控股有限公司 Database access method and device
CN108255515B (en) * 2018-01-17 2021-02-02 广州汇智通信技术有限公司 Method and device for realizing timer service
CN110851246A (en) * 2019-09-30 2020-02-28 天阳宏业科技股份有限公司 Batch task processing method, device and system and storage medium
CN111651279A (en) * 2020-02-20 2020-09-11 中国银联股份有限公司 Method and system for processing business process

Also Published As

Publication number Publication date
CN1584842A (en) 2005-02-23

Similar Documents

Publication Publication Date Title
CN1277196C (en) Method for applied server of computer system
CN1230737C (en) Device data polling dispatching method
CN100342369C (en) System for application server messaging with multiple dispatch pools
CN1302409C (en) System for integrating java servlets with asynchronous messages
US20040003085A1 (en) Active application socket management
US20060026169A1 (en) Communication method with reduced response time in a distributed data processing system
CN1306430C (en) User self-defining event mechanism based on structure
CN102323894B (en) System and method for realizing non-blockage mutual calling in distributed application of enterprise
CN103092682A (en) Asynchronous network application program processing method
CN1601478A (en) Method and system for dynamically bounded spinning threads on a contested mutex
CN102325148A (en) WebService service calling method
CN101464810A (en) Service program processing method and server
CN1658145A (en) Scalable print spooler
CN105357273A (en) Universal SOCKET communication and process management platform and method in asynchronous communication mode
CN102081605A (en) Data warehouse-based data encapsulation device and service data acquisition method
CN201491032U (en) Large-scale multithread communication server
JP2014520316A (en) Traffic control method and traffic control apparatus
CN1933454A (en) Synchronous information interface realizing method based on JAVA information service
CN1293493C (en) Computer group file service system and its input output treatment method
CN1423456A (en) Sharing route realizing and sheduling method
CN109828842A (en) A kind of high-performance data acquisition engine method based on DPDK technological development
CN1567835A (en) Distributed cluster service management system and service management method in intelligent network
CN1852167A (en) CPE parameter property processing method
CN1588411A (en) Flow custom managing platform
CN112416414A (en) Micro-service architecture containerized lightweight workflow system based on state machine

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20060927

Termination date: 20190609