0

I'm new to REST developing and i'm creating a simple rest API to request database values from clients. I have used the "Delphi Web Server Application" project assistant (the one that uses TIdHTTPWebBrokerBridge and the WebModule where you create the different 'Actions'). It works fine and I can make requests from client(s).

The server WebModule contains a FDConnection and some FDQuery components to make the database (MySQL) queries, and each Action executes a specific query with specific params obtained throug request params.

The client app uses TRESTResponse, TRESTRequest, TRESRResponse components to send/receive the data.

For example:

  • client request to server some values for a specific user, sending "user = user1" and "passwd = ***" as request params.
  • server executes the query "select * from xxx where user = user1 and passwd = ...…..." and sends the response to the client.

Every query is "user-specific".

Ok, it works, but now I have some misgivings due to my rest/webbroker functioning ignorance.

What if thousands of requests are made at a time? Could the server respond incorrect data because the FDQuery cursor is in another record? Or does the webbroker create the query for each request with no problem?

Is it better to create the FDQuery at runtime for each request and destroy it after request completion?

I made a simple test yesterday, running three instances of the Client application and sending 300 requests to the server (100 from each client) simultaneously and it worked, receiving correct data, but I don't know if this is enough guarantee.

Is this (Delphi Web Server Application) the correct method to créate the server? What are the differences with DataSnap?

Any advice?

santycg
  • 119
  • 1
  • 8

1 Answers1

0

In the Datasnap architecture (there are several flavours, but they all have a common architecture), the "server" makes 1 copy of the ServerMethodsUnit for each client connection. This is with the ServerClass.LifeCycle set to Session. Therefore, each client will be able to execute a servermethod and have the result returned to it, independently of what any other client may be requesting.

In your case, each ServerMethodsUnit will have it's own FdConnection, FdQuery and so on, wether you place design-time components there or instantiate them at runtime, the consequences are the same.

The limit here will be the hardware that the Datasnap/WebBroker application is running on. (Network bandwidth, RAM, Hard drive speed etc)

Datasnap (REST, DBX, Standalone, ISAPI, Apache, Linux), in my opinion is a sound basis for client/server development.

Freddie Bell
  • 2,186
  • 24
  • 43
  • Hi, nolaspeaker. But is this applicable to "Delphi Web Server Application"? I don't have a TDSServerClass nor a TDSServer components in my WebModule unit. – santycg Feb 27 '19 at 11:10