CN105893160B - A kind of dispatching method of multi-interface data - Google Patents

A kind of dispatching method of multi-interface data Download PDF

Info

Publication number
CN105893160B
CN105893160B CN201610474688.6A CN201610474688A CN105893160B CN 105893160 B CN105893160 B CN 105893160B CN 201610474688 A CN201610474688 A CN 201610474688A CN 105893160 B CN105893160 B CN 105893160B
Authority
CN
China
Prior art keywords
interface
core
core interface
container
response
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.)
Active
Application number
CN201610474688.6A
Other languages
Chinese (zh)
Other versions
CN105893160A (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.)
Alibaba China Co Ltd
Original Assignee
Unification Infotech (beijing) Co Ltd
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 Unification Infotech (beijing) Co Ltd filed Critical Unification Infotech (beijing) Co Ltd
Priority to CN201610474688.6A priority Critical patent/CN105893160B/en
Publication of CN105893160A publication Critical patent/CN105893160A/en
Application granted granted Critical
Publication of CN105893160B publication Critical patent/CN105893160B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention relates to a kind of dispatching methods of multi-interface data, the present invention is by establishing an interface scheduling mechanism, interface scheduling strategy is generated using the interface scheduling mechanism, it is as much as possible concurrent using background process, so that the concurrent quantity on backstage reaches reasonable maximum value, foreground quantity of request interface under the premise of not influencing core business and showing reaches minimum, so that backstage concurrently can take data using the advantage of cpu multicore to greatest extent and foreground is only concerned rendering and user's interaction rather than transmission data, advantage of the invention specifically includes that front page layout can be with the smallest frequency and backstage exchange data, the rearrangement that the page can be effectively reduced when displaying is redrawn;Concurrent processing a large amount of interactive interface in backstage ensure that core business is available, and non-core heart function is shown toward foreground in maximum efficiency.

Description

A kind of dispatching method of multi-interface data
Technical field
The present invention relates to internet areas, and in particular to a kind of dispatching method of multi-interface data.
Background technique
During gradually developing, each page is more and more with business, and the extra data needed can be more next for website More, these data often have respectively primary information source, such as database, memory, file, in order to make exploitation more efficient, Often respectively encapsulate these primary information sources with the mode of encapsulation in most of companies, it is each it is packaged after message come Also cry interface in source, and these interfaces are often on a server, can be to so each page is when obtaining data Interface requests on multiple servers obtain desired data.One page will show that certain business will request various businesses respectively The interface of data is provided, such several ways are had:
(1) completely from background request data
User opens the page, initiates request to backstage, sends acquisition request from background program to all data-interfaces, so After transmit to foreground, displaying is responsible for by foreground again again later, if there is interface that problem occurs under this mode, it may occur that Domino effect, leads to entirely backstage paralysis, and this problem is very normal in some PHP programs for temporarily multithreading not being supported to develop See, is tended not in this way when interface is more;
(2) AJAX request interface is sent by foreground completely and obtains data
User open the page, it is obstructed later platform, completely by foreground send AJAX request interface obtain data, eventually by return Letter of transfer number shows service logic, completely dispenses with backstage, but this mode due to safety problem and is of little use.In addition, all by Foreground sends request, if business demand number of requests is more, or when the case where interdepending, machine matches the browser set low Can because number of requests is excessive and the phenomenon that there is Caton for a long time.
(3) front and back hybrid mode:
Show that core business, front end transmission AJAX show non-using call back function by background request core business interface priority Core business, current this mode are most commonly seen.But the bigger time-consuming of interface general data amount of this mode core business Very long, concurrent utilization is not high;And non-core services shift foreground onto and establish AJAX request, once non-core services quantity is excessive, Foreground can there is a phenomenon where Catons when handling these requests;In addition, during business development, one or more groups Being responsible for one business of completion causes non-core services more and more, and the AJAX that foreground is called is also more and more, and the page just loads It is complete to go to handle many AJAX voice and packet data concurrent services, it is more likely that the phenomenon that will appear Caton.
In conclusion need the method for an Interface Controller to manage the calling of various interfaces, it can be in stable output Non-core services are efficiently added while core business for the page.
Summary of the invention
In order to solve the above-mentioned technical problems, the present invention provides a kind of dispatching method of multi-interface data, for working as webpage The Caton phenomenon occurred when multiple interfaces is requested to establish an interface scheduling mechanism, it is as much as possible concurrent using background process, To achieve the effect that efficiently to add non-core services while stable output core business for the page.
The present invention is realized with following technical solution,
A kind of dispatching method of multi-interface data including the core interface for processing core business and handles non-core industry The non-core interface of business is scheduled, comprising the following steps:
S1. it is interface class, and sorted interface is included in cell therefor:
The core interface that will be directly dispatched is included in core interface container,
The core interface that will not be able to directly be dispatched, which has been included in, relies on core interface container,
The non-core interface that will be directly dispatched is included in non-core interface container,
The non-core interface that will not be able to directly be dispatched, which has been included in, relies on non-core interface container;
S2. the page parameter in HTTP request is obtained;
S3. had according to page parameter update and rely on core interface container, core interface container, non-core interface container Non-core interface container is relied on having;
S4. the interface not being scheduled in the core interface container and non-core interface container is concurrently adjusted With;
S5. according to the call result of S4, forward end sends data;
S6. front end shows the call result of interface in S5, and judges whether there is non-core interface to be processed, if depositing Then the non-core interface is being called;
S7. forward end shows the call result of interface in S6, and judges whether there is non-core interface to be processed, if depositing Continuing to be called the non-core interface, and scheduling result is shown in front end.
Preferably, it updates to have in S3 and relies on core interface container, core interface container, non-core interface container and have dependence Non-core interface container includes:
Under the premise of the known page parameter, traversal, which has to rely on core interface container and have, relies on non-core interface appearance Device,
If there is the core interface for relying on and existing in core interface container and capable of directly being dispatched, will directly be dispatched Core interface move to the core interface container,
If there is the non-core interface for relying on and existing in non-core interface container and capable of directly being dispatched, will described in can be by The non-core interface directly dispatched moves to the non-core interface container.
Preferably, S4 includes:
S41. it opens thread parallel and dispatches not being scheduled in the core interface container and non-core interface container Interface;
If S42. obtaining response, success response is judged whether it is, if so, S43 is carried out, if it is not, then directly stopping institute Have for interface scheduling thread, directly return http response: 502 server problem of message status or 307 jump to it is corresponding The page;
S43. the interface flag that will acquire the response is scheduled interface, inquires whether the response results are to have dependence Core interface container and/or there is undetermined parameter required for the interface relied in non-core interface container, if it is, carrying out Otherwise S44 carries out S46;
S44. the undetermined parameter is substituted with the response results, and under the premise of known to the undetermined parameter, judgement Whether need the interface of the undetermined parameter can directly be scheduled, if can, S45 is carried out, otherwise, carries out S46;
S45. if desired the interface of the undetermined parameter be core interface, then by the core interface from have rely on core connect Mouthful container moves to core interface container, and if desired the interface of the undetermined parameter is non-core interface, then non-core connects described It mouthful relies on non-core interface container and moves to non-core interface container from having;
S46. the thread for obtaining response continues to dispatch not adjusted in the core interface container and non-core interface container The interface spent, until whole core interfaces are responded.
Preferably, S4 further includes obtaining to open in the core interface quantity N and thread maximum number of concurrent tMax, S4 being not called upon The quantity of the thread opened is not more than tMax;If N is not more than tMax, the non-core interface quantity and core interface number of Parallel Scheduling Amount ratio is less than maximum and concurrently compares, otherwise, first Parallel Scheduling core interface, and and N value is obtained in real time, when N is less than tMax, scheduling The non-core interface quantity and core interface quantity ratio for meeting Parallel Scheduling in the process concurrently compare no more than maximum.
Preferably, S4 further includes holding before opening parallel thread to the core interface container and the non-core interface Interface in device is ranked up according to importance, successively to the core interface container and the non-core interface in scheduling process The interface not being scheduled in container is called.
Preferably, S4 further includes before opening parallel thread, to it is described have rely on core interface container and described have dependence Interface in non-core interface container is ranked up according to importance.
Preferably, S5 includes:
The non-core interface for not obtaining response and/or response failure is judged whether there is, if so, then not obtaining sound for described The element for answering and/or responding the non-core interface of failure is packaged together with the data obtained in S4;Otherwise, it is only packaged in S4 and obtains Data;
Result will be packaged and be sent to front end.
Preferably, the element includes interface id and the scheduling for not obtaining the non-core interface of response and/or response failure The parameter of the non-core interface needs for not obtaining response and/or response failure.
Preferably, described to have dependence core interface container, core interface container, non-core interface container and have dependence non-core Interface in heart interface container includes the status indicator for characterizing the Interface status.
Preferably, interface calling is carried out by HTTP request in S4, ajax carries out interface calling in S5 and S6.
The beneficial effects of the present invention are:
The present invention provides a kind of dispatching methods of multi-interface data to utilize this by establishing an interface scheduling mechanism Interface scheduling mechanism generates interface scheduling strategy, as much as possible concurrent using background process, so that the concurrent quantity on backstage reaches To reasonable maximum value, foreground quantity of request interface under the premise of not influencing core business and showing reaches minimum, so that after Platform concurrently can take data using the advantage of cpu multicore to greatest extent and foreground is only concerned rendering and user's interaction rather than passes Transmission of data, advantage of the invention are main further include:
Front page layout can with minimum frequency and backstage exchange data, when displaying the rearrangement of the page can be effectively reduced It redraws;Concurrent processing a large amount of interactive interface in backstage ensure that core business is available, and non-core heart function maximal efficiency is forward Platform is shown.
Detailed description of the invention
Fig. 1 is the dispatching party flow chart of one embodiment multi-interface data;
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, the present invention is made into one below in conjunction with attached drawing Step ground detailed description.
Embodiment 1:
In one embodiment, as shown in Figure 1, a kind of dispatching method of multi-interface data, including for processing core The core interface of business and the non-core interface of processing non-core services are scheduled, and the present embodiment is with video playback website Example, core interface are to realize that webpage plays the relevant interface of video capability, and non-core interface is to realize connecing for the other functions of webpage Mouthful, for example realize comment function, the interface of associated video list display function, subscription function and download function is non-core connects Mouthful.
The dispatching method of multi-interface data the following steps are included:
S1. it is interface class, and sorted interface is included in corresponding queue:
The core interface that will be directly dispatched is included in core interface queue,
The core interface that will not be able to directly be dispatched, which has been included in, relies on core interface queue,
The non-core interface that will be directly dispatched is included in non-core interface queue,
The non-core interface that will not be able to directly be dispatched, which has been included in, relies on non-core interface queue;
S2. the page parameter in HTTP request is obtained;
S3. the parameter page parameter relied on as interface, update, which has, relies on core interface queue, core interface Queue, non-core interface queue and has and rely on non-core interface queue;
S4. the interface not being scheduled in the core interface queue and non-core interface queue is concurrently adjusted With;
S5. according to the call result of S4, forward end sends data;
S6. front end shows the call result of interface in S5, and judges whether there is non-core interface to be processed, if depositing Then the non-core interface is being called;
S7. forward end shows the call result of interface in S6, and judges whether there is non-core interface to be processed, if depositing Continuing to be called the non-core interface, and scheduling result is shown in front end.
Specifically, it updates to have and relies on core interface queue, core interface queue, non-core interface queue and have dependence non-core Heart interface queue method are as follows:
Under the premise of the known page parameter, traversal, which has to rely on core interface queue and have, relies on non-core interface team Column,
If there is the core interface for relying on and existing in core interface queue and capable of directly being dispatched, will directly be dispatched Core interface move to the core interface queue,
If there is the non-core interface for relying on and existing in non-core interface queue and capable of directly being dispatched, will described in can be by The non-core interface directly dispatched moves to the non-core interface queue.
Firstly, first introducing several definition:
CoreList be core interface queue, CoreDependList be have rely on core interface queue,
AppendList is non-core interface queue, and AppendDependList is to have to rely on non-core interface queue.
Interface includes following element:
Id: interface is uniquely requested number;
State: Interface status, -1 indicates that the non-parameter for relying on parameter is taken, and 0 indicates not request, and 1 indicates that request carries out In, 2 indicate that request is completed, and 3 indicate request failure;
Url: request address;
Method: requesting method;
Param: when request interface will band parameter;
Core interface is fully completed mark: CoreListState;
CoreListState is that 0 expression core interface has not sent request and obtained return value, and 1 indicates to obtain All return values, -1 indicates that there are interfaces not to respond to.
Maximum thread: tMax
Concurrent maximum quantity is handled, for describing physical computer theoretically reasonable thread concurrency, the present embodiment The operation method of a Thread Count is provided, Memery is the proceeding internal memory of program distribution (note that this quantity is single backstage journey Sequence triggering, be multiplied by worker quantity if there is multiple worker), it is 128M in the present embodiment, can be looked into ulimit-s See the thread stack size of default, this value is 8M under normal circumstances;Then tMax:128/8=16.
The maximum of core business interface and non-core services interface concurrently compares: CoreVSAppend
Core interface is often just several when concurrent there are core business, in the present embodiment all not all the remaining threads As non-core thread, thread is more also can be slow to entire process poll, if kernel thread can cut off remaining line when completing Journey, if the request thread of non-core services interface excessively will cause the pressure of website without completion again;CoreVSAppend this The setting of a value is by the average response time CoreTimeAve of core interface and the average response time of non-core interface What AppendTimeAve was compared, this needs to see that the log of interface determines the average response time of each interface;Assuming that Concurrently than being 2, then the request for allowing to have 2 core concurrent requests and 4 non-core services interfaces.
Control centre's label: messageDispatch
One page may have several control centres, can be generated in algorithm second and third time to control centre's transmission Which control centre is data come to distinguish, and request can all take scheduling label, scheduling label [scheduler every time Name-which time request] it indicates;
User sends request:
After user opens the page on browser, HTTP request is sent to interface control centre, has page in message entity Face parameter and parameter messageDispatch=playerPage-1, this value are only to be shown to be request broadcast page for the first time Control centre.
The page parameter (if there is encryption, first to decrypt and use afterwards) in HTTP message entity has been put into S2 and S3 The argument section of the interface of dependence, and check it is all have rely on interface queue (CoreDependList and AppendDependList), and the interface for having taken all necessary parameters is removed to the interface queue for having dependence (CoreDependList and AppendDependList) and be moved into do not rely on interface requests queue (CoreList, AppendList), and change interface requests state and be changed to 0 by -1.
Specifically, S4 includes:
S41. the interface not being scheduled in thread parallel scheduling CoreList and AppendDependList is opened;
If S42. obtaining response, success response is judged whether it is, if so, by the mode bit for the interface for obtaining response State is changed to 2 by 1, carries out S43, if it is not, the mode bit state for the interface for obtaining response is changed to 3 by 1, directly stops all For the thread of interface scheduling, directly return http response: 502 server problem of message status 307 jumps to corresponding page Face;
S43. inquire whether the response results are interfaces in CoreDependList and/or AppendDependList Otherwise required undetermined parameter, carries out S46 if it is, carrying out S44;
S44. the undetermined parameter is substituted with the response results, and under the premise of known to the undetermined parameter, judgement Whether need the interface of the undetermined parameter can directly be scheduled, if can, the interface of the undetermined parameter will be needed State has -1 to become 0, carries out S45, otherwise, carries out S46;
S45. if desired the interface of the undetermined parameter is core interface, then by the core interface from having CoreDependList moves to CoreList, and if desired the interface of the undetermined parameter is non-core interface, then by the non-core Heart interface moves to AppendList from AppendDependList;
S46. the thread for obtaining response continues to dispatch the interface not being scheduled in CoreList and AppendList, directly Whole interfaces into CoreList are responded.
Specifically, S4 further includes obtaining to open in the core interface quantity N and thread maximum number of concurrent tMax, S4 being not called upon The quantity of the thread opened is not more than tMax;If N is not more than tMax, the non-core interface quantity and core interface number of Parallel Scheduling Amount ratio is less than maximum and concurrently compares, otherwise, first Parallel Scheduling core interface, and and N value is obtained in real time, when N is less than tMax, scheduling The non-core interface quantity and core interface quantity ratio for meeting Parallel Scheduling in the process concurrently compare no more than maximum.
Specifically, S4 further include open parallel thread before, to CoreList, CoreDependList, Interface in AppendDependList and AppendList is ranked up according to importance, successively right in scheduling process The interface not being scheduled in CoreList and AppendList is called.
The data of the concurrent and part non-core services of all core business interfaces have been handled in S5 by S4, if Have the interface element for being responded and being responded failure in AppendList or not, not responded in entire AppendList and The id and parameter for responding the element of failure break into a data packet and encrypt, and are packaged together with the S4 data obtained, if Element in AppendList, which has all responded, also only sends out core business data and requested non-core services data, arranges below It is sent to the data content of front end out:
A indicates core business data and requested non-core services data;
B indicates the label from which control centre;
C indicates what the data that unsolicited non-core services interface id and unsolicited non-core services interface need were constituted Data encryption packet.
The request not responded is handled in S6 again:
After data are taken in front end, shows that S5 is sent to a data on foreground to the page, then determine whether there are data in c, such as Fruit has reads b from for which control centre, and the data of c are sent back interface control centre with AJAX again;
Corresponding control centre obtains unsolicited non-core services interface id and unsolicited non-core services interface Data deciphering is initiated concurrent process to initiate to request to remaining interface, the state all requested by the data encryption packet needed When becoming non-zero, indicates the data for having taken all non-core services, data are packaged, front end is sent to, if there is connecing Mouth sends (state state is 3) non-core interface of request failure, and each request of transmission request failure is packaged respectively, is added It is close, the data content for being sent to front end is listed below:
A indicates requested non-core services data;
B indicates the label from which control centre;
C indicates the non-core services interface ciphering packet of failure;
The request not responded is handled in S7 again:
The non-core services data in a are taken, front end is presented in, if there are data in data above block c, respectively to tune AJAX request is initiated at degree center, obtains response data, then be shown to front end.
Embodiment 2:
Nginx server is used in the present embodiment: having a master, M worker, master in nginx server Control worker.
Using nginx server carry out multi-interface data dispatching method the following steps are included:
S1. it is interface class, and sorted interface is included in corresponding queue:
The core interface that will be directly dispatched is included in core interface queue,
The core interface that will not be able to directly be dispatched, which has been included in, relies on core interface queue,
The non-core interface that will be directly dispatched is included in non-core interface queue,
The non-core interface that will not be able to directly be dispatched, which has been included in, relies on non-core interface queue;
S2. the page parameter in HTTP request is obtained;
S3. the parameter page parameter relied on as interface, update, which has, relies on core interface queue, core interface Queue, non-core interface queue and has and rely on non-core interface queue;
S4. the interface not being scheduled in the core interface queue and non-core interface queue is concurrently adjusted With the quantity of the thread of concurrent invocation is proceeding internal memory, the quantity at thread station and the number of worker of program distribution by Memery M is measured to determine;
S5. according to the call result of S4, forward end sends data;
S6. front end shows the call result of interface in S5, and judges whether there is non-core interface to be processed, if depositing Then the non-core interface is being called;
S7. forward end shows the call result of interface in S6, and judges whether there is non-core interface to be processed, if depositing Continuing to be called the non-core interface, and scheduling result is shown in front end.
Specifically, it updates to have and relies on core interface queue, core interface queue, non-core interface queue and have dependence non-core Heart interface queue method are as follows:
It updates to have in S3 and relies on core interface container, core interface container, non-core interface container and have dependence non-core Interface container includes:
Under the premise of the known page parameter, traversal, which has to rely on core interface container and have, relies on non-core interface appearance Device,
If there is the core interface for relying on and existing in core interface container and capable of directly being dispatched, will directly be dispatched Core interface move to the core interface container,
If there is the non-core interface for relying on and existing in non-core interface container and capable of directly being dispatched, will described in can be by The non-core interface directly dispatched moves to the non-core interface container.
Specifically, S4 includes:
S41. it opens thread parallel and dispatches not being scheduled in the core interface container and non-core interface container Interface;
If S42. obtaining response, success response is judged whether it is, if so, S43 is carried out, if it is not, then directly stopping institute Have for interface scheduling thread, directly return http response: 502 server problem of message status or 307 jump to it is corresponding The page;
S43. the interface flag that will acquire the response is scheduled interface, inquires whether the response results are to have dependence Core interface container and/or there is undetermined parameter required for the interface relied in non-core interface container, if it is, carrying out Otherwise S44 carries out S46;
S44. the undetermined parameter is substituted with the response results, and under the premise of known to the undetermined parameter, judgement Whether need the interface of the undetermined parameter can directly be scheduled, if can, S45 is carried out, otherwise, carries out S46;
S45. if desired the interface of the undetermined parameter be core interface, then by the core interface from have rely on core connect Mouthful container moves to core interface container, and if desired the interface of the undetermined parameter is non-core interface, then non-core connects described It mouthful relies on non-core interface container and moves to non-core interface container from having;
S46. the thread for obtaining response continues to dispatch not adjusted in the core interface container and non-core interface container The interface spent, until whole core interfaces are responded.
In addition, S4 further includes obtaining to open in the core interface quantity N and thread maximum number of concurrent tMax, S4 being not called upon Thread quantity be not more than tMax;If N is not more than tMax, the non-core interface quantity and core interface quantity of Parallel Scheduling Ratio is less than maximum and concurrently compares, otherwise, first Parallel Scheduling core interface, and and N value is obtained in real time, when N is less than tMax, dispatched The non-core interface quantity and core interface quantity ratio for meeting Parallel Scheduling in journey concurrently compare no more than maximum.
Specifically, S5 includes:
The non-core interface for not obtaining response and/or response failure is judged whether there is, if so, then not obtaining sound for described The element for answering and/or responding the non-core interface of failure is packaged together with the data obtained in S4;Otherwise, it is only packaged in S4 and obtains Data;
Result will be packaged and be sent to front end.
Specifically, the element includes interface id and the scheduling for not obtaining the non-core interface of response and/or response failure The parameter of the non-core interface needs for not obtaining response and/or response failure.
Specifically, described to have dependence core interface container, core interface container, non-core interface container and have dependence non-core Interface in heart interface container includes the status indicator for characterizing the Interface status.
In the present embodiment, interface calling is carried out by HTTP request in S4, passes through ajax progress interface calling in S5 and S6.
In addition, in the present embodiment:
(1) all requests write in text document, and total interface calls clear;
(2) there are when dependence, be first packaged into one to connect for parameter when the interface of two or more non-core services calls Mouth is called again;
(3) average response time of the interface of core business is not less than the non-core services interface response time;
(4) response time of total interface in an order of magnitude, did not had the presence of slow interface, and excessively slow interface makes pressure Use expired time;
(5) response data of interface is no more than 3M data.
Embodiment 3:
Third embodiment, the difference with one embodiment are:
The request time of total interface is recorded, if interface requests will unsuccessfully use a very big response time It indicates interface malloc failure malloc, all interface response times is recorded and sorted, this sequence is a sample;Statistics After the interface ordered samples for accessing website to n user, the response time of each interface is averaged, administrator is reported to. If website visiting amount is very big, the mode record interface state of random sampling can be used, the sample of random statistical A% is as system Metering.
The present embodiment can find the problem of interface in time, and optimize the interface of low-response;If interface responded slowly, The state of this interface is directly set to 3, and foreground is allowed to be called using ajax.
Embodiment 4:
4th embodiment is with one embodiment difference:
S1 is optimized:
When creating queue, request of the interface on same server is put together as far as possible, the reason is that, when building When vertical http request, keep-alive attribute can be added in heading, be can establish a TCP data when concurrent and passed Defeated channel sends multiple HTTP requests and is used to save the time.
Embodiment 5:
5th embodiment is with one embodiment difference:
Under the premise of not knowing the configuration of nginx, the subprocess for not being the nginx of reverse proxy is natively accounted for very greatly Resource, interrupted if robbing resource together in the new process of pull-up and drawing, O&M can't allow open excessive process;So it is merely able to Use thread;
1. the advantages of multithreading:
Object and variable be it is shared, can directly be operated;
Filec descriptor is that shared, different thread can directly operate the same resource;
2. the shortcomings that multithreading:
It needs to lock when operating nonlocal variable, programming difficulty is high;
EMS memory error occurs for one thread, and entire process can all terminate.
However, if website is often unstable in some period interface, it may occur that certain thread interrupt in scheduling process Therefore S4 is optimized so as to cause entire scheduling process interrupt, optimal way are as follows:
(1) it requires Nginx using reversed proxy server, forwards a request to multiple network servers;It is taken in multiple networks Deployment interface scheduler on business device;
(2) it uses multi-course concurrency instead from the background and does not use multi-thread concurrent request interface, scheduler at this time is one A parent process, concurrent request process are its subprocess, and the stability of entire parent process can be improved.
This optimal way also has a shortcoming, and the memory of process consumption is excessively high, do not consider resource can with process come It substitutes thread and realizes that interface is concurrent.
Embodiment 6:
6th embodiment, the difference with one embodiment are:
The present embodiment concurrently takes data using node.js realization.
Embodiment 7:
7th embodiment, the difference with one embodiment are:
The present embodiment uses nginx, there is a master in nginx, and M worker, master control worker.
Foreground extends the concurrency of ajax using the H5 new features of worker.
The above disclosure is only the preferred embodiments of the present invention, cannot limit the right model of the present invention with this certainly It encloses, therefore equivalent changes made in accordance with the claims of the present invention, is still within the scope of the present invention.

Claims (10)

1. a kind of dispatching method of multi-interface data, including the core interface and processing non-core services for processing core business Non-core interface be scheduled, which comprises the following steps:
S1. it is interface class, and sorted interface is included in cell therefor:
The core interface that will be directly dispatched is included in core interface container,
The core interface that will not be able to directly be dispatched, which has been included in, relies on core interface container,
The non-core interface that will be directly dispatched is included in non-core interface container,
The non-core interface that will not be able to directly be dispatched, which has been included in, relies on non-core interface container;
S2. the page parameter in HTTP request is obtained;
S3. had according to page parameter update and rely on core interface container, core interface container, non-core interface container and have Rely on non-core interface container;
S4. according to the relationship of the core interface quantity N and thread maximum number of concurrent tMax that are not called upon, the core interface is held The interface not being scheduled in device and the non-core interface container carries out concurrent invocation;If the interface success not being scheduled Response then based on response results and has and relies on core interface container and/or have an interface institute relied in non-core interface container The undetermined parameter needed, the needs undetermined parameter that movement can directly be scheduled are interfaced to core interface container or non-core Heart interface container;
S5. according to the call result of S4, forward end sends data;
S6. front end shows the call result of interface in S5, and judges whether there is non-core interface to be processed, and if it exists, then The non-core interface is called;
S7. forward end shows the call result of interface in S6, and judges whether there is non-core interface to be processed, and if it exists, Continue to be called the non-core interface, and scheduling result is shown in front end.
2. a kind of dispatching method of multi-interface data according to claim 1, which is characterized in that updating in S3 has dependence core Heart interface container, core interface container, non-core interface container and has and rely on non-core interface container and include:
Under the premise of the known page parameter, traversal, which has to rely on core interface container and have, relies on non-core interface container,
If there is the core interface for relying on and existing in core interface container and capable of directly being dispatched, can directly be dispatched by described in Core interface move to the core interface container,
It, can be direct by described in if there is the non-core interface for relying on and existing in non-core interface container and capable of directly being dispatched The non-core interface of scheduling moves to the non-core interface container.
3. a kind of dispatching method of multi-interface data according to claim 2, which is characterized in that S4 includes:
S41. it opens thread parallel and dispatches the interface not being scheduled in the core interface container and non-core interface container;
If S42. obtaining response, success response is judged whether it is, if so, S43 is carried out, if it is not, it is useful then directly to stop institute In the thread of interface scheduling, directly return http response: 502 server problem of message status 307 jumps to the corresponding page;
S43. the interface flag that will acquire the response is scheduled interface, and whether inquiry response result is to have dependence core interface Container and/or there is undetermined parameter required for the interface relied in non-core interface container, if it is, S44 is carried out, otherwise, Carry out S46;
S44. the undetermined parameter is substituted with the response results, and under the premise of known to the undetermined parameter, judge to need Whether the interface of the undetermined parameter can directly be scheduled, if can, S45 is carried out, otherwise, carries out S46;
S45. if desired the interface of the undetermined parameter be core interface, then by the core interface from have rely on core interface hold Device moves to core interface container, if desired the interface of the undetermined parameter be non-core interface, then by the non-core interface from There is the non-core interface container of dependence to move to non-core interface container;
S46. the thread for obtaining response continues to dispatch not being scheduled in the core interface container and non-core interface container Interface, until whole core interfaces are responded.
4. a kind of dispatching method of multi-interface data according to claim 3, which is characterized in that S4 further include obtain not by The quantity for the thread opened in the core interface quantity N and thread maximum number of concurrent tMax, S4 of calling is no more than tMax;If N is not Greater than tMax, then the non-core interface quantity of Parallel Scheduling and core interface quantity ratio are less than maximum and concurrently compare, otherwise, first simultaneously Row Scheduling Core interface, and N value is obtained in real time, when N is less than tMax, then need to meet the non-core of Parallel Scheduling in scheduling process Interface quantity and core interface quantity ratio concurrently compare no more than maximum.
5. a kind of dispatching method of multi-interface data according to claim 3, which is characterized in that S4 further includes opening parallel Before thread, the interface in the core interface container and the non-core interface container is ranked up according to importance, is adjusted Successively the interface not being scheduled in the core interface container and the non-core interface container is adjusted during degree With.
6. a kind of dispatching method of multi-interface data according to claim 3, which is characterized in that S4 further includes opening parallel Before thread, there are dependence core interface container and the interface having in the non-core interface container of dependence according to importance to described It is ranked up.
7. a kind of dispatching method of multi-interface data according to claim 3, which is characterized in that S5 includes:
The non-core interface for not obtaining response and/or response failure is judged whether there is, if so, not responded described then And/or the element of the non-core interface of response failure is packaged together with the data obtained in S4;Otherwise, it is only obtained in packing S4 Data;
Result will be packaged and be sent to front end.
8. a kind of dispatching method of multi-interface data according to claim 7, which is characterized in that the element includes not obtaining It must respond and/or respond the interface id of the non-core interface of failure and scheduling is described does not obtain the non-of response and/or response failure The parameter that core interface needs.
9. a kind of dispatching method of multi-interface data according to claim 8, which is characterized in that described to there is dependence core to connect Mouthful container, core interface container, non-core interface container and to have the interface relied in non-core interface container include that characterization connects The status indicator of mouth state.
10. a kind of dispatching method of multi-interface data according to claim 1, which is characterized in that asked in S4 by HTTP It asks and carries out interface calling, pass through ajax progress interface calling in S5 and S6.
CN201610474688.6A 2016-06-24 2016-06-24 A kind of dispatching method of multi-interface data Active CN105893160B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610474688.6A CN105893160B (en) 2016-06-24 2016-06-24 A kind of dispatching method of multi-interface data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610474688.6A CN105893160B (en) 2016-06-24 2016-06-24 A kind of dispatching method of multi-interface data

Publications (2)

Publication Number Publication Date
CN105893160A CN105893160A (en) 2016-08-24
CN105893160B true CN105893160B (en) 2019-09-27

Family

ID=56719005

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610474688.6A Active CN105893160B (en) 2016-06-24 2016-06-24 A kind of dispatching method of multi-interface data

Country Status (1)

Country Link
CN (1) CN105893160B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106777055B (en) * 2016-12-09 2021-01-01 武汉斗鱼网络科技有限公司 Method and device for realizing website interfacing rendering
CN110149356A (en) * 2019-02-28 2019-08-20 深圳点猫科技有限公司 Method and device is uniformly processed in a kind of network request abnormality
CN111273999B (en) * 2020-01-20 2021-07-20 北京字节跳动网络技术有限公司 Data processing method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103052059A (en) * 2011-10-17 2013-04-17 ***通信集团公司 Intelligent terminal and data processing method in intelligent terminal
CN103368724A (en) * 2013-07-30 2013-10-23 东莞宇龙通信科技有限公司 Terminal and data processing method
CN103402017A (en) * 2013-07-30 2013-11-20 东莞宇龙通信科技有限公司 Terminal and data processing method
CN105262826A (en) * 2015-10-29 2016-01-20 福建天晴数码有限公司 Method and system for adjusting interface processing amount

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130226892A1 (en) * 2012-02-29 2013-08-29 Fluential, Llc Multimodal natural language interface for faceted search

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103052059A (en) * 2011-10-17 2013-04-17 ***通信集团公司 Intelligent terminal and data processing method in intelligent terminal
CN103368724A (en) * 2013-07-30 2013-10-23 东莞宇龙通信科技有限公司 Terminal and data processing method
CN103402017A (en) * 2013-07-30 2013-11-20 东莞宇龙通信科技有限公司 Terminal and data processing method
CN105262826A (en) * 2015-10-29 2016-01-20 福建天晴数码有限公司 Method and system for adjusting interface processing amount

Also Published As

Publication number Publication date
CN105893160A (en) 2016-08-24

Similar Documents

Publication Publication Date Title
CN107729139B (en) Method and device for concurrently acquiring resources
US9515909B2 (en) System and method for determining and optimizing resources of data processing system utilized by a service request
CN110351342A (en) Service order processing method, device, computer equipment and storage medium
Schafer et al. Tasklets:" better than best-effort" computing
US10908926B2 (en) Plug-in management wrappers
CN109995669A (en) Distributed current-limiting method, device, equipment and readable storage medium storing program for executing
CN107479990A (en) Distributed software service system
EP2590113A1 (en) On demand multi-objective network optimization
CN105183470B (en) A kind of natural language processing system service platform
US10079865B2 (en) Method and system for an ontology based request/reply service
CN105893160B (en) A kind of dispatching method of multi-interface data
CN112256406B (en) Operation flow platformization scheduling method
CN105930249B (en) Using monitoring method and device
CN113703997A (en) Bidirectional asynchronous communication middleware system integrating multiple message agents and implementation method
CN108900627A (en) A kind of network request method, terminal installation and storage medium
Seelam et al. Polyglot application auto scaling service for platform as a service cloud
CN109725887A (en) Data interactive method, device and terminal device based on message research and development frame
US9614900B1 (en) Multi-process architecture for a split browser
CN109801425A (en) Queue poll reminding method, device, equipment and storage medium in the label business of face
CN103514044B (en) Resource optimization method, device and system of dynamic behavior analysis system
CN107426109A (en) A kind of traffic scheduling method, VNF modules and flow scheduling server
CN111913784A (en) Task scheduling method and device, network element and storage medium
CN109697132A (en) A kind of instantaneous communication system and method for terminal device
CN107329819A (en) A kind of job management method and device
CN109862070A (en) Inlet wire optimization method in financial face label business, device and can read access medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 100080 Beijing Haidian District city Haidian street A Sinosteel International Plaza No. 8 block 5 layer D

Patentee after: YOUKU INFORMATION TECHNOLOGY (BEIJING) Co.,Ltd.

Address before: 100029, B, 6 floor, World Trade Center, No. 36 East Third Ring Road, Dongcheng District, Beijing

Patentee before: HEYI INFORMATION TECHNOLOGY (BEIJING) Co.,Ltd.

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20200619

Address after: 310052 room 508, floor 5, building 4, No. 699, Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: Alibaba (China) Co.,Ltd.

Address before: 100080 Beijing Haidian District city Haidian street A Sinosteel International Plaza No. 8 block 5 layer D

Patentee before: YOUKU INFORMATION TECHNOLOGY (BEIJING) Co.,Ltd.