netty的http客户端与apache的http客户端比较

 2023-02-25    331  

  之前学习了netty和http异步连接池,跟仓颉大神问的结果是netty的http客户端性能比apache的好。

  咱今儿就用三种http连接池进行测试。

netty的http客户端与apache的http客户端比较

  首先是pom.xml:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3   <modelVersion>4.0.0</modelVersion>
 4 
 5   <groupId>com.company</groupId>
 6   <artifactId>websocket_demo</artifactId>
 7   <version>0.0.1-SNAPSHOT</version>
 8   <packaging>jar</packaging>
 9 
10   <name>websocket_demo</name>
11   <url>http://maven.apache.org</url>
12 
13   <properties>
14     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15     <junit.version>4.12</junit.version>
16     <log4j.version>1.2.17</log4j.version>
17     <netty.version>4.1.36.Final</netty.version>
18     <google.gson.version>2.3</google.gson.version>
19     <guava.version>19.0</guava.version>
20   </properties>
21 
22   <dependencies>
23      <!-- junit -->
24      <dependency>
25          <groupId>junit</groupId>
26          <artifactId>junit</artifactId>
27          <version>${junit.version}</version>
28          <scope>test</scope>
29      </dependency>
30 
31      <!-- log4j -->
32      <dependency>
33          <groupId>log4j</groupId>
34          <artifactId>log4j</artifactId>
35          <version>${log4j.version}</version>
36      </dependency>
37      
38      <!-- netty -->
39      <dependency>
40         <groupId>io.netty</groupId>
41         <artifactId>netty-all</artifactId>
42         <version>${netty.version}</version>
43      </dependency>
44      
45      <!-- gson -->
46      <dependency>
47          <groupId>com.google.code.gson</groupId>
48          <artifactId>gson</artifactId>
49          <version>${google.gson.version}</version>
50      </dependency>
51      
52      <!-- guava -->
53      <dependency>
54          <groupId>com.google.guava</groupId>
55          <artifactId>guava</artifactId>
56          <version>${guava.version}</version>
57      </dependency>
58      
59      
60 
61 <dependency>
62     <groupId>org.apache.httpcomponents</groupId>
63     <artifactId>httpclient</artifactId>
64     <version>4.5.8</version>
65 </dependency>
66 
67      <dependency>
68     <groupId>org.apache.commons</groupId>
69     <artifactId>commons-io</artifactId>
70     <version>1.3.2</version>
71 </dependency>
72      
73   </dependencies>
74   
75   <build>
76       <finalName>Netty_WebSocket</finalName>
77       <plugins>
78           <!--编译版本-->
79           <plugin>
80               <artifactId>maven-compiler-plugin</artifactId>
81               <version>2.3.1</version>
82               <configuration>
83                   <source>1.8</source>
84                   <target>1.8</target>
85                   <encoding>UTF-8</encoding>
86                   <compilerArguments>
87                       <extdirs>src/main/webapp/WEB-INF/lib</extdirs>
88                   </compilerArguments>
89               </configuration>
90           </plugin>
91        </plugins>
92   </build>
93   
94 </project>

pom.xml

以上所述是小编给大家介绍的netty的http客户端与apache的http客户端比较,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!

原文链接:https://77isp.com/post/34439.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。