Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the NIO optimization in active web page detection?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What this article shares with you is about the NIO optimization in active detection of web pages. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Build a table sentence:

CREATE SEQUENCE seq_probe_id INCREMENT BY 1 START WITH 1 NOMAXvalue NOCYCLE CACHE 2000: create table probe (host varchar (40) not null,state int not null,type varchar (10) not null,)

Using NIO to optimize this program and further squeeze the utilization rate of resources has been thought about for a long time.

But NIO+ multithreading, online examples are not very reliable. Their own learning is also a very headache, procrastination is more than a year.

New program, using three-stage process

First, a thread pool is used to continuously send connection requests, but no reception is processed. Just register a key for SelectionKey.OP_READ

Another single-threaded program constantly select qualified channels and then assigns them to another thread pool to receive and parse data. (the receiving and parsing processes are merged.)

Finally, a single-threaded program is used to constantly brush the results into the database in batches. This piece is also an optimization. Change from a single Insert to batch storage. This block saves the processing power of at least one CPU core.

The persistence and parsing processes basically reuse the original code.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report