You are not logged in.
Pages: 1
I have setup 2 TSqlHttpServer in same project and same procedure with diffrent port (888,999).
Both are TSqlHttpServer
-->TSqlRestServerDb (with interfaced service sicShared or sicClientDriven)
-->TSqlModel (some TSqlRecords with diffrent rooturl)
-->TOleDbMssqlConnectionPropperties (connect to same one DB@Server).
And write a Console TestCase to Test 2 ways(port:888 And 999) interfaced service.
But 2 ways testcase are same DataBase connections counts with 1 way (port 888 or 999) testcase , count to 32.
Why not 2 way DataBase connections count to 32+32 ?
2 TSqlHttpServer with diffrent port(888 and 999) ,thread max count = 32+32 or 32?
These are confused me...............
Updated:
I Setup 2 TSqlHttpServer With 2 Propject(win32 application) ,and same result too.
Last edited by zhyhero (2020-06-21 05:49:04)
Offline
The threads are defined per TSqlHttpServer instance.
You can adjust the number of threads in the constructor.
32 thread is for highly used server. For a seldom used server, you can set 3 or 4 threads only.
Offline
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|No. | type | httpserver (Port) | Create threads | TestCase Console App | database connections count |DataBase |
| | | | | Run 1 or 4 TestCase App at same time | 3rd Tools Counted | |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 1 | single | Sqlhttpserver1(888) | 32 | 1 / 4 | 32 / 32 | |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 2 | single | Sqlhttpserver2(999) | 32 | 1 / 4 | 32 / 32 | Same One |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 3 | both | Sqlhttpserver1(888),Sqlhttpserver2(999) | 32+32 | 1 / 4 | 32 / 32 | |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have tested all 3 scenarios .
The No.3 scenario confused me. The Database connections count still equals 32 ,not 64 .
Why this happened ?
Offline
Access both server(888 and 999) on case 3.
like
client1.create(888); service1:=client1.service<IServiceA>; service1.dosomething;
client2.create(999); service2:=client2.service<IServiceB>; service2.dosomething;
Offline
And with case 3 ,database connections count number increase 1 every time from 32 up to 33,34,35 .......
all test on delphi 10.4.
Sorry for post a lot of Source Codes here....
1. GlobalCodeServer.dpr
program GlobalCodeServer;
uses
Vcl.Forms,
Main in 'Main.pas' {FormMain},
Services in 'Services.pas';
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormMain, FormMain);
Application.Run;
end.
1.1 Services.pas
unit Services;
interface
uses mORMot, Syncommons, SynOleDB, SynDB;
type
IVeCode = interface(IInvokable)
['{DE580C16-54F4-4C82-860C-D60BE6374F29}']
function GenCodes(aSetCode: RAWUTF8; aSvcCode: RAWUTF8): RAWUTF8;
end;
IPaCode = interface(IInvokable)
['{ED56F71A-37A3-4A3A-BB2B-827A6D03A390}']
function GenCodes(aSetCode: RAWUTF8; aSvcCode: RAWUTF8): RAWUTF8;
end;
TVeCode = Class(TInterfacedObject, IVeCode)
public
function GenCodes(aSetCode: RAWUTF8; aSvcCode: RAWUTF8): RAWUTF8;
End;
TPaCode = Class(TInterfacedObject, IPaCode)
public
function GenCodes(aSetCode: RAWUTF8; aSvcCode: RAWUTF8): RAWUTF8;
End;
var
VeProp, PaProp: TOleDbMssqlConnectionProperties;
implementation
{ TVeUniCode }
function TVeCode.GenCodes(aSetCode, aSvcCode: RAWUTF8): RAWUTF8;
var
_Data: Variant;
aQuery: TSQLDBStatement;
begin
// _Data := _Json(VeProp.Execute('select ?+? As Adata', [aSetCode, aSvcCode]).FetchAllAsJSON(true));
aQuery := VeProp.NewThreadSafeStatement;
aQuery.Execute('select ?+? As Adata', true, [aSetCode, aSvcCode]);
_Data := _Json(aQuery.FetchAllAsJSON(true));
aQuery.Free;
Result := _Data._(0).Adata;
end;
{ TPaUniCode }
function TPaCode.GenCodes(aSetCode, aSvcCode: RAWUTF8): RAWUTF8;
var
_Data: Variant;
aQuery: TSQLDBStatement;
begin
// _Data := _Json(PaProp.Execute('select ?+? As Adata', [aSetCode, aSvcCode]).FetchAllAsJSON(true));
aQuery := PaProp.NewThreadSafeStatement;
aQuery.Execute('select ?+? As Adata', true, [aSetCode, aSvcCode]);
_Data := _Json(aQuery.FetchAllAsJSON(true));
aQuery.Free;
Result := _Data._(0).Adata;
end;
end.
1.2 Main.pas
unit Main;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, mORMot, mORMotSqlite3, mORMotHttpServer, SynOleDB, SynSqlite3Static;
type
TFormMain = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
VeModel, PaModel: TSQLModel;
VeRest, PaRest: TSQLRestServerDB;
VeHttp, PaHttp: TSQLHttpServer;
public
{ Public declarations }
end;
var
FormMain: TFormMain;
implementation
{$R *.dfm}
uses Services;
procedure TFormMain.FormCreate(Sender: TObject);
begin
VeProp := TOleDBMssqlConnectionProperties.Create('127.0.0.1,1433', 'DB8', 'Sa', '1');
PaProp := TOleDBMssqlConnectionProperties.Create('127.0.0.1,1433', 'DB8', 'Sa', '1');
VeModel := TSQLModel.Create([], 'Ve');
PaModel := TSQLModel.Create([], 'Pa');
VeRest := TSQLRestServerDB.Create(VeModel, ':memory:');
PaRest := TSQLRestServerDB.Create(PaModel, ':memory:');
VeRest.ServiceRegister(TVeCode, [TypeInfo(IVeCode)], sicClientDriven);
PaRest.ServiceRegister(TPaCode, [TypeInfo(IPaCode)], sicClientDriven);
VeHttp := TSQLHttpServer.Create('888', [VeRest], '+');
PaHttp := TSQLHttpServer.Create('999', [PaRest], '+');
VeHttp.AccessControlAllowOrigin := '*';
PaHttp.AccessControlAllowOrigin := '*';
end;
procedure TFormMain.FormDestroy(Sender: TObject);
begin
VeHttp.Free;
PaHttp.Free;
VeRest.Free;
PaRest.Free;
VeModel.Free;
PaModel.Free;
VeProp.Free;
PaProp.Free;
end;
end.
2. GlobalCodeTest.dpr
program GlobalCodeTestCase;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Services in 'Services.pas', SynTests, mORMotHttpClient, mORMot;
type
TTestClient = class(TSynTestCase)
published
procedure Test1;
end;
TTestSuit = class(TSynTestsLogged)
published
procedure MyTestSuit;
end;
{ TTestSuit }
procedure TTestSuit.MyTestSuit;
begin
AddCase([TTestClient]);
end;
{ TTestClient }
procedure TTestClient.Test1;
var
VeModel, PaModel: TSQLModel;
VeClient, PaClient: TSQLHttpClient;
VeCode: IVeCode;
Pacode: IPaCode;
i: integer;
begin
VeModel := TSQLModel.Create([], 'Ve');
VeClient := TSQLHttpClient.Create('127.0.0.1', '888', VeModel);
VeClient.ServiceRegister(TypeInfo(IVeCode), sicClientDriven);
VeClient.ServerTimestampSynchronize;
VeCode := VeClient.Service<IVeCode>;
PaModel := TSQLModel.Create([], 'Pa');
PaClient := TSQLHttpClient.Create('127.0.0.1', '999', PaModel);
PaClient.ServiceRegister(TypeInfo(IPaCode), sicClientDriven);
PaClient.ServerTimestampSynchronize;
Pacode := PaClient.Service<IPaCode>;
for i := 1 to 10000 do
begin
Check(VeCode.GenCodes('A', 'B') = 'AB');
Check(Pacode.GenCodes('C', 'D') = 'CD');
end;
VeCode := nil;
VeClient.Free;
VeModel.Free;
Pacode := nil;
PaClient.Free;
PaModel.Free;
end;
begin
with TTestSuit.Create do
try
Run;
readln;
finally
Free;
end;
end.
Offline
Pages: 1