#1 2014-05-07 14:21:50

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Can 1 server and N clients (in threads) coexist in 1 standalone EXE ?

For the HTTP mORMot architecture, the server can handle multiple clients (via http.sys or the other pure-pascal implementation) simultaneously (as seen at the client side) .

For the stand-alone mORMot architecture, can one server and multiple clients (one client per thread) coexist ? The reason to ask is that this might be thought as "producer-consumer" situation.

For example, if I create one TSQLRestServerDB, and use this existing TSQLRestServerDB to create multiple TSQLRestClientDB instances (one client per thread):

  1. Can the server handle the underlying ORM thread-safely ?

  2. How does the server achieve the ORM thread-safety ? Through a queue, or via spawned threads (e.g., TSQLRestClientDB spawns threads to deal with each request of TSQLRestClientDB, when the request of customized service-method takes quite a long time to complete ) ?

  3. Are there special things to pay attention to, for example, in the URI or customized service-methods in the TSQLRestServerDB, to ensure thread-safety for this situation ?

Last edited by ComingNine (2014-05-07 14:33:28)

Offline

#2 2014-05-08 07:58:26

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Can 1 server and N clients (in threads) coexist in 1 standalone EXE ?

Please ensure you read the "Thread-safety" paragraph in the latest version of the SAD 1.18 pdf.
Also search for "Multi-Thread" in the keyword index at the beginning of the PDF.
You will find here the answers to your questions.

In short, there is no thread created per client: this won't scale.
But there are a lot of options to be tuned for thread on server side execution, mainly:
- the TSQLRestServerURI.AcquireExecutionMode[] property for the global server process,
- and TServiceFactoryServer.SetOptions() for interface based services.

Our little mORmot is pretty configurable and versatile about thread-safety.

Offline

Board footer

Powered by FluxBB