I know that you don't control clients, I meant that you wrote the service implementation on the server side. Sorry if I didn't make that clear.
Sorry if I didn't understand you too.
]]>I've already said to you that I don't control clients. It's not about a Delphi client-server. Is much more than that... Java, services, website... anyway.
I know that you don't control clients, I meant that you wrote the service implementation on the server side. Sorry if I didn't make that clear.
]]>I agree with pvn0.
I cannot shutdown the service, even after this period, if the client already was using the service before
If there is information that will only be on instance A and that cannot be continued on instance B, is this not a type of session?
Instead of trying to discovery if mORMot does what I want to implement, you (all) are trying to know "why" I need it...
Guys, maybe the archtecture there is wrong; maybe storing the URL's of services in a database is wrong... but this is already exists and I need to work with.
]]>The thing you call "A/B service" is known as "Blue-Green Deployment" (google for it) and it usually implementing using some kind of load balance.
Announcing a new URL to client is tooooo complex.
Better to set up a load balance in front of your services, so you can start new instance, instruct load balance to proxy new requests to the new instance and when shut down old instance.
I use nginx for such task, but HAPxoxy is also good candidate. Even IIS may be can do such.
I can't choose what I want to use. They are paying me to do a job. That's it. Maybe I can use IIS, but I don't know yet.
I wrote "A/B service" (quoted), as it is just an idea and not the Blue-Green Deployment. Thanks, anyway.
You are writting very contradicting things, you say there is no session but your entire problem seems to be session related, or lack of.
That is because I'm thinking far. I have a job to do now, but new ones in a near future. I'm apologize if it's confusing for you.
Right, you wrote the service implementation, so if a client is using instance-A when you swap to instance-B, YOU should know that already because you wrote the service implementation
I've already said to you that I don't control clients. It's not about a Delphi client-server. Is much more than that... Java, services, website... anyway.
]]>I cannot shutdown the service, even after this period, if the client already was using the service before
If there is information that will only be on instance A and that cannot be continued on instance B, is this not a type of session?
]]>I don't know about PendingContextCount (I will read documentation) but as I'm answering you: so, I can return this value and if it is zero I can know, for sure, that no resquest still in a list to be process, right?
After double checking the code you should better use this instead.
ThttpServer(aHttpServer.HttpServer).ServerConnectionActive
My bad
So, you don't need a session (this service doesn't have one). But clients SHOULD refresh its own "list of URL services" in a *period of time*. If some client haven't updated its list and still trying to use the instance-A—AFTER this period of refreshing—I don't care if he/she got a 400 error because he/she should used the active service, which is instance-B.
But I cannot shutdown the service, even after this period, if the client already was using the service before — that could exists in other type of services, which I will implement as well, and that is why I would like to know how to shutdow the service without kill someone unintentialy. I would like to do this properly, clean, without workarounds.
You are writting very contradicting things, you say there is no session but your entire problem seems to be session related, or lack of.
@ab and @mpv are both right, you need load balancing and possibly revamp of your server code.
The biggest confusing thing for me is :
I cannot shutdown the service, even after this period, if the client already was using the service before
Right, you wrote the service implementation, so if a client is using instance-A when you swap to instance-B, YOU should know that already because you wrote the service implementation
]]>I still don't understand why you cannot shutdown the service.
]]>Okay, now I think I understand.
You return the URL at the beginning of the session and it will be the same until the client is finished.In theory a client can stay for hours in the same session and you would not be able to make this replacement within a constant period.
You can end up with hours of delay if the client remains open.
Almost that
Clients should get from a database the URL for each (active) services.
So, you don't need a session (this service doesn't have one). But clients SHOULD refresh its own "list of URL services" in a *period of time*. If some client haven't updated its list and still trying to use the instance-A—AFTER this period of refreshing—I don't care if he/she got a 400 error because he/she should used the active service, which is instance-B.
But I cannot shutdown the service, even after this period, if the client already was using the service before — that could exists in other type of services, which I will implement as well, and that is why I would like to know how to shutdow the service without kill someone unintentialy. I would like to do this properly, clean, without workarounds.
]]>macfly wrote:But if server A is no longer receiving requests after a while, why would someone still be using it?
"I cannot stop the service even if just one person is using it, because I cannot control if this client got the new URL, from the database, to use the instance-B."
Okay, now I think I understand.
You return the URL at the beginning of the session and it will be the same until the client is finished.
In theory a client can stay for hours in the same session and you would not be able to make this replacement within a constant period.
You can end up with hours of delay if the client remains open.
@ab is right as always
As I guy that worked directly with him, I always had this thought... but not this time
Just incase you need this or anyone is wondering :
THttpServer(aHTTPServer.HttpServer).ThreadPool.RunningThreads THttpServer(aHTTPServer.HttpServer).ThreadPool.PendingContextCount
RunningThreads will tell you how many threads in the pool are active and PendingContextCount will tell you how many requests are queued for processing. (don't call PendingContextCount too often because it uses a lock).
THANK you, to give some light on this thread! Now I start to think that is possible to do what I NEED to do.
I don't know about PendingContextCount (I will read documentation) but as I'm answering you: so, I can return this value and if it is zero I can know, for sure, that no resquest still in a list to be process, right?
Either way if you shutdown your server and your client gets an error you should either A.) be sure all clients have been notified of server change prior to shutdown B.) handle the error on client side.
I cannot control the clients, which is other apps (website, other Java services, of course the Delphi client, and anyone that wants to use that service).
]]>But if server A is no longer receiving requests after a while, why would someone still be using it?
"I cannot stop the service even if just one person is using it, because I cannot control if this client got the new URL, from the database, to use the instance-B."
]]>Whatever there are threads still working or not, is not relevant. I am afraid you still don't understand how the mORMot HTTP server thread pool works, and that "killing the threads" doesn't mean anything in our context. The threads are not running, they are sleeping until there is a request incoming.
Arnaud, I know that threads are not running if nobody is send request. Yes, they are sleeping, but I (as an admin of the service, not as a developer that has created) don't know if thread are sleeping or running, before I kill the process.
I cannot drop a user that is using the service. I just can't... and I'm afraid that you still don't understand me. Again, I cannot stop the service even if just one person is using it, because I cannot control if this client got the new URL, from the database, to use the instance-B!
There is already a feature in TSQLRestServer/THttpServer which allows a graceful shutdown of the server process.
If you just stop the mORMot daemon, it will shutdown properly, refusing any new input and finishing the pending requests.
So you can safely shutdown one instance, which won't accept any more request, and another one could take the next requests. If you want 100% up time, you can put a front-end, e.g. nginx reverse proxy with load balancing to the two instances.
Are you talking about mORMot 2.0?
If it already exists in 1.18 let us know, as everybody still using that version.
Another information is that I'm not using a demon (yet).
...refusing any new input and finishing the pending requests.
By "finishing" you meant stop to process in the middle, returning an error to the client? If I understood wrong, please try to explain again, otherwise I cannot do that.
PS: I cannot tell them what I would like to use (nginx, IIS, whatever). By now, I would like to use just mORMot service process.
]]>I cannot guarantee that a service is always online, 100% of time, if I can shutdown someone that are using it because I supposed that no one was using.
Don't you agree?
But if server A is no longer receiving requests after a while, why would someone still be using it?
]]>There is already a feature in TSQLRestServer/THttpServer which allows a graceful shutdown of the server process.
If you just stop the mORMot daemon, it will shutdown properly, refusing any new input and finishing the pending requests.
So you can safely shutdown one instance, which won't accept any more request, and another one could take the next requests. If you want 100% up time, you can put a front-end, e.g. nginx reverse proxy with load balancing to the two instances.