DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: cuiqingbo
今日帖子: 25
在线用户: 12
导航: 论坛 -> Web应用开发 斑竹:bodies  
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/7 9:15:51
标题:
apache benchmark 测试了DataSnap REST服务性能 出现 Failed requests 浏览:2314
加入我的收藏
楼主: 是服务的代码写的有问题吗
Failed requests:        6
   (Connect: 0, Receive: 0, Length: 6, Exceptions: 0)
----------------------------------------------
-
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/7 9:16:32
1楼: 40 40 很少出现失败的
上了50  100 1000 就更多了。
----------------------------------------------
-
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/7 9:18:31
2楼: ab -n 1000 -c 1000 http://127.0.0.1:8089/datasnap/rest/TServerMethods1/dateTime

Document Path:          /datasnap/rest/TServerMethods1/dateTime
Document Length:        34 bytes

Concurrency Level:      1000
Time taken for tests:   3.305 seconds
Complete requests:      1000
Failed requests:        394
   (Connect: 0, Receive: 0, Length: 394, Exceptions: 0)
----------------------------------------------
-
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/7 9:19:09
3楼: Concurrency Level:      1000
Time taken for tests:   2.828 seconds
Complete requests:      1000
Failed requests:        536
   (Connect: 0, Receive: 0, Length: 536, Exceptions: 0)
----------------------------------------------
-
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2020/4/7 10:08:02
4楼: 用的exe还是dll发布?datasnap rest连接了数据库没有,连的是32位的还是64位的?
----------------------------------------------
-
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/7 10:09:12
5楼: EXE ,没有连数据库
----------------------------------------------
-
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/7 10:11:46
6楼: 就用了个dateTime
----------------------------------------------
-
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/7 10:12:13
7楼: function TServerMethods1.dateTime(): string;
begin
Result := DateTimeToStr( now);
end;
----------------------------------------------
-
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2020/4/7 10:13:27
6楼: eexe一般500个并发没问题,超过了要优化,可以看看李维的《delphi 10.1berlin datasnap 开发手册》里讲的优化方法。用dll没有并发连接限制。
----------------------------------------------
-
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2020/4/7 10:15:45
8楼: 可能是datetimetostr(Now)高并发读取时间产生的问题,而不一定是datasnap rest,你可以直接返回客户端一个固定字符串试试?
----------------------------------------------
-
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/8 0:00:52
9楼: function TServerMethods1.sayHello: string;
begin
  Result:='hello';
end;
这个比dateTime是好多了,那代码不能这么写
Concurrency Level:      1000
Time taken for tests:   6.915 seconds
Complete requests:      1000
Failed requests:        8
   (Connect: 0, Receive: 0, Length: 8, Exceptions: 0)
Non-2xx responses:      8
----------------------------------------------
-
作者:
男 hnxxcxg (咏南中间件) ★☆☆☆☆ -
盒子活跃会员
2020/4/8 10:06:56
10楼: mormot http.sys,是高并发的良方
----------------------------------------------
中间件QQ群: 92449782 博客: http://www.cnblogs.com/hnxxcxg/
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2020/4/8 23:01:50
11楼: 不连接数据库,使用静态网页,做一定优化后,exe大约可以稳定到2000个并发,如果以dll发布,15000个并发没有问题的,这个已经超过大多数场景了。
做数据库连接就要注意了,由于datasnap rest一般推荐使用默认的Session生命周期,即为每个连接(而非每次请求)开辟一个会话进行管控,当并发连接多,datasnap rest会为每个连接生成一个数据库连接组件实例(firedac/ado/dbexpress),这样连接多了(200个并发)会导致服务器崩盘,这个时候就需要使用连接池功能,然而firedac要开启数据库连接池有时也不好办。使用64位数据库,开启连接池后,dll版本可以稳定到3000个并发连接的sqlserver2014请求,另外就是使用完后要记得关闭连接。
这一块,emb真的要优化datasnap,期待新版本有提高。
----------------------------------------------
-
作者:
男 smartdata (Jack) ★☆☆☆☆ -
普通会员
2020/4/9 0:08:09
12楼: 如果全部实行短连接,即调用服务端函数完成后马上断开连接,负载能力如何?
----------------------------------------------
==========
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/9 2:03:12
13楼: 呵呵,EMB现在的方向是RAD Server了。datasnap进入维护阶段,只改bug了。
----------------------------------------------
-
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2020/4/9 20:59:05
14楼: Rad server在10.3.1中只是评估版本
----------------------------------------------
-
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2020/4/10 9:53:26
15楼: rad server与datasnap并没有同质发展,emb并未放弃datasnap。
----------------------------------------------
-
作者:
男 earthsbest (全能中间件) ▲▲▲▲△ -
普通会员
2020/4/10 18:02:43
16楼: 用rtc吧,稳定、易用、高效。
此帖子包含附件:
PNG 图像
大小:127.6K
----------------------------------------------
Delphi4Linux Delphi三层/FireDAC 技术群:734515869 http://www.cnblogs.com/rtcmw
作者:
男 ksrsoft (cb168) ★☆☆☆☆ -
普通会员
2020/4/10 21:25:05
17楼: 果然厉害,请问这个RTC是啥
----------------------------------------------
-
作者:
男 earthsbest (全能中间件) ▲▲▲▲△ -
普通会员
2020/4/10 22:43:40
18楼: http://realthinclient.com

program MyHttpServer;

{ You need Delphi 2010 or later to compile this Project!

  This Example uses anonymous methods to implement RTC events.

  Check the "MyHttpServer" project if you are looking for an
  example which is compatible with all Delphi versions and does
  the same as this Project, but uses a custom class with methods
  instead of anonymous methods to implement all RTC events. }

{$APPTYPE CONSOLE}

{$include rtcDefs.inc}

{$IFNDEF RTC_ANON_METHODS}
begin
  Writeln('This Project uses Anonymous methods and requires Delphi 2010 or later.');
  Readln;
{$ELSE}
uses
  SysUtils,
  rtcTypes,
  rtcConn,
  rtcDataSrv,
  rtcHttpSrv,
  rtcInfo;

var
  HttpSrv: TRtcHttpServer;
  DataProv: TRtcDataProvider;

begin
  try
    // Create HttpServer and DataProvider components ...
    HttpSrv := TRtcHttpServer.Create(nil);
    DataProv := TRtcDataProvider.Create(nil);
    try
      // Assign Server to Data Provider ...
      DataProv.Server := HttpSrv;

      // Assign Data Provider Events (handle Valid Requests) ...

      { "Anon" methods are available ONLY with Delphi 2010 or later! }
      DataProv.OnCheckRequest := DataProv.Anon(
        procedure(Sender: TRtcConnection)
        begin
          // Check Request headers and "Accept" all Requests
          // we want to handle with our Data Provider ...
          with Sender do
          if (Request.Method = 'GET') and // we only want "GET" requests
          (Request.ContentLength = 0) then // ... with no content body
          if (Request.URI = '/html') or
          (Request.URI = '/json') or
          (Request.URI = '/xml') or
          (Request.URI = '/code') then
          Accept; // Accept the Request
        end);
      DataProv.OnDataReceived := DataProv.Anon(
        procedure(Sender: TRtcConnection)
        var
          t: TRtcRecord;
        begin
          with Sender do
          // We will start processing the request only if
          // we have received the complee request content body ...
          if Request.Complete then
          if Request.URI = '/html' then
          begin
          // We can use multiple "Write" calls
          // to prepare our HTML response ...
          Response.ContentType := 'text/html';
          Write('<html><body>');
          Write('Your IP: ' + PeerAddr + '<br>');
          Write('Your Port: ' + PeerPort + '<br>');
          Write('Date & Time: <b>' + DateTimeToStr(Now) + '</b><br>');
          Write('Agent: <i>' + Request['User-Agent'] + '</i><br>');
          Write('</body></html>');
          // All "Write" calls will be buffered,
          // RTC will calculate the "Content-Length" for us
          // and send the whole content body out as a single
          // Response - when we are finished with our event.
          end
          else
          begin
          // Using TRtcRecord to prepare our response Object ...
          t := TRtcRecord.Create;
          try
          t.asText['agent'] := Request['User-Agent'];
          t.asText['ip'] := PeerAddr;
          t.asText['port'] := PeerPort;
          t.asDateTime['now'] := Now;
          if Request.URI = '/json' then
          begin
          // Serialize to "JSON" ...
          Response.ContentType := 'application/json';
          Write(t.toJSON);
          end
          else if Request.URI = '/xml' then
          begin
          // Serialize to "XML-RPC" ...
          Response.ContentType := 'text/xml';
          Write(t.toXMLrpc);
          end
          else if Request.URI = '/code' then
          begin
          // Serialize to "Code" (RTC format) ...
          Response.ContentType := 'text/plain';
          Write(t.toCode);
          end;
          finally
          t.Free;
          end;
          end
        end);

      // Assign Server Events (handle the rest) ...
      HttpSrv.OnRequestNotAccepted := HttpSrv.Anon(
        procedure(Sender: TRtcConnection)
        begin
          // Request wasn't accepted ...
          with Sender do
          begin
          // Send "404" status code back ...
          Response.Status(404, 'Not Found');
          Response.ContentType := 'text/plain';
          // Something to show in the Web Browser ...
          Write('Bad command.');
          // And ... Disconnect the Client.
          Disconnect;
          end;
        end);
      HttpSrv.OnListenStart := HttpSrv.Anon(
        procedure(Sender: TRtcConnection)
        begin
          Writeln('Server started.');
        end);
      HttpSrv.OnListenStop := HttpSrv.Anon(
        procedure(Sender: TRtcConnection)
        begin
          Writeln('Server stopped.');
        end);
      HttpSrv.OnListenError := HttpSrv.Anon(
        procedure(Sender: TRtcConnection; E: Exception)
        begin
          Writeln('Server Error: ' + E.Message);
        end);

      // Configure the Server ...
      HttpSrv.ServerPort := '80';
      HttpSrv.ServerIPV := rtc_IPv4;
      HttpSrv.MultiThreaded := True;

      // Start the Server listener ...
      HttpSrv.Listen();

      // Since this is a console application and our
      // Server is Multi-Threaded, we can do whatever
      // we want here. For simplicity reasons, we will
      // just use "ReadLn" to allow the Server to run
      // while we wait for the user to press <Enter>.
      Writeln('Press <Enter> to Quit ...');
      Readln;

      // User has pressed <Enter> - time to kill our Server.
    finally
      // Stop the Server listener ...
      HttpSrv.StopListenNow();
      // Destroy the components ...
      HttpSrv.Free;
      DataProv.Free;
    end;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
{$ENDIF}

end.
----------------------------------------------
Delphi4Linux Delphi三层/FireDAC 技术群:734515869 http://www.cnblogs.com/rtcmw
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2020/4/11 15:53:06
19楼: 楼上大师,到哪找rtc新版本,很想学习一下,对datasnap对比
----------------------------------------------
-
作者:
男 nevergrief (孤独骑士) ★☆☆☆☆ -
盒子活跃会员
2020/4/11 18:22:43
20楼: 楼上,当然是万能的CSDN啊,当然还有我们的Kaida,他的下载空间就有
----------------------------------------------
只有偏执狂才能生存!
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行101.5625毫秒 RSS