smart-http 1.0.22 发布,7 行代码便可运行的 HTTP 服务器
smart-http 是一款比较简易的 http 服务器,其通信内核采用了 smart-socket 最新版v1.5.5。
也正因使用了 smart-socket,该服务器的性能表现还是非常不错的,在本人的4核CPU下能跑出 78W+的 qps。
smart-socket 的每次性能测试都是基于该服务器进行的,相信 smart-http 的表现不会让您失望的。
更新内容
- 升级smart-socket至最新版:1.5.5,提升服务性能。
- 重构内置的日志工具。
- 修复 Http 解码接口单词拼写错误问题。
- 读缓冲区默认采用 HeapByteBuffer,减少解码过程中的拷贝次数。
- 延长 Header Date 更新频率至 950 毫秒。
- 禁用解码过程中的字符串缓存.
快速体验
- 在您的Maven工程中引入smart-http依赖。
<dependency> <groupId>org.smartboot.http</groupId> <artifactId>smart-http-server</artifactId> <version>1.0.22</version> </dependency> - 拷贝以下代码并启动。
public class SimpleSmartHttp { public static void main(String[] args) { HttpBootstrap bootstrap = new HttpBootstrap(); bootstrap.pipeline().next(new HttpHandle() { public void doHandle(HttpRequest request, HttpResponse response) throws IOException { response.write("hello world".getBytes()); } }); bootstrap.setPort(8080).start(); } } - 浏览器访问:http://localhost:8080/