#51 Re: mORMot 1 » any necessary to implement Snowflake-IdWorker for global unique ID ? » 2017-09-04 12:39:53

emk

Means I can generate ID (64bit) on client with 100% assurance that will not collide with another ID?

#52 Re: mORMot 1 » About ZLib/SynLZ/Snappy/LZ4 » 2017-08-11 14:40:31

emk

Perfect! Didn't try but thank you very much.

#53 Re: mORMot 1 » RTL 64bit patched with Intel SIMD IPP TBB, MM from 70secs to 4 secs ! » 2017-07-24 09:26:32

emk

It's really fast (i3-6100T):

32bit, Multicore:

FastMM-AVX (only ERMS enabled)  - 18 sec;
BrainMM - 8 sec;

BrainMM should be investigated how good it is on some 24/7 processes, because performance is stellar!

#54 Re: mORMot 1 » RTL 64bit patched with Intel SIMD IPP TBB, MM from 70secs to 4 secs ! » 2017-07-22 13:03:20

emk

Roberto Della Pasqua:
"BrainMM actually crashes under some circumstances under WIN64, the author will correct it later this year. I did today another test, intel tbb+intel ipp single thread is slighty faster than fastmm4 and many times faster under threads. If the license will be more permissive perhaps we can build a custom LLVM4 object to embed statically."

#55 Re: mORMot 1 » RTL 64bit patched with Intel SIMD IPP TBB, MM from 70secs to 4 secs ! » 2017-07-22 10:32:38

emk

He already tested, but it was a bug in BrainMM and crashed on Win64.

#56 Re: mORMot 1 » RTL 64bit patched with Intel SIMD IPP TBB, MM from 70secs to 4 secs ! » 2017-07-21 12:11:45

emk

it's open source:

"Threading Building Blocks(Intel® TBB) 2017 now under Apache 2.0 license" https://www.threadingbuildingblocks.org/Licensing

Can you compare Intel MM (TBB) against this patch of FastMM-AVX? https://synopse.info/forum/viewtopic.php?id=57&p=4  Goto post #178 (It says is much better that NeverSleepOnThreadContetion)

#57 Re: mORMot 1 » Brotli Compression » 2017-07-19 11:15:11

emk

So, any info what compression to use between iOS/Android and mORMot server?
In my iOS/Android app I have SQLite db contaning a subset of main Firebird db and sometimes when sync is needed, a bulk transfer is happening which will benefit from compression.

Thank you.

#58 Re: mORMot 1 » Brotli Compression » 2017-07-18 09:51:26

emk

SynLZ "pure pascal" is cross-platform compatible? In near future I'll want to use it on iOS and Android apps connected to mORMot server.
Thank you.

#59 Re: mORMot 1 » Multiple databases in one Mormot server » 2016-12-23 14:27:27

emk

@cybexr,
In a linked post ( http://synopse.info/forum/viewtopic.php?id=3704 ), @ab says better than I could do it:

Having separated databases has several advantages:
- easier to backup or purge
- easier to change your hosting (you can change one client location from one server to another)
- more agile for scaling (cloud-like hosting without the cloud)
- you can replicate each database in several nodes (using mORMot replication features) to implement a real-time backup or offline work
- safer design (data of several clients would never mix)
- may be mandatory for regulatory purposes
- is a very good selling point: your client will have its own database!

#60 Re: mORMot 1 » Public-key Asymmetric Cryptography via SynECC » 2016-09-26 14:43:31

emk

Yes, I know, but Pavel says that mORMot features (SOA, ..) are not implemented yet like for standard websockets. He uses http.sys websockets only for light notification.
I'll be really grateful to access SOA(in request+response style)+mORMot authentication via http.sys websockets.

What I'm saying that other users will be delighted to have standard way of working things and protocol options (http.sys-http, or http.sys-websockets) to be just one parameter in constructor. Think about 5000 cell-phones connected thru websocket and receiving real time updates, or JS applications who respond instantaneous.

#61 Re: mORMot 1 » Public-key Asymmetric Cryptography via SynECC » 2016-09-26 08:58:35

emk

If I understand correctly, it will be only for websockets? If yes, that's to bad for me because, I would like to use SOA over websockets, but in current implementation it's only one connection per thread and it's not scalable for thousands of connections.
So, I'll still use "http.sys" http-like connections until so scalable "http.sys" websockets are fully implemented(by the way if you fully implement "http.sys" websockets, you will dust over any framework, including MS ones wink

Thank you for your wonderful framework and if it's possible please implement a-la SSL encryption also for normal http requests, not only for websocket.

#62 Re: mORMot 1 » Public-key Asymmetric Cryptography via SynECC » 2016-09-26 06:53:19

emk

That means you can implement a custom wire encryption a-la SSL style - exchange key of symmetric encryption over asymmetric ECC channel? Please, please make this for Delphi clients of mORMot with the impossibility to accept on that port non-encrypted connection - if somebody needs also JS non-encrypted can launch from the same executable another httpServer on another port.

Note: Symmetric key could live in RAM memory for the life of Delphi client, so the costly handshake will be only the first time.

#63 Re: mORMot 1 » Is there some documentation on master detail relationships in mORMot? » 2016-09-23 22:12:01

emk

If you want some classic approach this is what I want to test next week:

I'm using SOA - method based

1. Retrieve data as an JSON object (ex: "Order" with "OrderLine") into 2 TDataset-compatible(client side). Server-side, you could use for this ISQLDbRows.FetchAllToJSON for every table and combine the result by using TTextWriter.
2. On those 2 memory-TClientDataset you can have master-detail as you already know.
3. When you post changes back to mORMot server, on client side, scan every of those 2 TClientDataset for changed rows and you build an JSON array of changed records:
ex:

[{"table":"Order",  "op":"update", "version":1, "Data":{"ID":123, "Amount":110} },
 {"table":"OrderLine",  "op":"update", "version":1, "Data":{"ID":124, "Qty":11} },
 {"table":"OrderLine",  "op":"delete", "version":1, "Data":{"ID":125} }] 

For generating on client side the JSON from TClientDtaset you can use TDocVariant or JsonDataObjects or any Json writer.
4. On server-side, for transforming that JSON into SQL phrases use TJSONObjectDecoder record (for Fields "table", "op", "version") and GetJSONObjectAsSQL function (for "Data"; GetJSONObjectAsSQL  uses inside also TJSONObjectDecoder record):
ex:

update Order set Amount=110 where ID=123 and version=1;
update OrderLine set Qty=11 where ID=124 and version=1;
delete from OrderLine where ID=125 and version=1;

Notes:
a) "version" it's used for optimistic locking; you can use a timestamp instead; the basic idea is it prevents updating a row which is already modified by somebody-else since the time it was retrieved by me.
b) this approach is compatible with Elevate Web Builder with the difference that instead of "Data" and "version", they use 2 json-subobjects "newrow" and "oldrow".

#64 Re: mORMot 1 » Web sockets examples » 2016-09-17 08:36:36

emk

If I'm not mistaken Tsgc*** is Indy based, that means one thread per connection so you can't really used in apps where you have more than few hundreds connections.

#65 Re: mORMot 1 » Elevate Web Builder » 2016-09-13 13:01:01

emk

I have order on Amazon UK on Sep 11, dispatch on Sep 13 and will be delivered between Sep 15-17.

For europeans best is Amazon UK:
"https://www.amazon.co.uk/Using-Elevate-Web-Builder-Mobile/dp/153555505X/ref=sr_1_2?ie=UTF8&qid=1473771589&sr=8-2&keywords=elevate+web+builder

#66 mORMot 1 » Critical section vs Slim Reader/Writer lock » 2016-09-09 15:25:28

emk
Replies: 1

https://www.delphitools.info/2013/12/18 … ocks-rock/
http://nasutechtips.blogspot.ro/2010/11 … locks.html

Seems that SWR exclusive lock is twice as fast as CriticalSection. Why not use it in mORMot "if Windows >= Vista"? since the more threads are involved, the bigger gains.

#67 Re: mORMot 1 » About ZLib/SynLZ/Snappy/LZ4 » 2016-09-06 15:40:31

emk

Any plans to support SynLZ on FMX platform? Sometimes I will need to transfer some large blocks to iOS and Android devices.
Thank you.

#68 Re: mORMot 1 » About ZLib/SynLZ/Snappy/LZ4 » 2016-09-05 20:39:51

emk

I would like to use mORMot Win32 server because many RTL/mORMot functions are asm optimised and thanks to mORMot good arhitecture memory need is low wink  If, I would compile for Win64 I'll loose many of them. What is the solution for compression to use  a mobile client (iOS/Android) in conjuction with mORMot method based service? Delphi zlib seems to slow (I dindn't test it), SynLZ it's not crossplatform, Cloudflare zlib is only for FPC/Win64).

1. Please make SynLZ crossplatform or write some Snappy wrapper(crossplatform) and define some "synaessnappy" header; snappy seems to be on the same level with SynLZ.
2. What compression to use for AJAX + Win32. Do you intend to enhance the speed of zlib for Win32?

Thank you.

#69 Re: mORMot 1 » Elevate Web Builder » 2016-08-31 15:27:47

emk

Of course if you use variant a) (EWB + mORMot REST server), you can write a little code in EWB which automates marshalling from json GET http(s)://server/Customer(5) to instance of TCustomer (or from any json represented object to instance of that object). EWB knows RTTI.

So you can have your ORM on client side in EWB.

So, you can have something like this:

var
  Customer: TCustomer;
begin
  Customer :=TCustomer.Create;
  try
    GetFromServer(Customer, 5);
    label1.Caption := Customer.Name;
    label2.Caption := Customer.Adress;
  finally
    Customer.Free;
  end;
end;

where GetFromServer is your procedure written by you which calls GET http(s)://server/Customer(5), takes the json and parses Name, Adress,..

#70 Re: mORMot 1 » Elevate Web Builder » 2016-08-31 14:52:06

emk

Any shortcut is always welcome.

Tim Young is developer of EWB. He is the developer of also well known DBISAM.

#71 Re: mORMot 1 » Elevate Web Builder » 2016-08-31 13:58:11

emk

@edwinsn

1. With EWB, you can use any "outside" JS library, you have of course a component TScript. All the job is done in Object Pascal but if you want something fancy you have access to JS.
2. For EWB-mORMot relation you don't need an interface. From EWB app if you want data from mORMot you have 2 options:


a) TServerRequest send a query like this GET http(s)://server/Customers(5) , mormot responds a json with Customer with ID=5. Your logic from EWB parses the Json with help of TReader component and takes Name, Adress, FiscalCode, ... etc
So from server side-mORMot you can have:
a1) rest server with ORM enabled and a table called Customers or
a2) method based server with a method call Customers and you assembly the json for customer with ID=5; you choose.

b) EWB has a TDataset component, which is something like in-memory TClientDataset and has a method LoadRows. So, you have a in-memory TDataset with columns defined at design or runtime and you only ask for rows which will come from mORMot as json array. So you will have a mORMot method based server with only one method which assembly the response every time in the same JSON format - array of rows: ex for table Products:

{ "rows": [
{ "ProductID": "9V-BATTERY-12PK",
  "Description": "12-pack of 9-volt batteries",
  "ListPrice": 20, "Shipping": 2 },
{ "ProductID": "9V-BATTERY-4PK",
  "Description": "4-pack of 9-volt batteries",
  "ListPrice": 4.5, "Shipping": 1.5 },
{ "ProductID": "CALCULATOR-BUSINESS",
  "Description": "Business calculator",
  "ListPrice": 10, "Shipping": 1 }
] }

a) is the OO way, b) is some "tradional" Delphi way. (LoadRows of TDataset has inside a hidden TServerRequest).

#72 Re: mORMot 1 » NewPascal preview - fork for mORMot » 2016-08-31 12:09:18

emk

You don't need css. Every component has a some interfaces states: Focused, Selected, Error, Normal, ... etc
You can adjust properties of every state from Object Inspector (Font, Size, Border, ...etc).

So, a component comes with a standard design which can be customized per IDE (and becomes the new "standard"), or per project, or per form/component. Essentially you specify "css"/attributes of a component by Object Inspector. I think is designed that way so can be inherited and any user can develop his own components or enhancements. And is more "Delphi way". For somebody who doesn't know css, html, JS .. will be "at home" with EWB developing web applications.

So GUI and logic is made with EWB in "Delphi way" and requests for data/services or anything is made with JSON calls to a web server which can be PHP, ASP.NET or of course MORMOT. For that you have of course a component TServerRequest.

You have the same productivity like Delphi/Lazarus and you are not lost in JS world with thousands of: require.js, react.js, angular.js, .........

And one more thing, which is HUGE: in the same way Cordova makes "native" apps for mobile, the same, exists Electron which makes native apps for Windows, Linux and  Mac OSX. Electron is a packed Chrome browser + Node with unrestricted access to operating system. So you write once and run everywhere. Visual Studio Code is written in JS and deployed to Linux, Windows, Mac OSX with Electron.

You can write your app in EWB  in pure Delphi way(and use mORMot on server side for data requests), compile to JS and you have your app in browser, mobile, desktop Linux, Win and Mac OSX. Really cool.

#73 Re: mORMot 1 » NewPascal preview - fork for mORMot » 2016-08-31 09:39:27

emk

@edwinsn

Yes, it supports debugging.
EWB doesn't work with CSS. It has a better way, GUI interfaces. You can easily replicate the bootstrap framework.
Check this and you can figure yourself: Elevate web builder creating custom component

Edit: By replicate, I mean the components are already there, but you can change their style as you wish.

#74 Re: mORMot 1 » NewPascal preview - fork for mORMot » 2016-08-31 08:58:21

emk

@edwinsn

Code completion, not yet..will be in v2.50
The same principle as SMS (I didn't play with SMS). In the same way of Delphi, Lazarus, you write Object Pascal, design the interface(you have a lot of components which can be extended or you can design new ones), press F9 -> compile and EWB creates for you a optimized JS file which run in any browser. EWB has also a simple http server for easy test your project. I think EWB is very good for business applications and has very good documentattion and good support. Check their forum.

#75 Re: mORMot 1 » Delphi for Linux preview - what do you think? » 2016-08-30 18:37:11

emk
ab wrote:

From my tests, mORMot's sockets on my PC gives 90MB/sec bandwidth under Linux, whereas it is only 24MB/sec under Windows...

And how much bandwidth produces http.sys?

#76 Re: mORMot 1 » Websockets and SSL » 2016-08-25 18:33:21

emk

1. Any plans to make these http.sys-websockets compatible with TSQLRestServer - for method based server? I want to call ex: "GET /root/Sum?a=3.12&b=4.2" thru a websocket.

2. I see the example from Project31WinHTTPEchoServer.dpr. How can I send from server side a notification message to a specific connection ID? For ex: "CUSTOMERS_updated"

Thank you.

#77 mORMot 1 » Websockets and SSL » 2016-08-25 11:48:46

emk
Replies: 2

I read that because of every SSL handshaking/exchange certificate a http connection with ~200ms will go to finally ~500ms. Using 'synaes' encryption for desktop will be ok, but our future javascript/mobile counter part app will be a little laggy. So, I thought about websockets:

I never used websockets, but I intend to. I see in forum there is a branch of user "mpv" who made possible thousands of websocket connections with few server resources based on "http.sys". Why it's not included in main release/branch? I think this achivement is colosal. I really need this for "SSL lag reason", but also really need for continous connection with mobile apps to send them "pushes".

I also need this websocket connections to be encrypted.
So, in "mpv-branch", websockets connections are encrypted? How? with SSL if certificate is available/enabled for "http.sys"? or must be developed as another standars "wss://" ? Please, someone to bring some light to me because I'm in darkness. Thank you.

#78 Re: mORMot 1 » Serialize JSON for a dataset which already has JSON content » 2016-04-17 11:46:08

emk

I think I found it: TSQLDBStatement. FetchAllToBinary(Dest: TStream; MaxRowCount: cardinal=0; DataRowPosition: PCardinalDynArray=nil): cardinal; virtual;

but what means "DataRowPosition" ? documentation is lacking for this.

1. What is the reverse function for this, for executing on client?
2. It's the best/fastest way for binary serialization? (so many options smile )
2. I have to manually compress "Dest" with SynLZ or it's enough if I register compression and on the client I set header accepting this compression?

#79 Re: mORMot 1 » Serialize JSON for a dataset which already has JSON content » 2016-04-17 11:28:36

emk

I was able to modify Samples-06 and I was able to return a dynamic array of records. Looking from browser, Delphi 10 serializes this like normal JSON. By the way these days I have to make new samples starting from Samples-06 making method based service very clear how to return different structures of data (a result but not with names pipes, a record, an array of records, a file, ...) because o lot of beginers in mORMot like me spin their head around with so many options. This is my conclusion reading this forum together with my small learning experience. People they know what is a rest server and they want to know quickly how to create a SOA with visible (JSON) results from browser. When it's ready I'll send an email, maybe you publish them.

By the way, speaking of so many options, which functions/procedures I have to use so an array of records (or similar fast non-compatible "TDataset") aka a result set of a query should be returned by a method base service; the fastest way. What do you use to serialize to binary a result set of a query? Thank you.

#80 Re: mORMot 1 » Serialize JSON for a dataset which already has JSON content » 2016-04-16 22:34:19

emk

SynDBRemote was the first option I studied but it's not good for me since it creates one HttpServer per SQLDBProperties and I have thousands of databases which I need to make them online. So, step2 - I'm looking at services. I'll take your advice and create one TZConnection (or TSQLDBProperties if can execute "execute block...") per database guarded by a TCriticalSection and with one housekeeping thread who will disconnect the connection after let's say 15min.

TDynArray of record will return binary coded as Base64 in Delphi 10? because in one place I read this but in another says that only <Delphi2010 versions.

#81 Re: mORMot 1 » Serialize JSON for a dataset which already has JSON content » 2016-04-16 14:54:31

emk

"AFAIR TSQLDBProperties does support "execute block...." since we use it for batch insert/update/delete at ORM level."

That's great news. Thank you. I'll try it.

"To manage JSON in a custom way, take a look at TDocVariant in the documentation.
It is a fast and quick way of manipulating JSON."

I'll look also, but I think my solution resides in TDynArray since my clients for this replication service are only Delphi apps. My priority is to be fast as possible and eventually smallest content; so I wanted to get rid of 2 times JSON escaping:

Log = record
           LOGID: Int64;
           TRANSACTIONID: Int64;
           LOG_TEXT: RawUTF8;
         end;
LogA = array of Log;
DynLogA = TDynArray;

And as a result of my method based service will send DynLogA, which will be binary serialized compact, like you said in documentation, as Base64. So that's great. I have to try it.

"If you use TSQLDBProperties, you could retrieve the JSON directly from a SELECT.
Consider using Zeos/ZDBC, since it has direct support of JSON with TSQLDBProperties, and is very optimized for speed. Just use the 7.2/7.3 branch."

I'm considering Zeos (with or without TSQLDBProperties) because I need direct UTF8 buffer, so I can get rid of conversion.

#82 mORMot 1 » Serialize JSON for a dataset which already has JSON content » 2016-04-15 12:40:28

emk
Replies: 8

Hello,

I'm trying to make an method based service which optionally accepts as an argument a Firebird SQL script "execute block as.. insert...update..delete" (brings updates from client).
This script is not executed by TSQLDBProperties (because can't execute scripts); it's executed by a TZConnection or IBObjects connection (IBO has native access to Firebird, bypassing TDataset; it has also a TIB_Cursor which is native, very fast and doesn't allocate memory) - I didn't decided yet, ZEOS or IBO.

My method based service returns data from a log table (log for replication via db-triggers). My log table could look like:

LOGID - int64
TRANSACTIONID - int64
TIME - time
LOG_TEXT - varchar(3000)

First time I wanted to save in LOG_TEXT field the SQL statements recorded by triggers, but I think it's better to have it in JSON format so optionally I can parse it and I can present it to the user a history of an object like Invoice, Order.. etc. So LOG_TEXT could be:

{"Table" = "Invoice", "Method" = "Insert", "ID" = 1234, "No_of_products" = 10, "Amount" = 100}
or
{"Table" = "Invoice", "Method" = "Update", "ID" = 1234, "No_of_products" = 9, "Amount" = 90}
or
{"Table" = "Invoice", "Method" = "Delete", "ID" = 1234}

What should I do for my method based service not to escape the JSON twice and maybe to combine to nice JSON like this:

{"LOGID" = 10010, "TRANSACTIONID = 5678, "TIME" = int64_time, "Table" = "Invoice", "Method" = "Insert", "ID" = 1234, "No_of_products" = 10, "Amount" = 100}
...

#83 Re: mORMot 1 » TSQLDBConnectionProperties and SQL Script » 2016-04-12 11:23:39

emk

You exposed a TZConnection from main connection of TSQLDBZEOSConnectionProperties? because I think it's not possible because like I saw in source code, TSQLDBConnection passes work to "Properties" thru a OnProcess callback.

I think you created a new TZConnection, so for my case, at the moment I can't use TSQLDBZEOSConnectionProperties.

#84 mORMot 1 » TSQLDBConnectionProperties and SQL Script » 2016-04-12 09:47:02

emk
Replies: 3

Taking the response of @ab from http://stackoverflow.com/questions/3651 … onnections I would like to re-evaluate using TSQLDBConnectionProperties as database connection, but I think I reached a wall: It supports executing a SQL script?

My Delphi clients assembly a Firebird script like "execute block as ... insert.., update..., delete..." which I need to upload to server and execute it.

#85 Re: mORMot 1 » TSQLHttpServer » 2016-04-08 09:21:57

emk

He he, I find it myself but I didnd't have time to update here. The paper which describes the Delphi AMPQ client is here:

http://66.85.163.250/files/articles/BP37_38_AMQP.pdf

kbmMW also have their own messaging system (WIB  - publish/subcribe) which is good to use when deploy AppServer in LAN (one executable mORMot http.sys server + WIB server) - easy to make an installation script, and all the settings on default since the number of user will be small. When deploy in cloud the other scenario is good: mORMot AppServer separately and RabbitMQ+Delphi AMPQ client -  and can be made some speed optimizations conf. and installation doesn't matter because it's your server and you are in charge of.

#86 Re: mORMot 1 » TSQLHttpServer » 2016-04-04 20:42:42

emk

I have similar needs that server pushes notifications to client:
My clients have a copy of the db locally and posts/takes updates thru HTTP calls to a "http.sys" server central database. My clients needs "push" from server with notification message when other clients updates the central db. (I know that mORMot has built in master/slave replication but I can't use it, because my scenario needs plain SQL exchange and some fine tunning)

I have studied the options since I have the same expectations > 2000 clients all time connected to server to get notifications: (I'm talking about notifications system only):

1. mORMmot websockets is not good since it creates one thread per socket
2. the same with all Indy libraries
3. use a standalone RabbitMQ server (or a message broker server) which easily takes millions of messages and thousands of online clients. This seems the best option, but it's a pity that Delphi doesn't have a client for AMQP protocol for exchanging messages (for STOMP protocol exists, but seems the RabbitMQ who is the "message broker of the moment" has better results with AMQP protocol).

#87 Re: mORMot 1 » Multiple databases in one Mormot server » 2016-03-14 16:38:50

emk

I can't use sqllite because I have a lot of stored procedures.

I know that mormot is very refined, that's why I stopped here.

I read quickly the SAD but I still have question how to do some stuff.

I want to achieve 3 objectives:

1. To put data in cloud and to use the same thick windows app (with small modifications) - I'll use the scenario from previous post - localdb + firebird embedded + method based service on server
2. Translate to a new web app for reporting/"light use" with the excelent Elevate Web Builder - I'll use also method based service (EWB AJAX requests seems to be fine with method based services).
3. Make a REST API  for Orders, Invoices, Customers,... to  3rd party app interactions. I read a response in forum that can be achieved also with method based service but I can't figure out how enable something like this:

GET /Orders/{OrderID}/Products/{ProductID}

I read the Method based services chapter, I know that I have to create a TSQLModel 'Orders'- pass it to create method TSQLRestServerFullMemory- pass it to a THttpApiServer but I don't have a working example how to do it.

[qoute=Leslie7]It is worth testing  your usage scenarios  with mORMot for speed and resource consumption before making design decisions.[/qoute]

Yes, it's true, but I need working examples for all 3 objectives (I have solutions for the first 2), so in that way I know if I can go to the way of one big db, multiple processes + multiple dbs, I have to know how URI will be influenced,..etc It will be really helpful if someone posts some code for enabling:

GET /Orders/{OrderID}/Products/{ProductID}

#88 Re: mORMot 1 » Multiple databases in one Mormot server » 2016-03-12 23:57:36

emk

Anyway one-db/FinalCustomer , or one-db/MyCustomerX, I have to write my own db connection pool.

Can someone please post a snippet of code how to make method based service REST API server (TSQLRestServerFullMemory) to enable something like this:

GET /Orders/{OrderID}/Products/{ProductID}

Please.. so I can clear my mind. Thank you.

#89 Re: mORMot 1 » Multiple databases in one Mormot server » 2016-03-12 22:51:51

emk

@Leslie7,

Already have replication in my mind, but for the sake of question simplicity, I didn't mention it.
1. I can't use ORM(the app exists, so I'll not recode it), so I can't use mormot replication. 2. Multi master replication or merge changes configurations is out of the question.

So, my intended scenario:

Every user of MyCustomerX connects LOCALLY (on his computer thru Firebird embedded) to a READ-ONLY replicated database (of course they have only MyCustomerX databases). Every time the app needs data reads locally and load it to Firedac memory tables. At ApplyUpdates for those FDMemtables, I generate DML SQL script (with Firebird "execute block", so it's a single unit of work even it's master/detail update). That SQL script I'll send it to a method based service "ApplyUpdatesAndGetChanges" for execution. The method based service will return all changes log SINCE previous syncronization, including the just applied updates. Posted changes will be notified to other users using the same "master-database" in that moment thru a ZeroMQ or RabbitMQ server, so every notified user will call a method based service "GetChanges" .

How the "master-database" keep the changes log, you can read in excelent article  "http://www.ibexpert.net/ibe/index.php?n … Replicated"
My biggest luck to apply the methodology from that article is that I already have one unique ID=Int64 for all the records, no matter which table.

It's the best architecture I can think of. It's fast (all reads are locally), it's safe (only one true master write), minimum resources use on our cloud-server and data on every client it's up to date almost instant.

What you proposed to use one big master-database and few replicated detail-database filtered by client has 2 drawbacks:
1. 6000db x 100 mb = will be already 600GB database and growing
2. I can't use "fast download database". "Fast download database" means backup now "master-database", zip it and download it quickly to client to replace "detail-database"(less than 15 MB for a full 100 MB db). This is useful when synchonization was a long time ago and changes log is to long to be asked by SQL(part by part and buffered to client), or the client database is corrupted, or computer is reinstalled etc.

This is the model I'll go to enable "cloud" to my existing app. I'm asking those questions because later, I want to publish REST API to those databases, so I want to clear my head from the start and to consider all the aspects of this implementation.

#90 Re: mORMot 1 » Multiple databases in one Mormot server » 2016-03-12 18:29:42

emk

GET "info/X_HisOwnCustomerXX/Invoices/{InvoiceID}" it's a better aproach

#91 Re: mORMot 1 » MVC URI routing » 2016-03-12 18:12:05

emk

Please write a snippet of code because I didn't find in samples.

#92 Re: mORMot 1 » Multiple databases in one Mormot server » 2016-03-12 17:50:14

emk

No refactoring, because it's not sharding, I really need one database for each customer of my customers, because MyCustomer1..MyCustomer200 are accounting companies and keep booking for their own customers.
At any time the final customer can ask for his own database for legal purpose.

Please let me explain better:

MyCustomer1 has (1_HisOwnCustomer1db...1_HisOwnCustomer30db)
..
MyCustomer200 has (200_HisOwnCustomer1db...200_HisOwnCustomer25)

So can be 4000-6000 databases on server. NOT all databases will be online, only a few of them (150-200) because MyCustomer1 can work let's say 2hours on 1_HisOwnCustomer1db, after that can work another 3h on 1_HisOwnCustomer9db, so the connections to 1_HisOwnCustomer1db will be timed out and disconnected after ~10min (by the background thread who maintains the connection pools).

It seems that I have 2 options:
a) One mormot server executable with THttpApiServer with ~64 threads + TSQLRestServerFullMemory + my own intelligent connection pool to ALL databases.
b) One mormot executable/process for EACH MyCustomerXXX with THttpApiServer with ~2 threads + TSQLRestServerFullMemory  + my own intelligent connection pool to ONLY databases of MyCustomerXXX

If I want to implement a REST API like this: GET "X_HisOwnCustomerXX/Invoices/{InvoiceID}" the both options are ok or only the  first one?

PS: I made the wrong assumption that for enabling a REST API, I need use ORM part of Mormot which is tied to TSQLDBConnectionProperties, but it's not the case - I can use method based services with my own connection pool.

#93 Re: mORMot 1 » Multiple databases in one Mormot server » 2016-03-12 12:17:17

emk

Yes, it's true, 400 threads it's not a problem, but number of clients could grow.

But another thing is the problem: each client can have 20-30 databases = 3000-4000 databases, so in your scenario I should have "200 mormot server executable" x "2 threads https.sys" x "connection pools to 4000 db", which IMHO it's not viable.

I think I should have my own connection pool maintained by a background thread who connects dbs dinamically when requested and disconnect them after let's say 10 min of inactivity for that particular db.

The question is if I use my own connection pool and not the "official" TSQLDBConnectionProperties, I can still use later the ORM part of Mormot? because, for start, I'll execute method based serviced to serve SQL queries, but later I want to publish my REST API for Invoices/Orders/Customers/etc.

#94 Re: mORMot 1 » MVC URI routing » 2016-03-12 09:05:20

emk

I would also like to implement a REST API for our Invoice/Orders/etc.. Can someone please post a code example how to implement thru method based services the processing of:

  GET 'customers'
  GET 'customers/{CustomerId}'
  POST 'customers'
  DELETE 'customers/{CustomerId}'
  PUT 'customers'   
  GET 'customers/{CustomerId}/invoices/{InvoiceNumber}'
  POST 'customers/{CustomerId}/invoices'
  DELETE 'customers/{CustomerId}/invoices/{InvoiceNumber}'

Thank you.

#95 mORMot 1 » Multiple databases in one Mormot server » 2016-03-11 22:30:09

emk
Replies: 16

I'm evaluating Mormot and a read part of the docs and forum.

Our existing (accounting-ERP) application use Firebird databases; now we want to enable it for "cloud". For start, we'll use SOA to execute SQL and later "upgrade" to ORM/JSON, so parts (reporting, etc) of our app I will hope to be in AJAX/browser.

So we want to host on our server machine, Mormot executable + Firebird engine + databases of our clients.

Let's say we have 200 clients(5-10 user each) with multiple databases for each client (each database is accounting-db for every of their own customers). So it can be easily 3000 databases (mostly under 100MB each) on one server.
AFAIK, If I create a separate HTTP server for each of 200 client x "few http.sys threads", I have to much thread context switching, so I think the only solution is one mormot server executable with multiple databases. How to do it? Please with sample source code.

#96 Low level and performance » ZeeBeeDee (secure/compressed tunnel) - Implementation of SynLZ » 2013-10-24 15:25:25

emk
Replies: 0

Hello,

For AB,

If you have time, please investigate the posibility to implement your SynLZ compression in ZeeBeeDee project. It'll benefit the speed of this compression algorithm.

For those who don't know ZeeBeeDee is secure/compressed(zlib) tunnel. For example: a Delphi/.Net app can connect transparently thru Internet to a Firebird database - all communications going compressed and encrypted.

Thank you

Best regards.

Board footer

Powered by FluxBB