How can I upgrade the DataSnap server while the clients are still connected?

We use stateful DataSnap servers for some business logic tasks, as well as for providing clientdataset data.

If we need to update the server to change the business rule, we will copy the new version into a new empty folder and register it (depending on the Delphi version, simply by running or running the TRegSvr utility).

We can do this even while the old server instance is running. However, after registering the new version, all new client connections will still use the current (old) server instance of the server . All clients must first disconnect, then the new server will be used for the following clients.

Is there a way to redirect all new client connections to a new server right after registration?

(I know that new or changed method signatures will also require changing and restarting clients, but this question is about internal changes that do not affect the interface)

We use Socket connections, and all clients use the same server application (only one application window is open). Previously, we used a different configuration of the remote data module, which led to one application window for each client. Maybe this could be a solution? (because each new client will run the currently registered executable file)

Update: Does Delphi XE support "hot deployment" (upgraded servers)? We are using Delphi 2009 at the moment, but we will upgrade to XE if it offers an easier implementation of "hot deployment".

+4
source share
6 answers

you can split your application server into 2 new servers, one of which is a simple proxy object that redirects all methods (and optionally containing status information, if any) to the second, which actually implements your business logic. You also need to implement the “silent reconnection” function on your proxy server so as not to disturb connected clients if you decide to replace the business application server at any time. I have never done such a design before, but I hope that the idea is clear.

+5
source

You tried to rename the current server and put the new one in the same place with the correct name (compared to changing the registry location). I have done this for COM libraries before this with success. I'm not sure if it applies to remote start rules, since it can look for an existing instance to connect instead of a completely new server.

This may be a bit hacky, but you would ask the client to call the method on the server, indicating that a newer version is available. This would allow for any necessary cleanup, so that in the end, you don’t have to talk to either the existing server instance or the new server instance.

+1
source

There is probably no simple answer to this question, and I suspect that you will have to modify the client. The simplest solution I can think of is to have a flag on the server (a property or out parameter on some often called method) that the client periodically checks to tell the client to disconnect and reconnect (something like ImBeingRetired is called).

It is also possible to write callbacks under certain circumstances for a datasnap (although I never did). This will allow the server to tell the client that it should restart or reconnect.

The last option that I can think of (which has not been mentioned yet) is to make the client / server standstill, so that every time the client wants something that he connects, he gets what he wants, and then disconnected.

Unfortunately, none of these options answer your question, but may give you some ideas.

+1
source
  • (optional) configure vmware vSphere, ESX or find a hosting service that already has it.
  • Save session variables in db.
  • Prepare 2 web boxes with 2 different IP addresses and deploy your files.
  • Configure DNS, firewall, load balancer, or BSD vm, so the name "example.com" is resolved in Web Box 1.
  • Deploy the new version in web box 2.
  • Switch to web block 2 using any selected routing method.
  • Deploy the new version in web box 1 if everything looks fine.

Using DNS is probably the easiest, but it takes time for distribution to spread to the client (if the client is outside your local network), and the two clients can see different results. Some firewalls have an IP address mapping feature that allows you to display the public IP address and internal IP address. The ideal way is to use a load balancer and set it to 50:50 and change it to 100: 0 when you want to upgrade, but it costs money. A cheaper alternative is to run software load balancing on BSD vm, but it probably takes some work.

Change I wanted to say that these are session variables, not session. You said that the server is configured for status. If it contains some business logic that uses a session variable, it must be saved externally to be preserved when reconnecting during a switch. The actual DataSnap session will be lost, so when you close web window 1 during the update, the client will receive the message "Session {some-uuid} not found" using web box 1 and it will reconnect to web box 2. Also you can use 3 IP addresses (1 open and 2 private), so the client always sees 1 address, which is the best method.

0
source

I did something similar, having a specific table that contained my "version of the data." Every time I update the server or change the global global parameter, I would increase this field. When the client starts, it always checks this value and will check again before any transactions / requests. If the value was always different from when I first started, I had to go through my re-initialization logic, which could easily enable re-login to the updated server.

I used IIS to publish my application servers, so the data that will change will be empty for the application server. I saved the old ones to respond to any existing transactions that were in the game. In the end, they will be deleted as soon as I find out that client connections to this version no longer exist.

You can easily cope with which versions should be supported if you register the server to which the client was the last to connect (and therefore it will know).

0
source

For newer versions (Delphi 2010 and above) there is an interesting solution

  • for systems using the HTTP transport:

Implement fault tolerance and load balancing in DataSnap 2010 by Andreano Lanusse

  • and related question for TCP / IP transport:

How to configure DataSnap clients to connect to different DS servers?

0
source

Source: https://habr.com/ru/post/1285664/


All Articles