您现在的位置是:首页 > 文章详情

smart-http 1.0.22 发布,7 行代码便可运行的 HTTP 服务器

日期:2021-02-07点击:589

smart-http 是一款比较简易的 http 服务器,其通信内核采用了 smart-socket 最新版v1.5.5

也正因使用了 smart-socket,该服务器的性能表现还是非常不错的,在本人的4核CPU下能跑出 78W+的 qps。

smart-socket 的每次性能测试都是基于该服务器进行的,相信 smart-http 的表现不会让您失望的。

更新内容

  1. 升级smart-socket至最新版:1.5.5,提升服务性能。
  2. 重构内置的日志工具。
  3. 修复 Http 解码接口单词拼写错误问题。
  4. 读缓冲区默认采用 HeapByteBuffer,减少解码过程中的拷贝次数。
  5. 延长 Header Date 更新频率至 950 毫秒。
  6. 禁用解码过程中的字符串缓存.

快速体验

  1. 在您的Maven工程中引入smart-http依赖。
     <dependency> <groupId>org.smartboot.http</groupId> <artifactId>smart-http-server</artifactId> <version>1.0.22</version> </dependency>

     

  2. 拷贝以下代码并启动。
     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(); } }

     

  3. 浏览器访问:http://localhost:8080/
原文链接:https://www.oschina.net/news/129525/smart-http-1-0-22-released
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章