CN108337295A - A kind of Internet of Things communication means, server and system - Google Patents

A kind of Internet of Things communication means, server and system Download PDF

Info

Publication number
CN108337295A
CN108337295A CN201810028886.9A CN201810028886A CN108337295A CN 108337295 A CN108337295 A CN 108337295A CN 201810028886 A CN201810028886 A CN 201810028886A CN 108337295 A CN108337295 A CN 108337295A
Authority
CN
China
Prior art keywords
time
thread
server
operating mode
terminal
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.)
Granted
Application number
CN201810028886.9A
Other languages
Chinese (zh)
Other versions
CN108337295B (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.)
Qingdao Haier Intelligent Home Appliance Technology Co Ltd
Original Assignee
Qingdao Haier Intelligent Home Appliance Technology 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 Qingdao Haier Intelligent Home Appliance Technology Co Ltd filed Critical Qingdao Haier Intelligent Home Appliance Technology Co Ltd
Priority to CN201810028886.9A priority Critical patent/CN108337295B/en
Publication of CN108337295A publication Critical patent/CN108337295A/en
Application granted granted Critical
Publication of CN108337295B publication Critical patent/CN108337295B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a kind of Internet of Things communication means, server and systems, belong to Internet of Things field of communication technology.The Internet of Things communication means is applied to server, including:Obtain the required first time T1 of connection request sent with current thread operating mode processing terminal;Judge whether first time T1 reaches first time threshold, if first time T1 reaches first time threshold, switches current thread operating mode.Corresponding module is set in server, to realize the Internet of Things communication means.Server can flexibly switch according to the traffic load amount of terminal between single thread operating mode and multithreading operating mode, improve the ability of server process connection request.The Internet of Things network communication system of the server and terminal composition, also has the ability of efficient communication.

Description

A kind of Internet of Things communication means, server and system
Technical field
The present invention relates to Internet of Things field of communication technology, more particularly to a kind of Internet of Things communication means, server and system.
Background technology
In current Internet of Things network communication system, if server thread is excessive, the expense of switch threads is big, occupies server Resource reduces server performance;If server thread is very few, once terminal connection request increases, server can not play it Due performance, it will increase the Queue time of connection request.
Invention content
An embodiment of the present invention provides a kind of Internet of Things communication means, server and systems.For the embodiment to disclosure Some aspects there are one basic understanding, simple summary is shown below.The summarized section is not extensive overview, nor It determines key/critical component or describes the protection domain of these embodiments.Its sole purpose is to be in simple form Some existing concepts, in this, as the preamble of following detailed description.
According to a first aspect of the embodiments of the present invention, a kind of Internet of Things communication means is provided, server, packet are applied to It includes:Obtain the required first time T1 of connection request sent with current thread operating mode processing terminal;Judge described Whether one time T1 reaches first time threshold, if the first time T1 reaches the first time threshold, described in switching Current thread operating mode.
Server in this method can be according to the traffic load amount of internet-of-things terminal in single thread operating mode and multithreading Flexibly switch between operating mode, improves the ability of server process connection request, keep the communication of server and terminal more efficient.
In a kind of optional embodiment, after the first time T1 reaches the first time threshold, described in the switching Before current thread operating mode, further include:Judge whether the duration of the current thread operating mode reached for the second time Threshold value;If the duration of the current thread operating mode has reached the second time threshold, work as front described in switching Journey operating mode.
It is described to obtain the connection request institute sent with current thread operating mode processing terminal in a kind of optional embodiment Further include initialization thread operating mode before the first time T1 needed, the initialization thread operating mode includes setting Number of threads, the first time threshold and the second time threshold.
In a kind of optional embodiment, obtain required for the connection request sent with current thread operating mode processing terminal First time T1, specially:Record the time point t1 that the connection request that terminal is sent reaches server;Selector is read The thread of connection request described in the connection request and allocation processing;Thread reads and handles the connection request;Described in record The time t1 ' that connection request described in thread process finishes;The first time T1, T1=t1 '-t1.
In a kind of optional embodiment, when terminal accesses, the thread reads and handles the connection request, specifically For:The connection request that terminal is sent is specially access request;The thread reads the access request;The thread is institute State access request setting configuration file;The thread receives the access request;
When receiving terminal data, the thread reads and handles the connection request, specially:The thread reads institute State connection request;The thread allows terminal to be written and read operation in the server;The thread receives the data that terminal is sent.
According to a second aspect of the embodiments of the present invention, a kind of Internet of Things communication server is provided, including:It obtains at the first time Module, judgment module, handover module;The first time acquisition module, is handled for obtaining server with current operation mode The connection request required first time that terminal is sent;The judgment module, for judging whether the first time reaches First time threshold starts the handover module if the first time reaches the first time threshold;The switching mould Block is used for the current thread operating mode of switching server.
In a kind of optional embodiment, the judgment module is additionally operable to judge continuing for the current thread operating mode Whether the time reaches second time threshold;If the first time reaches the first time threshold, and the current thread work The duration of operation mode reaches the second time threshold, then starts handover module.
Further include initialization module in a kind of optional embodiment, the initialization module, for be arranged number of threads, The first time threshold and the second time threshold.
Further include terminal AM access module and data reception module in a kind of optional embodiment;The terminal AM access module, Access request for receiving terminal;The data reception module, the data for receiving terminal transmission;The first time is obtained Modulus block runs the primary terminal for obtaining server when the terminal AM access module is run with current operation mode AM access module required first time;When the data reception module is run, for obtaining server with work at present mould The formula operation primary data reception module required first time.
According to a third aspect of the embodiments of the present invention, a kind of Internet of Things network communication system, including server, the service are provided The server that device is provided by second aspect of the present invention.
It should be understood that above general description and following detailed description is only exemplary and explanatory, not It can the limitation present invention.
Description of the drawings
The drawings herein are incorporated into the specification and forms part of this specification, and shows the implementation for meeting the present invention Example, and be used to explain the principle of the present invention together with specification.
Fig. 1 is a kind of flow diagram of Internet of Things communication means shown according to an exemplary embodiment;
Fig. 2 is the communication efficiency of the Thread Count and server of a kind of reflection server shown according to an exemplary embodiment Relationship schematic diagram;
Fig. 3 is the communication efficiency of the Thread Count and server of a kind of reflection server shown according to an exemplary embodiment Relationship schematic diagram;
Fig. 4 is the communication efficiency of the Thread Count and server of a kind of reflection server shown according to an exemplary embodiment Relationship schematic diagram;
Fig. 5 is needed for the connection request that a kind of acquisition server to process terminal shown according to an exemplary embodiment is sent The flow diagram of the first time T1 wanted;
Fig. 6 is needed for the connection request that a kind of acquisition server to process terminal shown according to an exemplary embodiment is sent The flow diagram of the first time T1 wanted;
Fig. 7 is a kind of flow diagram of switching current thread operating mode shown according to an exemplary embodiment;
Fig. 8 is a kind of switching current thread operating mode schematic diagram shown according to an exemplary embodiment;
Fig. 9 is a kind of flow diagram of the initialization of thread work pattern shown according to an exemplary embodiment;
Figure 10 is a kind of schematic diagram of terminal access process shown according to an exemplary embodiment;
Figure 11 is a kind of schematic diagram of terminal access process shown according to an exemplary embodiment;
Figure 12 is a kind of flow diagram of reception terminal data shown according to an exemplary embodiment;
Figure 13 is a kind of flow diagram of reception terminal data shown according to an exemplary embodiment;
Specific implementation mode
The following description and drawings fully show specific embodiments of the present invention, to enable those skilled in the art to Put into practice them.Embodiment only represents possible variation.Unless explicitly requested, otherwise individual components and functionality is optional, and And the sequence of operation can change.The part of some embodiments and feature can be included in or replace other embodiments Part and feature.The range of embodiment of the present invention includes the entire scope of claims and the institute of claims There is obtainable equivalent.Herein, each embodiment can individually or generally be indicated that this is only with term " invention " It is merely for convenience, and if in fact disclosing the invention more than one, be not meant to automatically limit the range of the application For any single invention or inventive concept.Herein, relational terms such as first and second and the like are used only for one Entity, which either operates to distinguish with another entity or operation, to be existed without requiring or implying between these entities or operation Any actual relationship or sequence.Moreover, the terms "include", "comprise" or its any other variant be intended to it is non-exclusive Property include, so that process, method or equipment including a series of elements include not only those elements, but also to include Other elements that are not explicitly listed.Each embodiment herein is described by the way of progressive, and each embodiment stresses Be all difference from other examples, just to refer each other for identical similar portion between each embodiment.For implementing For structure, product etc. disclosed in example, since it is corresponding with part disclosed in embodiment, so fairly simple, the phase of description Place is closed referring to method part illustration.
According to Fig. 1 to Figure 13, illustrate the embodiment of the present invention in a first aspect, a kind of Internet of Things communication means, such as Fig. 1 institutes Show, is applied to server, including:
The required first time T1 of connection request that S101, acquisition are sent with current thread operating mode processing terminal;
S102, judge whether first time T1 reaches first time threshold, if first time T1 reaches first time threshold, Then follow the steps S103;
S103, switching current thread operating mode.
In the present embodiment, current thread operating mode is the thread work residing for server when obtaining first time T1 Pattern;Thread work pattern includes:Single thread operating mode and multithreading operating mode.If current thread operating mode is single line Journey operating mode, switching current thread operating mode are to switch to multithreading operating mode by single thread operating mode;If working as Preceding thread operating mode is multithreading operating mode, and switching current thread operating mode is to be switched to by multithreading operating mode Single thread operating mode.
Server in this method can be according to the traffic load amount of internet-of-things terminal (hereinafter referred to as " terminal ") in single thread Flexibly switch between operating mode and multithreading operating mode, improve server process connection request ability, make server with The communication of terminal is more efficient.
First time T1, which is reflected, to give out a contract for a project time-consuming between terminal and server, that is, reflects the communication efficiency of communication system, First time, T1 was bigger, indicated that the communication between terminal and server more has some setbacks, the efficiency of communication system is lower;Lead to first The increased factors of time T1 mainly have following two aspects:1) traffic load between terminal and server is big;Such as in certain a period of time Between there are 300 terminal to server to have sent a large amount of connection requests in section, and the Thread Count of server process connection request is limited, Such as 60 threads, 60 connection requests can only be once handled, other 240 connection requests are just waited in line, thus, right For other 240 connection requests waited in line, time for waiting in line is included in give out a contract for a project and take in, become so giving out a contract for a project and taking Greatly, i.e. first time T1 increases;Such as the traffic between terminal and server becomes larger, then the time for handling a connection request becomes Long, the Queue time for the connection request being lined up is also corresponding elongated, and causing to give out a contract for a project to take becomes larger, i.e. first time T1 increases Greatly;2) the performance in-fighting of server is big;Such as although the connection request of pending terminal is less, server is still dispatched greatly The thread of amount handles less connection request, and the processor of server needs to be scheduled these thread, processor exists A thread can only be executed in one timeslice, for switching to thread B by thread A, processor needs " to preserve thread A's Execute scene ", then " be loaded into thread B executes scene ", this process can consume the resource of a large amount of processor, server The quantity of the thread of processor scheduling is bigger, and the resource of the processor of consumption is more;The consumption of switch threads also has:Memory it is same Walk expense, thread creation and the expense of extinction and the expense etc. of scheduling;Server is consumed to the handoff procedure of thread The efficiency of resource, server process connection request is lower, and giving out a contract for a project to take increases, and first time T1 increases.In short, what terminal was sent The load capacity of connection request and the treatment progress number of server mismatch, and increase first time T1.When server process thread When less, by taking current thread operating mode is single thread operating mode as an example, first time T1 increases, and reaches first time threshold When, illustrate that the thread of server work is very little, be not enough to cope with excessively high traffic load, needs to work in increase server at this time Thread Count, switch current thread operating mode, i.e., multithreading operating mode is switched to by single thread operating mode;Work as server When the thread of middle work is excessive, by taking current thread operating mode is multithreading operating mode as an example, first time T1 increases, and reaches When first time threshold, illustrate that the thread of server work is too many, Thread-switch overhead is too big, needs to reduce in server at this time The Thread Count of work switches current thread working condition, i.e., switches to single thread operating mode by multithreading operating mode.Pass through Change the Thread Count to work in server, it is ensured that the traffic load of server and the Thread Count of work match, the clothes made The connection request that the efficient processing terminal of business device is sent, and then the communication between the terminal of Internet of Things and server is made more to increase Effect.
Multithreading operating mode in the present embodiment includes the multithreading operating mode of 2 threads and the above thread.In turn, In a kind of optional embodiment, multithreading operating mode includes the first multithreading operating mode, the second multithreading operating mode, the Three multithreading operating modes and the 4th multithreading operating mode.If the maximum thread that server is configured is N, more than first The Thread Count dispatched in thread work pattern is N/4, and the Thread Count dispatched in the second multithreading operating mode is N/2, and third is more The Thread Count dispatched in thread work pattern is 3N/4, and the Thread Count dispatched in the 4th multithreading operating mode is N.It is corresponding, Traffic load is minimum or the communication request number of terminal is few, or even only there are one terminals when sending communication request, and server is cut Single thread operating mode is shifted to, i.e. the current thread operating mode of server is single thread operating mode;With traffic load It gradually increases, current thread operating mode can be switched to the first multithreading operating mode or the second multithreading operating mode, or Third multithreading operating mode or the 4th multithreading operating mode.
Further multithreading operating mode is finely divided, in a kind of optional embodiment, the work of each different threads number Operation mode one multithreading operating mode of equal self-contained, i.e. multithreading operating mode include 2 thread work patterns, 3 thread work moulds Formula, 4 thread work pattern ... N-1 thread works patterns and N thread works pattern (total number of threads of server is N).For Specific traffic load, server only work under the operating mode of optimal Thread Count, just can guarantee that communication system is in most Efficient communications status.As shown in Fig. 2, when traffic load is minimum, i.e., when single thread operating mode can meet communication requirement, With the increase of the Thread Count to work in server, the switching consumption of server thread increases, and the working efficiency of communication system is anti- And it continuously decreases;As shown in figure 3, when traffic load is in the maximum value that communication system can accommodate, with work in server The increase of the Thread Count of work, the connection request waited in line is fewer and fewer, and the working efficiency of communication system gradually increases;Such as Fig. 4 It is shown, when traffic load is between peak volume and minimum traffic, with the increase of the Thread Count to work in server, Showing that the connection request waited in line is fewer and fewer, the communication efficiency of communication system improves, to after critical value, the line in server Journey switching consumption becomes apparent, and the communication efficiency of communication system continuously decreases.By the above rule, server is according to traffic load Corresponding multithreading operating mode is switched to, ensures that the communication efficiency of communication system is in optimum state.
First time threshold reflects the desired value to the communication efficiency of communication system, and first time threshold is smaller, explanation It is expected that the communication efficiency of the communication system is higher;First time threshold is bigger, illustrates it is expected that the communication efficiency of the communication system is got over It is low.Under normal circumstances, first time threshold is positively correlated with a communication cycle, and a communication cycle, that is, terminal and server are complete At once communicating required average time.It should be noted that with the increase of the traffic load in communication system, communication system The optimal communication efficiency of system continuously decreases.That is, the increase of the traffic load with communication system, terminal are complete with server The period needed at primary communication is elongated, therefore needs accordingly to tune up first time threshold.
Thread switching consumption server performance, likewise, switch threads operating mode can also consume a large amount of server Energy:Switch threads operating mode means that total number of threads changes, wherein creating thread process or terminated line comprising a large amount of Journey process.To avoid the thread work pattern of server from carrying out unnecessary switching, in a kind of optional embodiment, when first Between after T1 reaches first time threshold, before switching current thread operating mode, further include:Judge current thread operating mode Whether the duration reaches second time threshold;If first time T1 reaches first time threshold, and current thread operating mode Duration have reached second time threshold, then switch current thread operating mode.If current thread operating mode continues Time less than second time threshold, just switch threads operating mode again, then last time switch threads operating mode and this cut The interval time for changing current thread operating mode is too short, and thread work pattern switching is excessively frequent, can continuously consume server A large amount of resource, to delay the connection request of server to process terminal transmission, to reduce the communication efficiency of communication system.Institute After the duration of current thread operating mode reaches second time threshold, then to switch current thread operating mode, to subtract Influence of the switching current operation mode to communication efficiency less.Switching current thread operating mode in the present embodiment, if referring to Current thread operating mode is single thread operating mode, then switches to multithreading operating mode by single thread operating mode;If working as Preceding thread operating mode is multithreading operating mode, then switches to single thread operating mode by multithreading operating mode.
In a kind of optional embodiment, second time threshold is that the communication efficiency after switch threads operating mode reaches stable state The required time.After switch threads operating mode, the ability of server process traffic load changes, i.e. communication system at this time Communication efficiency change, that react communication efficiency is first time T1, in order to improve accuracy, it is preferred that at the first time T1 be the required average value of server process connection request, so, after switch threads operating mode, immediately obtain first Time T1 is influenced by preceding thread operating mode, is inaccurate, if at this time according to first time T1 switch threads work Operation mode can not only influence communication efficiency, but also can not switch to accurate thread work pattern, can not ensure communication system Communication be in highest effect state.So after the duration of thread work pattern reaching second time threshold, i.e. communication system After the communication efficiency of system becomes stable, then switch threads operating mode, it is ensured that accurate thread work pattern is switched to, is protected Demonstrate,prove the communication efficiency highest of communication system.
In a kind of optional embodiment, as shown in figure 5, obtaining server process connection request required first time T1, specially:
The connection request that S501, record terminal are sent reaches the time point t1 of server;
S502, selector read the thread of connection request and allocation processing connection request;
S503, thread read and handle connection request;
The time point t1 ' that S504, record thread processing connection request finish;
S505, first time T1, T1=t1 '-t1.
In a kind of optional embodiment, Internet of Things communication means is realized with Java (programming language of object-oriented) language, Including:
Selector selectors, can the multiple Socket of concurrent processing (be a communication for describing IP address and port The handle of chain can be used for realizing communication between server and terminal) selectors of connection read-write requests;
EventLoop, thread events processor;
As shown in fig. 6, obtaining the required first time T1 of server process connection request, specially:
The connection request that S601, record terminal are sent reaches the time point t1 of server;
S602, triggering Selector read message;
Message Opcode is read in S603, EventLoop triggering;
S604, EventLoop execute Message Opcode and finish and record time point t1 ';
S605, first time T1, T1=t1 '-t1.
As shown in fig. 7, after considering second time threshold, the flow of switch threads operating mode is specially:
S701, initialization thread operating mode;
The connection request that S702, record terminal are sent reaches the time point t1 of server;
S703, selector read the thread of connection request and allocation processing connection request;
S704, thread read and handle connection request;
The time point that S705, record thread processing connection request finish;
The connection request sum of S706, update total time-consuming and processing;
Average time needed for S707, calculation processing connection request is to obtain first time T1;
To obtain accurate first time T1, the time of thread process connection request is averaged, with total time-consuming divided by Connection request sum can obtain first time T1;
S708, judge whether first time T1 reaches first time threshold, if so then execute step S709, otherwise execute step Rapid S702;
S709, current thread operating mode duration is obtained:Second time T2;
If server for the first time processing connection request, also non-switch threads operating mode, then current thread operating mode be The preset thread work pattern of server can be single thread operating mode, can be multithreading operating mode, at this time T2=0;
S710, judge whether the second time T2 reaches second time threshold, if so then execute step S711, otherwise execute step Rapid S708;
S711, switching current thread operating mode;
S712, resetting total time-consuming, connection request sum and the second time T2.
As shown in figure 8, realizing above-mentioned flow with Java language, specially:
S801, initialization thread operating mode;
The connection request that S802, record terminal are sent reaches the time point of server;
S803, triggering Selector read message;
Message Opcode is read in S804, EventLoop triggering;
S805, EventLoop execute Message Opcode and finish and record time point;
The connection request sum of S806, update total time-consuming and processing;
Average time needed for S807, calculation processing connection request is to obtain first time T1;
S808, judge whether first time T1 reaches first time threshold, if so then execute step S809, otherwise execute step Rapid S802;
S809, current thread operating mode duration is obtained:Second time T2;
If server handles connection request for the first time, not yet switch current thread operating mode, then current thread Working mould Formula is the preset thread work pattern of server, can be single thread operating mode, can be multithreading operating mode, at this time then T2= 0;
S810, judge whether the second time T2 reaches second time threshold, if so then execute step S811, otherwise execute step Rapid S808;
S811, switching current thread operating mode;
S812, resetting total time-consuming, connection request sum and the second time T2.
Initialization thread operating mode in step S701 or step S801, including setting number of threads, first time threshold Value and second time threshold.When thread work pattern only has two kinds of single thread operating mode and multithreading operating mode, setting Number of threads is that the Thread Count of multithreading operating mode dispatching is arranged;When thread work pattern includes single thread Working mould Formula, the first multithreading operating mode, the second multithreading operating mode, third multithreading operating mode and the 4th multithreading Working mould When formula, initialization thread operating mode includes number of threads I, the first time threshold that scheduling is arranged for the first multithreading operating mode Value I and second time threshold I, number of threads II, II and of first time threshold for the setting scheduling of the second multithreading operating mode Second time threshold II, for number of threads III, the first time threshold III and second of the setting scheduling of third multithreading operating mode Time threshold III, for number of threads IV, first time threshold IV and the second time of the setting scheduling of the 4th multithreading operating mode Threshold value IV;It is each more when the equal one multithreading operating mode of self-contained of the operating mode of each different threads number in server Number of threads, corresponding first time threshold and the corresponding second time threshold of the corresponding scheduling of thread work mode setting.
As shown in figure 9, in a kind of optional embodiment, the initialization flow of communication system is realized with Java, specially:
S901, server EventLoop main threads start Accept initializers, and initial work starts to execute;
S902, newly-built Selector receivers;
S903, Accept events are registered to Selector receivers;
S904, the relevant Connecting quantity of setting;
S905, initialization EventLoop thread relevant parameters complete initialization operation;
The relevant parameter initialized in this step includes:Number of threads, first time threshold and the second time threshold of scheduling Value etc.;
S906, EventLoop thread receive the time triggered of the Accept of Selector.
EventLoop is the event handler for being individually for Accept settings, the processor in step S901 and step S906 Single thread is run at the beginning, is only responsible for receiving the connection request of terminal.
Server after initialization can complete terminal access process and receive terminal data flow, when terminal accesses, The connection request that terminal is sent is specially access request, and thread reads and handle access request, specially executes following step successively Suddenly:Thread reads access request, and thread is that configuration file is arranged in access request, and thread receives access request.
As shown in Figure 10, terminal access process is specially:
S1001, initialization thread operating mode;
S1002, terminal initiate access request;
The sequence of step S1001 and step S1002 and not only limit and this, optionally, terminal first initiates the connection request, services Device reinitializes thread work pattern;Step S1002 is first carried out, then executes step S1001;
The access request that S1003, record terminal are sent reaches the time point of server;
Reception access request in this step only indicates that server receives the access request of terminal, is as server No that the terminal is allowed to access, there is no limit;If server allows the terminal to access, follow the steps below;
S1004, selector read the thread of access request and allocation processing access request;
S1005, thread read access request;
S1006, thread are that configuration file is arranged in access request;
In this step, server is that terminal access is got ready;
S1007, thread receive access request;
The time that S1008, record thread processing access request finish;
The access request sum of S1009, update total time-consuming and processing;
Average time needed for S1010, calculation processing access request is to obtain first time T1;
S1011, judge whether first time T1 reaches first time threshold, if so then execute step S1012, otherwise execute Step S1002;
S1012, current thread operating mode duration is obtained:Second time T2;
S1013, judge whether the second time T2 reaches second time threshold, if so then execute step S1014, otherwise execute Step S1011;
S1014, switching current thread operating mode;
S1015, resetting total time-consuming, access request sum and the second time T2, execute step S1001.
As shown in figure 11, in a kind of optional embodiment, terminal access process is realized by Java, specially:
S1101, initialization thread operating mode;
S1102, terminal initiate access request;
The sequence of step S1101 and step S1102 and not only limit and this, optionally, terminal first initiates the connection request, services Device reinitializes thread work pattern;Step S1102 is first carried out, then executes step S1101;
The access request that S1103, record terminal are sent reaches the time point of server;
Reception access request in this step only indicates that server receives the access request of terminal, is as server No that the terminal is allowed to be accessed, there is no limit;If the terminal is allowed to access, following steps are executed;
S1104, EventLoop execute Selector;
The Accept events of S1105, Selector trigger;
In this step, server has been carried out standby for terminal access;
S1106, server receive access request;
S1107, record server receive the time point after access request;
The access request sum of S1108, update total time-consuming and processing;
Average time needed for S1109, calculation processing access request is to obtain first time T1;
S1110, judge whether first time T1 reaches first time threshold, if so then execute step S1111, otherwise execute Step S1102;
S1111, the duration for obtaining current thread operating mode:Second time T2;
S1112, judge whether the second time T2 reaches second time threshold, if so then execute step S1113, otherwise execute Step S1110;
S1113, switching current thread operating mode;
In this step, if switching current thread operating mode, the thread work being replaced is handled with new thread operating mode The operation that operation mode does not complete;If not switching current thread operating mode, continue with after the completion of current thread operating mode Continuous operation;
S1114, resetting total time-consuming, access request sum and the second time T2, execute step S1101.
When server receiving terminal data, thread reads and handles connection request, specially executes following steps successively:Line Journey reads connection request, and thread allows terminal to be written and read operation in the server, and thread receives the data that terminal is sent.
As shown in figure 12, the flow of server reception data is specific as follows:
S1201, initialization thread operating mode;
The connection request that S1202, record terminal are sent reaches the time point of server;
S1203, selector read the thread of connection request and allocation processing connection request;
S1204, thread read connection request;
S1205, thread allow terminal to be written and read operation in the server;
S1206, thread receive the data that terminal is sent;
S1207, record thread receive the time that data finish;
The connection request sum of S1208, update total time-consuming and processing;
Average time needed for S1209, calculation processing connection request is to obtain first time T1;
S1210, judge whether first time T1 reaches first time threshold, if so then execute step S1211, otherwise execute Step S1202;
S1211, the duration for obtaining current thread operating mode:Second time T2;
S1212, judge whether the second time T2 reaches second time threshold, if so then execute step S1213, otherwise execute Step S1210;
S1213, switching current thread operating mode;
S1214, resetting total time-consuming, connection request sum and the second time T2;
In the above flow, the mainly operation of server progress, wherein part operation corresponds to the operation of terminal, example Such as:Before server receives connection request, terminal initiates the connection request;When receiving the data that terminal is sent, terminal sends number simultaneously According to.
As shown in figure 13, it in a kind of optional embodiment, is realized by Java and receives terminal data flow, specially:
S1301, initialization thread operating mode;
The connection request that S1302, record terminal are sent reaches the time point of server;
S1303, Selector are that terminal carries out registration read-write event;
S1304, EventLoop execute Selector read-write operations;
S1305, the data that terminal is sent are received;
Time point after the data that S1306, record reception terminal are sent;
The connection request sum of S1307, update total time-consuming and processing;
Average time needed for S1308, calculation processing connection request is to obtain first time T1;
S1309, judge whether first time T1 reaches first time threshold, if so then execute step S1310, otherwise execute Step S1302;
S1310, the duration for obtaining current thread operating mode:Second time T2;
S1311, judge whether the second time T2 reaches second time threshold, if so then execute step S1312, otherwise execute Step S1309;
S1312, switching current thread operating mode;
S1313, resetting total time-consuming, connection request sum and the second time T2;
In the above flow, the mainly operation of server progress, wherein part operation corresponds to the operation of terminal, example Such as:Before server receives connection request, terminal is needed to initiate the connection request;When receiving the data that terminal is sent, need terminal same When transmission data.Switching current thread operating mode then opens new EventLoop and executes post-treatment operations, otherwise uses current EventLoop under thread work pattern executes post-treatment operations.
The second aspect of the embodiment of the present invention provides a kind of Internet of Things communication server, including:Mould is obtained at the first time Block, judgment module, handover module;First time acquisition module is sent out for obtaining server with current operation mode processing terminal The connection request required first time sent;Judgment module, for judging whether reach first time threshold at the first time, if Reach first time threshold at the first time, then starts handover module;Handover module, the current thread for switching server work Pattern.
Wherein, reflect the height of server and terminal communication efficiency at the first time, that is, reflect the communication efficiency of communication system Height:If larger at the first time, communication efficiency is the bottom of compared with;If smaller at the first time, communication efficiency is higher.If server Current thread operating mode is single thread operating mode, starts handover module, then server is switched to by single thread operating mode Multithreading operating mode;If the current thread operating mode of server is multithreading operating mode, starts handover module, then service Device switches to single thread operating mode by multithreading operating mode.
This communication server can be according to the traffic load amount of terminal in single thread operating mode and multithreading operating mode Between flexibly switch, improve server process connection request ability, keep the communication of server and terminal more efficient.
In a kind of optional embodiment, judgment module, be additionally operable to judge current thread operating mode duration whether Reach second time threshold;If reaching first time threshold at the first time, and the duration of current thread operating mode reaches Second time threshold then starts handover module.
Further include initialization module, initialization module, for number of threads, first to be arranged in a kind of optional embodiment Time threshold and second time threshold.
Further include terminal AM access module and data reception module in a kind of optional embodiment;Terminal AM access module, is used for The access request of receiving terminal;Data reception module, the data for receiving terminal transmission;First time in server obtains Module runs a terminal AM access module institute for obtaining server when terminal AM access module is run with current operation mode The first time needed;When data reception module is run, data are run with current operation mode for obtaining server Receiving module required first time.
The third aspect of the embodiment of the present invention, provides a kind of Internet of Things network communication system, including server, and server is this hair The server that bright second aspect is provided.
It should be understood that the invention is not limited in the flow and structure that are described above and are shown in the accompanying drawings, And various modifications and changes may be made without departing from the scope thereof.The scope of the present invention is only limited by the attached claims System.

Claims (10)

1. a kind of Internet of Things communication means, which is characterized in that it is applied to server, including:
Obtain the required first time T1 of connection request sent with current thread operating mode processing terminal;
Judge whether the first time T1 reaches first time threshold, if the first time T1 reaches the first time threshold Value, then switch the current thread operating mode.
2. Internet of Things communication means according to claim 1, which is characterized in that the first time T1 reaches described first After time threshold, before the switching current thread operating mode, further include:
Judge whether the duration of the current thread operating mode reaches second time threshold;
If the duration of the current thread operating mode has reached the second time threshold, switch the current thread Operating mode.
3. Internet of Things communication means according to claim 2, which is characterized in that the acquisition is with current thread operating mode Further include initialization thread operating mode before the required first time T1 of connection request that processing terminal is sent, it is described initial It includes setting number of threads, the first time threshold and the second time threshold to change thread work pattern.
4. Internet of Things communication means according to any one of claim 1 to 3, which is characterized in that obtain with current thread The required first time T1 of connection request that operating mode processing terminal is sent, specially:
Record the time point t1 that the connection request that terminal is sent reaches server;
Selector reads the thread of connection request described in the connection request and allocation processing;
Thread reads and handles the connection request;
Record the time t1 ' that connection request described in the thread process finishes;
The first time T1, T1=t1 '-t1.
5. Internet of Things communication means according to claim 4, which is characterized in that when terminal accesses, the thread is read And the connection request is handled, specially:
The connection request that terminal is sent is specially access request;
The thread reads the access request;
The thread is that configuration file is arranged in the access request;
The thread receives the access request;
When receiving terminal data, the thread reads and handles the connection request, specially:
The thread reads the connection request;
The thread allows terminal to be written and read operation in the server;
The thread receives the data that terminal is sent.
6. a kind of Internet of Things communication server, which is characterized in that including:First time acquisition module, judgment module, switching mould Block;
The first time acquisition module, the connection request institute sent with current operation mode processing terminal for obtaining server The first time needed;
The judgment module, for judging whether the first time reaches first time threshold, if the first time reaches The first time threshold then starts the handover module;
The handover module is used for the current thread operating mode of switching server.
7. the Internet of Things communication server according to claim 6, which is characterized in that the judgment module is additionally operable to judge Whether the duration of the current thread operating mode reaches second time threshold;If the first time reaches described first Time threshold, and the duration of the current thread operating mode reach the second time threshold, then start the switching Module.
8. the Internet of Things communication server according to claim 7, which is characterized in that further include initialization module, it is described first Beginningization module, for number of threads, the first time threshold and the second time threshold to be arranged.
9. the Internet of Things communication server according to any one of claim 6 to 8, which is characterized in that further include that terminal connects Enter module and data reception module;
The terminal AM access module is used for the access request of receiving terminal;
The data reception module, the data for receiving terminal transmission;
The first time acquisition module, when the terminal AM access module is run, for obtaining server with work at present mould The formula operation primary terminal AM access module required first time;When the data reception module is run, for obtaining Server runs the primary data reception module required first time with current operation mode.
10. a kind of Internet of Things network communication system, including server, which is characterized in that the server is to appoint in claim 6 to 8 Server described in one.
CN201810028886.9A 2018-01-12 2018-01-12 Internet of things communication method, server and system Active CN108337295B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810028886.9A CN108337295B (en) 2018-01-12 2018-01-12 Internet of things communication method, server and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810028886.9A CN108337295B (en) 2018-01-12 2018-01-12 Internet of things communication method, server and system

Publications (2)

Publication Number Publication Date
CN108337295A true CN108337295A (en) 2018-07-27
CN108337295B CN108337295B (en) 2022-09-23

Family

ID=62924267

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810028886.9A Active CN108337295B (en) 2018-01-12 2018-01-12 Internet of things communication method, server and system

Country Status (1)

Country Link
CN (1) CN108337295B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114338756A (en) * 2021-11-11 2022-04-12 北京蜂云科创信息技术有限公司 Method and system for intelligent networking high-concurrency communication of commercial vehicle

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1540508A (en) * 2003-04-24 2004-10-27 �Ҵ���˾ Dynamic switching of multiline range processor between single line range and complicated multiline range mode
US20050022196A1 (en) * 2000-04-04 2005-01-27 International Business Machines Corporation Controller for multiple instruction thread processors
CN101681260A (en) * 2007-06-20 2010-03-24 富士通株式会社 Arithmetic unit
CN106371976A (en) * 2016-08-31 2017-02-01 福建天晴数码有限公司 Method and system for monitoring thread by client and Web server

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050022196A1 (en) * 2000-04-04 2005-01-27 International Business Machines Corporation Controller for multiple instruction thread processors
CN1540508A (en) * 2003-04-24 2004-10-27 �Ҵ���˾ Dynamic switching of multiline range processor between single line range and complicated multiline range mode
CN101681260A (en) * 2007-06-20 2010-03-24 富士通株式会社 Arithmetic unit
CN106371976A (en) * 2016-08-31 2017-02-01 福建天晴数码有限公司 Method and system for monitoring thread by client and Web server

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114338756A (en) * 2021-11-11 2022-04-12 北京蜂云科创信息技术有限公司 Method and system for intelligent networking high-concurrency communication of commercial vehicle
CN114338756B (en) * 2021-11-11 2024-03-08 北京蜂云科创信息技术有限公司 Method and system for intelligent network high concurrency communication of commercial vehicle

Also Published As

Publication number Publication date
CN108337295B (en) 2022-09-23

Similar Documents

Publication Publication Date Title
CN102035884B (en) Cloud storage system and data deployment method thereof
CN103443770B (en) Terminal installation, process management method and process supervisory program
Mosberger et al. Making paths explicit in the Scout operating system
TWI489391B (en) Method, computer program, and computer readable medium for scheduling in a multicore architecture
JP5439219B2 (en) Message delivery system and message delivery method
CA2194520C (en) Operation right interlinking method and cooperative working method for shared application programs
US20130318257A1 (en) Device and method of simultaneous data transmission service over heterogeneous networks
EP3588852B1 (en) Method, apparatus and system for managing network slice instance
CN106161076B (en) Virtual network function extended method and device
WO2015131671A1 (en) Target resource occupancy handling method and device
KR100649713B1 (en) Method for hierarchical system configuration and integrated scheduling to provide multimedia streaming service on a two-level double cluster system
KR102159045B1 (en) How to trigger network policy updates, management function entities and core network devices
US8780730B2 (en) Load-balancing gateways
Sachs et al. GRACE: A hierarchical adaptation framework for saving energy
CN108337295A (en) A kind of Internet of Things communication means, server and system
CN115858083A (en) Container CPU resource scheduling and isolating method and device, storage medium and electronic equipment
RU2006107971A (en) PLATFORM FOR UNLOCKING AND USING WEB SERVICES
JP2014520316A (en) Traffic control method and traffic control apparatus
WO2014076960A1 (en) Control device, control method and control system
CN105069024B (en) Distributed file system write access method towards parallel data acquisition
CN104079398B (en) A kind of data communications method, apparatus and system
CN102664892B (en) Method and service nodes for automatic pulldown content dispatching
CN102812445A (en) Hierarchical Multi-core Processor, Multi-core Processor System, And Control Program
CN110650546A (en) File transmission method, device, storage medium and terminal
CN102148741B (en) Method and system for reallocating loads as well as calling method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CB03 Change of inventor or designer information

Inventor after: Zhang Baoxin

Inventor before: Zhang Baoxin

CB03 Change of inventor or designer information