#1 2018-04-19 18:49:35

juwo
Member
Registered: 2014-09-05
Posts: 21

many mormot services on same computer

I plan to deploy my application on windows server 2012 (4 core 4 Gb RAM). Standard TSQLHttpServer running as a service. Each client will be using separate database, so i will install many services (on different ports). My question is: how many Mormot servers can be installed on one computer. Is there any limitations?
(each database will be used by 2-5 users)

PS ab - Many, many thanks for Mormot. Each time i post question i'm reminding myself to make donation - same this time.

Offline

#2 2018-04-19 19:36:24

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: many mormot services on same computer

Recently I've been thinking the multiple database implementation with mORMot.

A solution
===
I guess the best option would be each mORMO-http server listens on local port, and let IIS/nginx reverse proxying sub-domains to the local servers.

For example, http://clienta.mycorp.com redirects to http://localhost:8001/root, and
http://clientb.mycorp.com redirects to http://localhost:8002/root

More thoughts
===
Actually the fact that with the current mORMot implementation, 'a http server can have multiple rest server', and since each 'rest server' can have their own 'root folder URI' and database, mORMot itself might already is a ground for implementing such functions, but I'm not sure.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#3 2018-04-19 19:52:09

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

Re: many mormot services on same computer

On Windows, if you use the http.sys server, you can have the very same HTTP port shared by several mORMot servers.
The trick is to each TSQLRestServer have its own genuine "root" text.

Also note that you can run several mORMot TSQLRestServer in the same process, served by a single TSQLHttpServer instance.
And, if needed, you can have several TSQLHttpServer instance in the same process.

About multi-users, the trick may be to have several local SQLite3 database, perhaps one per user.
Then serve the content using a shared TSQLRestServer.
Of course, for this kind of process, it is better to develop a SOA service, with one DB per client.

Online

#4 2018-04-20 06:48:49

juwo
Member
Registered: 2014-09-05
Posts: 21

Re: many mormot services on same computer

Thanks a lot for new directions. Looks like i need to back to SAD documentation and rethink server part. But returning to my first question if i run mormot server as service for each client on different port with ssl (max. number of services is about 150) may i expect any problems?
I made some tests on weaker machine (2core, 2gb ram). I ran about 40 services and all worked very smooth. Surprisingly, since mormot is very well optimized,  processor usage was 0% most of the time (in real use with connected clients).
Of course so many services is not best solutions and definitely i need rework it. But, as temporary solution, windows server will be able to handle about 150 services? Someone has any experience?

edwinsn: thanks for reverse proxying sub-domains idea

Offline

#5 2018-04-20 08:34:05

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

Re: many mormot services on same computer

You should better not use anything than port 443 for HTTPS.
And also think about the certificate...
The idea is to use a single domain name with a single certificate, then redirect the sub-URI to the servers.
Under Windows, the http.sys server allows this for you, without the need to put a reverse proxy in front (no IIS nor nginx needed).

No problem to run 150 services, especially if you run a single process with 150 TSQLRestServer (each with its own root name), but a single TSQLHttpServer.

Online

#6 2018-04-20 08:47:02

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: many mormot services on same computer

@juwo,
if you expose port numbers other than 80/443 you probably will encounter firewall problems in the future, and it's known not to be a good (professional) practice.

@ab,
Where I can find the code example or documentation as to implementing:

....use a single domain name... then redirect the sub-URI to the (other) servers...without using reverse proxy...

?
Thanks!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#7 2018-04-20 08:49:52

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: many mormot services on same computer

Some text for you from the author of sqlite:

...
Developers report that SQLite is often faster than a client/server SQL database engine in this scenario. Database requests are serialized by the server, so concurrency is not an issue. Concurrency is also improved by "database sharding": using separate database files for different subdomains. For example, the server might have a separate SQLite database for each user, so that the server can handle hundreds or thousands of simultaneous connections, but each SQLite database is only used by one connection.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#8 2018-04-20 09:52:08

juwo
Member
Registered: 2014-09-05
Posts: 21

Re: many mormot services on same computer

Thank you. This is new field for me and these tips are invaluable. I join @edwinsn's request - any examples will be really appreciated.

Offline

#9 2018-04-21 12:53:46

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: many mormot services on same computer

Hey! I've just found the BEST solution IMHO!
With the URL Rewrite v2 and Application Request Routing modules for IIS, you can achieve the following:

Assuming you have many mORMot servers listening on local ports, for example:
http://localhost:8081
http://localhost:8082
...

And your domain is www.mysite.com, and your IIS URL Rewrite map would be something like:

<rewrite>
    <rules>
        <rule name="Reverse Proxy to webmail" stopProcessing="true">
            <match url="^client1/(.*)" />
            <action type="Rewrite" url="http://localhost:8081/{R:1}" />
        </rule>
        <rule name="Reverse Proxy to payroll" stopProcessing="true">
            <match url="^client2/(.*)" />
            <action type="Rewrite" url="http://localhost:8082/{R:1}" />
        </rule>
    </rules>
</rewrite>

And the result would be
All traffic to http://www.mysite.com/client1 will be redirected to http://localhost:8081, and
All traffic to http://www.mysite.com/client2 will be redirected to http://localhost:8082

Awesome, isn't it? I just tried on my Windows VPS with windows server 2016 (IIS 10).

Oh I almost forgot, here is the tuotrial.

Last edited by edwinsn (2018-04-22 02:32:18)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#10 2018-04-21 21:32:10

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

Re: many mormot services on same computer

No need to use a reverse proxy : under Windows, use dedicated url instead and the same port.
It will be better for the performance and stability, and you won't need IIS at all.

Online

#11 2018-04-22 02:35:28

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: many mormot services on same computer

But IIS can bring a lot of benifits, for example, take use of the auto-config Let's Encrypt tools, and a lot of controls provided by IIS.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#12 2018-04-22 12:44:23

juwo
Member
Registered: 2014-09-05
Posts: 21

Re: many mormot services on same computer

@edwinsn @ab thanks again for yours hints. I will try (for learning purpose) all suggestions. I have no words how valuable for me is mORMot. Thanks to this framework, in last few years, i discovered many new ways in pascal world.

Offline

Board footer

Powered by FluxBB