Hunt Framework Hunt Framework 3.1.0 发布,D 语言 Web 服务框架

· Created · Last modified by Brian replied at · 343 times read

Hunt Framework 是基于 DLang 语言编写的全栈 Web 框架。

专为快速开发 Web 服务端而设计,类似 PHP's Laravel、Java's Spring、 Python's Django!

本次主要更新如下:

  1. 加入安全相关的 GET 参数检验方式
  2. 改进工作线程,加入 WokerGroup
  3. 底层库进行模块化
  4. 改进 Windows 平台 IO 稳定性

参数校验示例代码:

    class UserController : Controller {
    ...
        @Action
        string user(@Min(1) uint id)
        {
            auto result = request.valid();
            if (!result.isValid())
            {
               string[string] messages = result.messages();
                // error
            }

            return null;
        }
    }

刚测试了下,负载还是有问题
win10 64bit

D:\phpstudy_pro\Extensions\Apache2.4.39\bin>ab.exe -n 1000 -c 100 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)

Test aborted after 10 failures

apr_socket_connect(): 由于目标计算机积极拒绝,无法连接。   (730061)

D:\phpstudy_pro\Extensions\Apache2.4.39\bin>ab.exe -n 1000 -c 100 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
apr_socket_recv: 远程主机强迫关闭了一个现有的连接。   (730054)
Total of 111 requests completed

服务器返回信息

Try to browse http://0.0.0.0:8080
Program exited with code -1073741819

代码没看,我想是否是多线程存在问题。
一般是创建固定线程数,线程执行完不退出,只需清空缓存,等待新数据。主线程检测空线程分配数据或支线程主动来取数据,主线程通过线程锁控制。

测试了我的PHP程序,可以运行的,不是电脑环境。

D:\phpstudy_pro\Extensions\Apache2.4.39\bin>ab.exe -n 1000 -c 100 http://ruyicms/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking ruyicms (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.39
Server Hostname:        ruyicms
Server Port:            80

Document Path:          /
Document Length:        3305 bytes

Concurrency Level:      100
Time taken for tests:   6.576 seconds
Complete requests:      1000
Failed requests:        66
   (Connect: 0, Receive: 0, Length: 66, Exceptions: 0)
Total transferred:      3599303 bytes
HTML transferred:       3154980 bytes
Requests per second:    152.06 [#/sec] (mean)
Time per request:       657.628 [ms] (mean)
Time per request:       6.576 [ms] (mean, across all concurrent requests)
Transfer rate:          534.49 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.8      0      46
Processing:    31  581 682.4    268    3707
Waiting:       16  569 674.4    258    3642
Total:         31  582 682.5    269    3707

Percentage of the requests served within a certain time (ms)
  50%    269
  66%    410
  75%    557
  80%    748
  90%   1601
  95%   2248
  98%   2463
  99%   3672
 100%   3707 (longest request)

@Ding OK,我们测试一下尽快修复这个问题。

这个库和vipe-d有什么区别不同啊 我要是写server-client模式的程序用哪个库好

你写 CS 形式的简单来说用 hunt-net 比较好,更容易自定义协议,如果更上层的可以看一下基于 hunt-net 的 MsgTrans,这个更强大些。

关于 vibe.d 我觉得更学术,毕竟 hunt net 源于业务。

@Brian 看了下好像hunt-net只支持tcp协议

@phantom 现在 net 层是 codec 封装,底层有 hunt io 可支持 udp

Login to reply