#1 Re: mORMot 1 » TSQLHttpServer - Blocking acting like single thread running on windows » 2020-01-24 03:31:07

Thanks for all your help.
I found the issue it was not related to mOrmot.
The issue was caused by the client calls.
This thread can be closed.

#2 Re: mORMot 1 » TSQLHttpServer - Blocking acting like single thread running on windows » 2020-01-14 06:18:19

Ok I tried running my exe as administrator and still no go. I can see there are 32 threads created for the process in the task manager, however here is the waterfall graph from chrome dev tools
(I also updated to latest version of mormot from github)
I can confirm that the exe loads httpapi.dll as well from C:\WINDOWS\SYSTEM32\httpapi.dll


Waterfall

As you can see the first 6 of the calls to mormot happen pretty much at once, but each response is delayed by the 3000 sleep in my published procedure after the previous call ends
( Chrome will only run 6 http request at a time, so that explains why the 7th call waits until the first one is done)

   TServiceServer = class(TSQLRestServerFullMemory)
   published
      procedure doit(Ctxt: TSQLRestServerURIContext);
   end;     

The doit function just parses the parameters and calls

      DebugLog('Getting: ' + string(src));
      sleep(3000); 

      Ctxt.Returns(s);

I would have expected all the sleeps to happen in parallel in each thread and return the results all around the same time.

Am I right in expecting this ?

Thanks
Peter

#3 Re: mORMot 1 » TSQLHttpServer - Blocking acting like single thread running on windows » 2020-01-05 22:59:48

Yes i know there are 32 threads created by default, but i am wondering why the calls seem to be happening in a sequential fashion. (like there is only a single thread or its blocking the other threads)

I thought the URIs should be automatically registered using the HTTP_DEFAULT_MODE of TSQLHpptServer ?

#4 mORMot 1 » TSQLHttpServer - Blocking acting like single thread running on windows » 2019-12-20 06:23:01

psla314
Replies: 8

Hi

I am new to MORmot, but i wrote a simple server to handle rest call from browser and it works well. (code below)
However it seems like there is only 1 thread or its blocked.
I can make 10 calls at same time from browser to same endpoint and each one will only run in sequential fashion.
I even changed server calls to only log a message and then sleep for 5 seconds, and still the second call would only run after the first one finished.

I am running on windows 10 using free pascal to compile/run the MORmot and using javascript in chrome to send the requests on same machine.

Is there a trick to enable the 32 threads in server, or is it just windows being difficult ?
ps. I am running an older version of Mormot (1.18)

TServiceServer = class(TSQLRestServerFullMemory)   
...
procedure StartRestServer;
var
   iPort : Integer;
   bConnected : Boolean;
const
   c_StartPort = 8001;
begin
   Model := TSQLModel.Create([], 'data');
   iPort := c_StartPort;
   DB := TServiceServer.Create(Model, false);
   bConnected := false;
   while not bConnected and (iPort < c_StartPort+10) do
   begin
      try
        Server := TSQLHttpServer.Create(AnsiString(inttostr(iPort)),[DB],'+',HTTP_DEFAULT_MODE);
        bConnected := True;
        DebugLog('OAS Listening on Port '+inttostr(iPort));
      except
         DebugLog('Port '+inttostr(iPort)+' Used.');
         inc(iPort);
      end;
   end;
   Server.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
end;   

Thanks
Peter

Board footer

Powered by FluxBB