CN107276857A - A kind of method and device for monitoring flow - Google Patents
A kind of method and device for monitoring flow Download PDFInfo
- Publication number
- CN107276857A CN107276857A CN201710701684.1A CN201710701684A CN107276857A CN 107276857 A CN107276857 A CN 107276857A CN 201710701684 A CN201710701684 A CN 201710701684A CN 107276857 A CN107276857 A CN 107276857A
- Authority
- CN
- China
- Prior art keywords
- request
- client
- monitoring
- read
- write
- 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.)
- Pending
Links
- 238000012544 monitoring process Methods 0.000 title claims abstract description 84
- 238000000034 method Methods 0.000 title claims abstract description 35
- 230000005540 biological transmission Effects 0.000 claims description 3
- 230000008520 organization Effects 0.000 claims 7
- 238000012545 processing Methods 0.000 abstract description 35
- 238000012806 monitoring device Methods 0.000 abstract description 3
- 230000000694 effects Effects 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 5
- 238000007619 statistical method Methods 0.000 description 3
- 238000007726 management method Methods 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 206010033799 Paralysis Diseases 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/08—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/14—Network analysis or design
- H04L41/142—Network analysis or design using statistical or mathematical methods
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/12—Avoiding congestion; Recovering from congestion
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Environmental & Geological Engineering (AREA)
- Physics & Mathematics (AREA)
- Algebra (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Mathematical Physics (AREA)
- Probability & Statistics with Applications (AREA)
- Pure & Applied Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明公开了一种监测流量的方法,所述方法包括:接收客户端发送的请求;判断所述请求是否为读写请求;若是,则通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构。该方法通过为客户端提供对应的存储结构,同时对发送的请求进行判断,为读写请求提供了专用的处理线程,进而监测读写流量数据,并将流量数据和所述请求存储至与所述客户端对应的存储结构。方便了对客户端的读写请求的流量数据的管理,同时为以后对客户端的读写请求的流量数据进行控制,实现流量限制提供了基础。相应地,本发明公开的一种监测流量的装置,也同样具有上述技术效果。
The invention discloses a method for monitoring traffic, the method comprising: receiving a request sent by a client; judging whether the request is a read-write request; if so, performing traffic monitoring on the request through a read-write request processing thread, And store the monitored traffic data and the request in a storage structure corresponding to the client. This method provides a corresponding storage structure for the client, and at the same time judges the sent request, provides a dedicated processing thread for the read and write request, and then monitors the read and write flow data, and stores the flow data and the request in the The storage structure corresponding to the above client. It facilitates the management of the traffic data of the client's read and write requests, and at the same time provides a basis for controlling the traffic data of the client's read and write requests in the future and realizing traffic restrictions. Correspondingly, a flow monitoring device disclosed in the present invention also has the above-mentioned technical effects.
Description
技术领域technical field
本发明涉及分布式存储系统的流量监测,更具体地说,涉及一种监测流量的方法及装置。The invention relates to flow monitoring of a distributed storage system, more specifically, to a method and device for monitoring flow.
背景技术Background technique
随着计算机技术以及互联网行业的迅猛发展,集群型的计算机网络已经趋于成熟,其中的共享资源也随之日益增加。而网络文件系统(NFS)作为一种在网络环境下共享数据的方式,大大方便了用户对于共享资源的使用。网络文件系统(NFS)允许一个系统在网络上与他人共享目录和文件,用户可以像访问本地文件一样访问远端系统上的文件。网络文件系统(NFS)因其优异的稳定性和可扩展性在分布式存储领域的各业务场景中得到了广泛的应用。With the rapid development of computer technology and the Internet industry, the cluster computer network has become mature, and the shared resources in it are also increasing. The Network File System (NFS), as a way of sharing data in a network environment, greatly facilitates the use of shared resources by users. Network File System (NFS) allows a system to share directories and files with others on the network, and users can access files on remote systems as if they were accessing local files. Network File System (NFS) has been widely used in various business scenarios in the field of distributed storage because of its excellent stability and scalability.
目前,在分布式存储领域中,通常通过网络文件系统(NFS)服务向所有用户提供数据服务,所以在业务高峰阶段,高压力容易造成网络拥堵和集群服务压力过大,用户请求无法及时处理,造成请求积压或延迟,严重时可能导致服务系统故障或者整个服务系统的瘫痪。由于各用户的流量使用行为在服务端未进行记录,所以服务管理者在高峰业务时段对于网络拥堵现象束手无策,无法及时解决拥堵现象。At present, in the field of distributed storage, data services are usually provided to all users through the network file system (NFS) service. Therefore, during the peak period of business, high pressure is likely to cause network congestion and excessive pressure on cluster services, and user requests cannot be processed in time. It causes a backlog or delay of requests, which may lead to service system failure or paralysis of the entire service system in severe cases. Since the traffic usage behavior of each user is not recorded on the server side, service managers are helpless to deal with network congestion during peak business hours and cannot solve the congestion in time.
因此,如何实时监测用户的流量使用行为,分析管理流量数据,进而实现精准检测控制流量,是本领域技术人员需要解决的问题。Therefore, how to monitor users' traffic usage behavior in real time, analyze and manage traffic data, and then realize accurate detection and control of traffic is a problem to be solved by those skilled in the art.
发明内容Contents of the invention
本发明的目的在于提供一种监测流量的方法及装置,以实现实时监测用户的流量使用行为,分析管理流量数据。The purpose of the present invention is to provide a method and device for monitoring traffic, so as to realize real-time monitoring of traffic usage behavior of users, and analyze and manage traffic data.
为实现上述目的,本发明实施例提供了如下技术方案:In order to achieve the above object, the embodiment of the present invention provides the following technical solutions:
一种监测流量的方法,包括:A method of monitoring traffic, comprising:
S11、接收客户端发送的请求;S11. Receive the request sent by the client;
S12、判断所述请求是否为读写请求;S12. Determine whether the request is a read-write request;
S13、若是,则通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构。S13. If yes, monitor the flow of the request through the read and write request processing thread, and store the monitored flow data and the request in a storage structure corresponding to the client.
其中,所述接收客户端发送的请求之后,还包括:Wherein, after receiving the request sent by the client, it also includes:
判断所述客户端是否是首次发送请求;judging whether the client is sending the request for the first time;
若是,则创建与所述客户端对应的存储结构,并执行S12;If yes, create a storage structure corresponding to the client, and execute S12;
若否,则执行S12。If not, execute S12.
其中,所述判断所述客户端是否是首次发送请求,包括:Wherein, the judging whether the client sends the request for the first time includes:
根据发送所述请求的客户端IP判断所述客户端是否是首次发送请求。Determine whether the client sends the request for the first time according to the IP of the client sending the request.
其中,所述通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构,包括:Wherein, the flow monitoring of the request through the read-write request processing thread, and storing the monitored flow data and the request in a storage structure corresponding to the client includes:
若所述请求为读请求,则通过与所述客户端对应的读写请求处理线程对所述读请求进行流量监测,并将监测的读流量数据和所述读请求存储至与所述客户端对应的读请求存储结构;If the request is a read request, the read and write request processing thread corresponding to the client will monitor the flow of the read request, and store the monitored read flow data and the read request to the client. The corresponding read request storage structure;
若所述请求为写请求,则通过与所述客户端对应的读写请求处理线程对所述写请求进行流量监测,并将监测的写流量数据和所述写请求存储至与所述客户端对应的写请求存储结构。If the request is a write request, monitor the flow of the write request through the read and write request processing thread corresponding to the client, and store the monitored write flow data and the write request to the client The corresponding write request storage structure.
其中,所述若是,通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构之后,还包括:Wherein, if the said yes, monitor the traffic of the request through the read and write request processing thread, and store the monitored traffic data and the request in the storage structure corresponding to the client, it also includes:
通过流量监测线程和定时器,以秒为单位统计所有客户端的总流量值,并进行存储;Through the flow monitoring thread and timer, the total flow value of all clients is counted in seconds and stored;
若所述总流量值超过预先设置的阈值,则进行报警。If the total flow value exceeds a preset threshold, an alarm is issued.
一种监测流量的装置,包括:A device for monitoring flow comprising:
接收模块,用于接收客户端发送的请求;The receiving module is used to receive the request sent by the client;
第一判断模块,用于判断所述请求是否为读写请求;A first judging module, configured to judge whether the request is a read-write request;
监测模块,用于当所述请求为读写请求时,通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构。A monitoring module, configured to monitor the flow of the request through a read-write request processing thread when the request is a read-write request, and store the monitored flow data and the request in a storage structure corresponding to the client .
其中,还包括:Among them, also include:
第二判断模块,用于判断所述客户端是否是首次发送请求;The second judging module is used to judge whether the client sends a request for the first time;
创建模块,用于当所述客户端首次发送请求时,创建与所述客户端对应的存储结构。A creating module, configured to create a storage structure corresponding to the client when the client sends a request for the first time.
其中,所述第二判断模块具体用于:根据发送所述请求的客户端IP判断所述客户端是否是首次发送请求。Wherein, the second judging module is specifically configured to: judge whether the client sends the request for the first time according to the IP of the client sending the request.
其中,所述监测模块包括:Wherein, the monitoring module includes:
第一监测单元,用于当所述请求为读请求时,通过与所述客户端对应的读写请求处理线程对所述读请求进行流量监测;A first monitoring unit, configured to monitor the flow of the read request through a read and write request processing thread corresponding to the client when the request is a read request;
第一存储单元,用于将监测的读流量数据和所述读请求存储至与所述客户端对应的读请求存储结构;A first storage unit, configured to store the monitored read traffic data and the read request in a read request storage structure corresponding to the client;
第二监测单元,用于当所述请求为写请求时,通过与所述客户端对应的读写请求处理线程对所述写请求进行流量监测;The second monitoring unit is configured to monitor the flow of the write request through the read and write request processing thread corresponding to the client when the request is a write request;
第二存储单元,用于将监测的写流量数据和所述写请求存储至与所述客户端对应的写请求存储结构。The second storage unit is configured to store the monitored write traffic data and the write request in a write request storage structure corresponding to the client.
其中,还包括:Among them, also include:
总流量值监测模块,用于通过流量监测线程和定时器,以秒为单位统计所有客户端的总流量值,并进行存储;The total flow value monitoring module is used to count and store the total flow value of all clients in seconds through the flow monitoring thread and timer;
报警模块,用于当所述总流量值超过预先设置的阈值时,进行报警。An alarm module, configured to issue an alarm when the total flow value exceeds a preset threshold.
通过以上方案可知,本发明实施例提供的一种监测流量的方法,所述方法包括:接收客户端发送的请求;判断所述请求是否为读写请求;若是,则通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构。如此服务端便可以实时监测客户端的读写请求而产生的流量数据,并进行统计分析,为管理控制流量提供了有效依据。It can be seen from the above scheme that the embodiment of the present invention provides a method for monitoring traffic, the method includes: receiving the request sent by the client; judging whether the request is a read-write request; Traffic monitoring is performed on the request, and the monitored traffic data and the request are stored in a storage structure corresponding to the client. In this way, the server can monitor the traffic data generated by the client's read and write requests in real time, and perform statistical analysis, which provides an effective basis for managing and controlling traffic.
可见,该方法通过为每个客户端提供对应的存储结构,同时对发送的请求进行判断,为读写请求提供了专用的处理线程,进而监测读写流量数据,并将流量数据和所述请求存储至与所述客户端对应的存储结构。通过对每个客户端的读写流量数据进行监测统计,方便了对每个客户端的读写请求的流量数据的管理,同时为以后对每个客户端的读写请求的流量数据进行控制,实现流量限制提供了基础。It can be seen that this method provides a corresponding storage structure for each client, and at the same time judges the sent request, provides a dedicated processing thread for the read and write request, and then monitors the read and write traffic data, and compares the traffic data with the request stored in a storage structure corresponding to the client. By monitoring and counting the read and write flow data of each client, it is convenient to manage the flow data of each client's read and write requests, and at the same time control the flow data of each client's read and write requests in the future to achieve flow limitation provides the basis.
相应地,本发明实施例提供的一种监测流量的装置,也同样具有上述技术效果。Correspondingly, a device for monitoring flow provided by an embodiment of the present invention also has the above-mentioned technical effect.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1为本发明实施例公开的一种监测流量的方法流程图;Fig. 1 is a flow chart of a method for monitoring flow disclosed by an embodiment of the present invention;
图2为图1公开的一种监测流量的方法中的读写请求分类结构示意图;FIG. 2 is a schematic diagram of a classification structure of read and write requests disclosed in FIG. 1 in a method for monitoring traffic;
图3为本发明实施例中公开的另一种监测流量的方法流程图;FIG. 3 is a flow chart of another method for monitoring flow disclosed in the embodiment of the present invention;
图4为图3公开的一种监测流量的方法中的读写请求分类结构示意图;FIG. 4 is a schematic diagram of a classification structure of read and write requests disclosed in FIG. 3 in a method for monitoring traffic;
图5为本发明实施例公开的一种监测流量的装置示意图。Fig. 5 is a schematic diagram of a flow monitoring device disclosed in an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
本发明实施例公开了一种监测流量的方法及装置,以实现实时监测用户的流量使用行为,分析管理流量数据。The embodiment of the present invention discloses a method and device for monitoring traffic, so as to realize real-time monitoring of user traffic usage behavior and analyze and manage traffic data.
参见图1,本发明实施例提供的一种监测流量的方法,包括:Referring to Figure 1, a method for monitoring traffic provided by an embodiment of the present invention includes:
S11、接收客户端发送的请求;S11. Receive the request sent by the client;
具体的,在分布式存储领域中,当客户端需要访问网络文件时,便会向服务端发送请求。通常情况下,所述请求以报文的形式进行传输,所以当服务端接收所述请求后,需要对所述请求进行解析处理。Specifically, in the field of distributed storage, when a client needs to access a network file, it will send a request to the server. Usually, the request is transmitted in the form of a message, so after receiving the request, the server needs to analyze and process the request.
S12、判断所述请求是否为读写请求;S12. Determine whether the request is a read-write request;
具体的,当服务端将所述请求解析完成后,会获得所述请求的具体内容、发送端以及传输路径等信息,进而服务端根据所述请求的具体内容判断所述请求是否为读写请求,以便将读写请求与创建、转移等请求区别处理。Specifically, after the server parses the request, it will obtain information such as the specific content of the request, the sender, and the transmission path, and then the server will judge whether the request is a read-write request based on the specific content of the request. , so that read and write requests are handled differently from requests such as creation and transfer.
S13、若是,则通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构;S13. If yes, monitor the flow of the request through the read and write request processing thread, and store the monitored flow data and the request in a storage structure corresponding to the client;
需要说明的是,由于服务端为读写请求分配了专用的线程池,所以在判断所述请求为读写请求后,服务端会将所述请求通过读写请求处理线程进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构。It should be noted that since the server allocates a dedicated thread pool for read and write requests, after judging that the request is a read and write request, the server will monitor the flow of the request through the read and write request processing thread, and The monitored traffic data and the request are stored in a storage structure corresponding to the client.
参见图2,图2为本实施例中读写请求分类结构示意图,所述通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构,包括:Referring to FIG. 2, FIG. 2 is a schematic diagram of the classification structure of read and write requests in this embodiment. The read and write request processing thread monitors the flow of the request, and stores the monitored flow data and the request to the client. The storage structure corresponding to the end, including:
若所述请求为读请求,则通过与所述客户端对应的读写请求处理线程对所述读请求进行流量监测,并将监测的读流量数据和所述读请求存储至与所述客户端对应的读请求存储结构;If the request is a read request, the read and write request processing thread corresponding to the client will monitor the flow of the read request, and store the monitored read flow data and the read request to the client. The corresponding read request storage structure;
若所述请求为写请求,则通过与所述客户端对应的读写请求处理线程对所述写请求进行流量监测,并将监测的写流量数据和所述写请求存储至与所述客户端对应的写请求存储结构。If the request is a write request, monitor the flow of the write request through the read and write request processing thread corresponding to the client, and store the monitored write flow data and the write request to the client The corresponding write request storage structure.
具体的,在本实施例中,服务端为每个客户端都分配了用于处理读写请求的线程池,即每个客户端都具有对应的用于处理读写请求的线程池;并且服务端为每个客户端提供了用于存储读写请求相关数据的存储结构,即每个客户端具有对应的存储结构。Specifically, in this embodiment, the server allocates a thread pool for processing read and write requests for each client, that is, each client has a corresponding thread pool for processing read and write requests; and the service The terminal provides each client with a storage structure for storing data related to read and write requests, that is, each client has a corresponding storage structure.
当服务端接收到客户端发送的读写请求后,会自动将所述请求交由客户端对应的线程池中的线程进行流量监测和流量数据存储;如果所述请求为读请求,那么相关线程对其进行流量监测时,会自动将监测而得的流量数据和所述读请求存储至与客户端对应的读请求存储结构。如果所述请求为写请求,那么相关线程对其进行流量监测时,会自动将监测而得的流量数据和所述写请求存储至与客户端对应的写请求存储结构。即系统自动将同一客户端的读请求和写请求的流量数据分别存储,以便日后对读流量数据和写流量数据的统计分析和管理。当然,存储结构也存储了对应的客户端信息,包括IP地址、物理地址等信息。When the server receives the read and write request sent by the client, it will automatically hand over the request to the thread in the thread pool corresponding to the client for traffic monitoring and traffic data storage; if the request is a read request, then the relevant thread When the traffic is monitored, the monitored traffic data and the read request will be automatically stored in the read request storage structure corresponding to the client. If the request is a write request, when the relevant thread monitors its traffic, it will automatically store the monitored traffic data and the write request in the write request storage structure corresponding to the client. That is to say, the system automatically stores the traffic data of read requests and write requests of the same client separately, so as to facilitate statistical analysis and management of read traffic data and write traffic data in the future. Of course, the storage structure also stores corresponding client information, including information such as IP addresses and physical addresses.
S14、若否,则通过其他线程进行处理。S14. If not, process through other threads.
具体的,如果所述请求为其他请求,例如:创建、转移请求等,服务端会自动通过其他线程进行相关处理,并将处理结果及时返回至客户端。Specifically, if the request is other requests, such as creation and transfer requests, etc., the server will automatically perform related processing through other threads, and return the processing results to the client in time.
可见,本实施例提供的一种监测流量的方法,该方法在接收客户端发送的请求后,对发送的请求类型进行判断,为读写请求提供了专用的处理线程,进而监测读写流量数据,并且将读请求的流量数据和写请求的流量数据分别存储至对应的读请存储结构和写请求存储结构。如此通过对每个客户端的读写流量数据分别监测、存储,方便了对每个客户端的读写请求的流量数据管理,同时为以后对每个客户端的读写请求的流量数据进行控制,实现流量限制提供了基础。It can be seen that this embodiment provides a method for monitoring traffic. After receiving the request sent by the client, the method judges the type of the sent request, provides a dedicated processing thread for the read and write requests, and then monitors the read and write traffic data. , and store the traffic data of the read request and the traffic data of the write request in the corresponding read request storage structure and write request storage structure respectively. In this way, by monitoring and storing the read and write flow data of each client separately, it is convenient to manage the flow data of each client's read and write requests, and at the same time control the flow data of each client's read and write requests in the future to realize the flow Limits provide the basis.
参见图3,本发明实施例提供的另一种监测流量的方法,包括:Referring to Fig. 3, another method for monitoring traffic provided by an embodiment of the present invention includes:
S31、接收客户端发送的请求;S31. Receive a request sent by the client;
S32、判断客户端是否是首次发送请求;S32. Determine whether the client sends the request for the first time;
需要说明的是,在服务端接收客户端发送的请求后,首先对所述请求进行解析,获得发送所述请求的客户端IP、所述请求的具体内容等信息,进而服务端会根据发送所述请求的客户端信息判断所述客户端是否是首次发送请求,即判断所述客户端是否是首次访问该服务端。It should be noted that after the server receives the request sent by the client, it first analyzes the request to obtain information such as the IP of the client that sent the request and the specific content of the request, and then the server will Judging whether the client is sending the request for the first time based on the client information of the request, that is, judging whether the client is accessing the server for the first time.
在本实施例中,所述判断所述客户端是否是首次发送请求,包括:In this embodiment, the judging whether the client sends the request for the first time includes:
根据发送所述请求的客户端IP判断所述客户端是否是首次发送请求。Determine whether the client sends the request for the first time according to the IP of the client sending the request.
具体的,由于服务端为每个客户端提供了存储客户端信息和读写流量数据的存储结构,所以对于有过访问历史记录的客户端的信息,例如:IP地址等,已经存储于该服务端中。当某台客户端首次访问该服务端时,服务端获取该客户端的IP地址,进而在系统中查找相对应的IP地址,若查找不到相对应的IP地址,即判断该客户端属于新增加的客户端,是首次发送请求。当然,也可以根据客户端的物理地址判断客户端是否是首次发送请求,详细过程与使用IP地址进行判断类似,故在此不再赘述。Specifically, since the server provides each client with a storage structure for storing client information and reading and writing traffic data, the information of clients with access history records, such as IP addresses, etc., have been stored in the server middle. When a client accesses the server for the first time, the server obtains the IP address of the client, and then searches for the corresponding IP address in the system. If the corresponding IP address cannot be found, it is judged that the client is newly added. The client is sending a request for the first time. Of course, it is also possible to determine whether the client is sending a request for the first time according to the physical address of the client. The detailed process is similar to the judgment using the IP address, so it will not be repeated here.
S33、若是,则创建与所述客户端对应的存储结构,并执行S34;若否,则执行S34;;S33. If yes, create a storage structure corresponding to the client, and execute S34; if not, execute S34;
具体的,在根据发送所述请求的客户端IP判断所述客户端是首次发送请求后,服务端为首次发送请求的客户端创建对应的存储结构,用来存储该客户端的读写请求、读写流量数据以及该客户端的信息等内容。Specifically, after judging that the client sends the request for the first time according to the IP of the client that sent the request, the server creates a corresponding storage structure for the client that sends the request for the first time to store the client's read and write requests, read Write traffic data and information about the client, etc.
S34、判断所述请求是否为读写请求;S34. Determine whether the request is a read-write request;
S35、若是,则通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构;S35. If so, monitor the flow of the request through the read and write request processing thread, and store the monitored flow data and the request in a storage structure corresponding to the client;
S36、若否,则通过其他线程进行处理。S36. If not, process through other threads.
具体的,如果所述客户端是首次发送请求,那么为其创建相应的存储结构后,进而需要判断该客户端发送的请求类型是否为读写请求;若为读写请求,则通过读写请求处理线程进行相关处理。Specifically, if the client is sending a request for the first time, after creating a corresponding storage structure for it, it is necessary to determine whether the request type sent by the client is a read-write request; if it is a read-write request, then pass the read-write request The processing thread performs related processing.
需要说明的是,由于服务端为读写请求分配了专用的线程池,所以在判断所述请求为读写请求后,服务端将所述请求通过读写请求处理线程进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构。It should be noted that since the server allocates a dedicated thread pool for read and write requests, after judging that the request is a read and write request, the server will monitor the traffic of the request through the read and write request processing thread, and will monitor The traffic data and the request are stored in a storage structure corresponding to the client.
参见图4,图4为本实施例中读写请求分类结构示意图,服务端在系统中为读写请求分配了专用的线程池,即该线程池中的线程用来处理所有客户端的读写请求。与上述实施例类似,本实施例也为每个客户端提供了对应的存储结构,包括读请求存储结构和写请求存储结构;读请求的流量数据和写请求的流量数据分别存储于读请求存储结构和写请求结构,即本实施例提供的客户端存储结构与上述实施例中的客户端存储结构相同。相较于上述实施例,在本实施例中,所有客户端共用读写请求处理线程,即服务端在系统中为所有客户端分配了用于处理读写请求的专用线程池。Referring to Fig. 4, Fig. 4 is a schematic diagram of the classification structure of read and write requests in this embodiment. The server allocates a dedicated thread pool for read and write requests in the system, that is, the threads in the thread pool are used to process the read and write requests of all clients . Similar to the above embodiment, this embodiment also provides each client with a corresponding storage structure, including a read request storage structure and a write request storage structure; the traffic data of the read request and the traffic data of the write request are stored in the read request storage The structure and write request structure, that is, the client storage structure provided by this embodiment is the same as the client storage structure in the foregoing embodiments. Compared with the above embodiment, in this embodiment, all clients share read and write request processing threads, that is, the server allocates a dedicated thread pool for processing read and write requests to all clients in the system.
具体的,当服务端收到客户端发送的读写请求后,服务端自动通过读写请求线程池中的空闲线程来进行流量监测,并将监测的流量数据和所述请求存储至与该客户端对应的存储结构。即本实施例中的用于处理读写请求的线程池并未与每个客户端对应,而是所有客户端共用同一线程池。当然,也可以将客户端按照数量或者其他信息进行划分,两两共用一个线程池或者三个、五个客户端共用一个线池,本实施例在此并不具体限定。Specifically, when the server receives the read and write request sent by the client, the server automatically monitors the traffic through the idle thread in the read and write request thread pool, and stores the monitored traffic data and the request to the The storage structure corresponding to the end. That is, the thread pool for processing read and write requests in this embodiment does not correspond to each client, but all clients share the same thread pool. Of course, the clients can also be divided according to the number or other information, and two clients share one thread pool, or three or five clients share one thread pool, which is not specifically limited in this embodiment.
可见,本实施例提供的一种监测流量的方法,该方法在接收客户端发送的请求后,首先判断发送端是否是首次发送请,若是,则对发送的请求类型进行判断;并为所有客户端的读写请求提供专用的处理线程,即所有客户端共用同一个线程池来处理读写请求;进而监测读写流量数据,并且将读请求的流量数据和写请求的流量数据分别存储至对应的读请存储结构和写请求存储结构。如此通过对每个客户端的读写流量数据分别监测、存储,方便了对每个客户端的读写请求的流量数据管理,同时为以后对每个客户端的读写请求的流量数据进行控制,实现流量限制提供了基础。It can be seen that in the method for monitoring traffic provided by this embodiment, after receiving the request sent by the client, the method first judges whether the sending end is sending the request for the first time, and if so, judges the type of request sent; Provide a dedicated processing thread for the read and write requests of the client, that is, all clients share the same thread pool to process the read and write requests; then monitor the read and write traffic data, and store the traffic data of the read request and the traffic data of the write request in the corresponding Read request storage structure and write request storage structure. In this way, by monitoring and storing the read and write flow data of each client separately, it is convenient to manage the flow data of each client's read and write requests, and at the same time control the flow data of each client's read and write requests in the future to realize the flow Limits provide the basis.
基于上述任意实施例,需要说明的是,在对每个客户端的读写流量数据进行实时监测时,服务端统计所有客户端的读写流量数据。Based on any of the above embodiments, it should be noted that when monitoring the read and write traffic data of each client in real time, the server counts the read and write traffic data of all clients.
具体的,所述若是,通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构之后,还包括:Specifically, if the said if, monitors the traffic of the request through the read and write request processing thread, and stores the monitored traffic data and the request in the storage structure corresponding to the client, it also includes:
通过流量监测线程和定时器,以秒为单位统计所有客户端的总流量值,并进行存储;Through the flow monitoring thread and timer, the total flow value of all clients is counted in seconds and stored;
若所述总流量值超过预先设置的阈值,则进行报警。If the total flow value exceeds a preset threshold, an alarm is issued.
服务端系统中具有专用于流量值统计的线程,配合定时器进行流量值的统计。以秒为单位更新所有客户端的读写流量值,并实时存储。基于对历史读写流量的统计分析,服务端预先设置了安全阈值,提示管理人员出现了网络拥堵现象。如果总流量值超过预先设置的安全阈值,那么系统会进行报警处理。管理人员便可以对某些客户端进行限流操作,减轻网络拥堵现象,避免系统崩溃。The server system has a dedicated thread for traffic value statistics, and it cooperates with timers to count traffic values. Update the read and write traffic values of all clients in seconds and store them in real time. Based on statistical analysis of historical read and write traffic, the server presets a security threshold to alert managers of network congestion. If the total flow value exceeds the preset safety threshold, the system will perform alarm processing. Administrators can limit the flow of certain clients to reduce network congestion and avoid system crashes.
基于上述任意实施例,在对每台客户端的读写请求进行流量监测,得到监测的流量数据后,也可以将该流量数据及时返回至客户端,以便用户及时知晓当前操作的流量数据。如果制定限流策略,对每台客户端进行限流,那么用户知晓已经使用的流量数据后,便可酌情减少,合理控制访问次数。Based on any of the above embodiments, after monitoring the flow of read and write requests of each client, and obtaining the monitored flow data, the flow data can also be returned to the client in time, so that the user can know the flow data of the current operation in time. If a flow-limiting strategy is formulated to limit the flow of each client, then after the user knows the flow data that has been used, he can reduce it as appropriate and reasonably control the number of visits.
下面对本发明实施例提供的一种监测流量的装置进行介绍,下文描述的一种监测流量的装置与上文描述的一种监测流量的方法可以相互参照。A device for monitoring flow rate provided by an embodiment of the present invention is introduced below. The device for monitoring flow rate described below and the method for monitoring flow rate described above may refer to each other.
参见图5,本发明实施例提供的一种监测流量的装置,包括:Referring to Figure 5, a flow monitoring device provided by an embodiment of the present invention includes:
接收模块501,用于接收客户端发送的请求;A receiving module 501, configured to receive a request sent by a client;
第一判断模块502,用于判断所述请求是否为读写请求;A first judging module 502, configured to judge whether the request is a read-write request;
监测模块503,用于当所述请求为读写请求时,通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构。The monitoring module 503 is configured to monitor the flow of the request through a read-write request processing thread when the request is a read-write request, and store the monitored flow data and the request in a storage corresponding to the client structure.
其中,还包括:Among them, also include:
第二判断模块,用于判断所述客户端是否是首次发送请求;The second judging module is used to judge whether the client sends a request for the first time;
创建模块,用于当所述客户端首次发送请求时,创建与所述客户端对应的存储结构。A creating module, configured to create a storage structure corresponding to the client when the client sends a request for the first time.
其中,所述第二判断模块具体用于:根据发送所述请求的客户端IP判断所述客户端是否是首次发送请求。Wherein, the second judging module is specifically configured to: judge whether the client sends the request for the first time according to the IP of the client sending the request.
其中,所述监测模块包括:Wherein, the monitoring module includes:
第一监测单元,用于当所述请求为读请求时,通过与所述客户端对应的读写请求处理线程对所述读请求进行流量监测;A first monitoring unit, configured to monitor the flow of the read request through a read and write request processing thread corresponding to the client when the request is a read request;
第一存储单元,用于将监测的读流量数据和所述读请求存储至与所述客户端对应的读请求存储结构;A first storage unit, configured to store the monitored read traffic data and the read request in a read request storage structure corresponding to the client;
第二监测单元,用于当所述请求为写请求时,通过与所述客户端对应的读写请求处理线程对所述写请求进行流量监测;The second monitoring unit is configured to monitor the flow of the write request through the read and write request processing thread corresponding to the client when the request is a write request;
第二存储单元,用于将监测的写流量数据和所述写请求存储至与所述客户端对应的写请求存储结构。The second storage unit is configured to store the monitored write traffic data and the write request in a write request storage structure corresponding to the client.
其中,还包括:Among them, also include:
总流量值监测模块,用于通过流量监测线程和定时器,以秒为单位统计所有客户端的总流量值,并进行存储;The total flow value monitoring module is used to count and store the total flow value of all clients in seconds through the flow monitoring thread and timer;
报警模块,用于当所述总流量值超过预先设置的阈值时,进行报警。An alarm module, configured to issue an alarm when the total flow value exceeds a preset threshold.
可见,本实施例提供的一种监测流量的装置,包括:接收模块、第一判断模块以及监测模块。首先由接收模块接收客户端发送请求;然后第一判断模块判断判断所述请求是否为读写请求;当所述请求为读写请求时,监测模块通过读写请求处理线程对所述请求进行流量监测,并将监测的流量数据和所述请求存储至与所述客户端对应的存储结构。如此各个模块之间分工合作,各司其职,共同实现了对每个客户端读写流量的实时监测;同时通过对每个客户端的读写流量数据进行监测统计,方便了对每个客户端的读写请求的管理,同时为以后对每个客户端的读写请求进行控制,实现流量限制提供了基础。It can be seen that the device for monitoring traffic provided by this embodiment includes: a receiving module, a first judging module, and a monitoring module. First, the receiving module receives the request sent by the client; then the first judging module judges whether the request is a read-write request; when the request is a read-write request, the monitoring module processes the request through the read-write request processing thread monitor, and store the monitored traffic data and the request in a storage structure corresponding to the client. In this way, the division of labor and cooperation among the various modules, each performing its own duties, jointly realize the real-time monitoring of the read and write traffic of each client; at the same time, through the monitoring and statistics of the read and write traffic data of each client, it is convenient The management of read and write requests also provides a basis for controlling the read and write requests of each client in the future and realizing traffic limitation.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。Each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other.
对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本发明。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710701684.1A CN107276857A (en) | 2017-08-16 | 2017-08-16 | A kind of method and device for monitoring flow |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710701684.1A CN107276857A (en) | 2017-08-16 | 2017-08-16 | A kind of method and device for monitoring flow |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107276857A true CN107276857A (en) | 2017-10-20 |
Family
ID=60077230
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710701684.1A Pending CN107276857A (en) | 2017-08-16 | 2017-08-16 | A kind of method and device for monitoring flow |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107276857A (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108737289A (en) * | 2018-06-27 | 2018-11-02 | 郑州云海信息技术有限公司 | A kind of storage load balance method and system |
CN110018781A (en) * | 2018-01-09 | 2019-07-16 | 阿里巴巴集团控股有限公司 | Disk flow control method, device and electronic equipment |
CN111899858A (en) * | 2020-07-29 | 2020-11-06 | 广州海鹚网络科技有限公司 | Hospital flow limiting method and device, computer equipment and storage medium |
CN112260955A (en) * | 2020-09-18 | 2021-01-22 | 苏州浪潮智能科技有限公司 | A hybrid read-write flow control method and device |
CN114143036A (en) * | 2021-11-04 | 2022-03-04 | 湖南天云软件技术有限公司 | Alarm method, device, device and computer storage medium |
CN114995768A (en) * | 2022-06-24 | 2022-09-02 | 杭州谐云科技有限公司 | A method and system for improving distributed storage performance in container scenarios |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102523290A (en) * | 2011-12-19 | 2012-06-27 | 成都市华为赛门铁克科技有限公司 | Data processing method, device and system |
US20140082129A1 (en) * | 2012-09-18 | 2014-03-20 | Netapp, Inc. | System and method for managing a system of appliances that are attached to a networked file system |
CN105245463A (en) * | 2014-07-09 | 2016-01-13 | 腾讯科技(深圳)有限公司 | Flow control method and device |
-
2017
- 2017-08-16 CN CN201710701684.1A patent/CN107276857A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102523290A (en) * | 2011-12-19 | 2012-06-27 | 成都市华为赛门铁克科技有限公司 | Data processing method, device and system |
US20140082129A1 (en) * | 2012-09-18 | 2014-03-20 | Netapp, Inc. | System and method for managing a system of appliances that are attached to a networked file system |
CN105245463A (en) * | 2014-07-09 | 2016-01-13 | 腾讯科技(深圳)有限公司 | Flow control method and device |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110018781A (en) * | 2018-01-09 | 2019-07-16 | 阿里巴巴集团控股有限公司 | Disk flow control method, device and electronic equipment |
CN108737289A (en) * | 2018-06-27 | 2018-11-02 | 郑州云海信息技术有限公司 | A kind of storage load balance method and system |
CN111899858A (en) * | 2020-07-29 | 2020-11-06 | 广州海鹚网络科技有限公司 | Hospital flow limiting method and device, computer equipment and storage medium |
CN111899858B (en) * | 2020-07-29 | 2024-07-26 | 广州海鹚网络科技有限公司 | Hospital flow limiting method and device, computer equipment and storage medium |
CN112260955A (en) * | 2020-09-18 | 2021-01-22 | 苏州浪潮智能科技有限公司 | A hybrid read-write flow control method and device |
CN112260955B (en) * | 2020-09-18 | 2022-11-11 | 苏州浪潮智能科技有限公司 | Hybrid read-write flow control method and device |
CN114143036A (en) * | 2021-11-04 | 2022-03-04 | 湖南天云软件技术有限公司 | Alarm method, device, device and computer storage medium |
CN114995768A (en) * | 2022-06-24 | 2022-09-02 | 杭州谐云科技有限公司 | A method and system for improving distributed storage performance in container scenarios |
CN114995768B (en) * | 2022-06-24 | 2024-11-08 | 杭州谐云科技有限公司 | A method and system for improving distributed storage performance in container scenarios |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107276857A (en) | A kind of method and device for monitoring flow | |
CN109064345B (en) | Message processing method, system and computer readable storage medium | |
US10681065B2 (en) | Network monitoring, detection, and analysis system | |
US8135979B2 (en) | Collecting network-level packets into a data structure in response to an abnormal condition | |
EP2563062B1 (en) | Long connection management apparatus and link resource management method for long connection communication | |
US7782793B2 (en) | Statistical trace-based methods for real-time traffic classification | |
CN103152352B (en) | A kind of perfect information security forensics monitor method based on cloud computing environment and system | |
CN107104840A (en) | A kind of daily record monitoring method, apparatus and system | |
CN106953758A (en) | A dynamic configuration management method and system based on Nginx server | |
US12229032B1 (en) | Evaluating machine and process performance in distributed system | |
WO2019041738A1 (en) | Client resource obtaining method and apparatus, terminal device, and storage medium | |
US10320688B2 (en) | Aggregating flows by endpoint category | |
CN109379390B (en) | Network security baseline generation method based on full flow | |
EP3554036B1 (en) | Ddos attack detection method and device | |
CN106027595A (en) | Access log processing method and system for CDN node | |
CN110809060B (en) | Monitoring system and monitoring method for application server cluster | |
CN108920111B (en) | Data sharing method and distributed data sharing system | |
CN107168853A (en) | A kind of server performance information acquisition method, system and substrate control manager | |
CN105471626A (en) | Method and system for distributing storage data of internal memory | |
CN105893150B (en) | Interface calling frequency control method and device and interface calling request processing method and device | |
CN109600395A (en) | A kind of device and implementation method of terminal network access control system | |
CN113055493A (en) | Data packet processing method, device, system, scheduling device and storage medium | |
CN115344534A (en) | File downloading method and device, computer equipment and storage medium | |
CN110222084B (en) | Method and device, storage medium, and terminal for reporting hotspot device monitoring information | |
CN106341474B (en) | It is a kind of that center and its contents management method are managed based on the data of ICN and SDN network |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20171020 |