Delphi. UniGUI. Sessions

Публикую здесь свои выводы топика о сессиях в UniGUI (англ.).

I was testing AllowTerminate example and added 1 timer on the form to count the time, spent from the start. And for my surprise – if checked AllowTerminate as true or not – reaction was the same – Application was going to work and didn’t terminated util manual terminate.

Then I made conclusion – when Application do something – even if we move form, enabling timer, pressing buttons – any activity – then, it seems to me its communicating to the Server and session continues!!! Then if I understand correct – SessionTimeout begins from the moment of last Activity.

Activity from client? Sessions – continues. Application continues to work.

No Activity? SessionTimeout starts and Application will be terminated.

I post it here because I didn’t know that and maybe some new developers who didn’t work with web, came from clear Delphi – will find it useful. I will try to assume experience of this topic

(Post #12, Mohammed Nasman) What is Session (shortly)?

Session –  instance of Application with Unique ID on the server

Session object, it’s an object dictionary for each session instance, and it could be access within the application for the same (session id only).

(Post #26, myself) How Session Model works?

NoActivity from client Application (client went for coffebreak) – SessionTimeout Starts, if on ServerModule.SessionTimeOut was 20 minutes than after 20 minutes of NoActivity – Instance will be terminated and all data will be lost.

So to save users data we can use MainModule.OnSessionTimeout

AnyActivity? Application continues to work – SessionTimeOut countdown doesn’t start

(Post #18, #20, Oscar, myself)  Oskar model

-keep session alive (by “doing something” with server or maybe with AllowTerminate:=false; like above)

-terminate session on Connection down to clean temporary files

-to put “false” CloseApp button, and on click not to terminate,  and real termination will be on closing browser tab

-to keep transactions in one event

My thoughts about it

If we have <100 users than keeping session always alive – it is Ok. But in general case…

Keeping session alive for all users may lead to big memory consumtion. So, lets take 32 bit Apps, 1 session, according to Mohhamed words – 10 MB.

-If 1 user will open App only in 1 Tab than it is 10 MB of RAM,

-if 100 users will open App in 1 tab than ~ 1 GB, after 100 users as i understand its unpredictable!!!

-if 100 users will open App in 2 tabs than ~ 2 GB (will it work for 32 bit? Maybe. But OutOfMemory very possible), and for the Web it is normal to open different pages in many tabs – so here it could be problem for 32 bit.

So if to project big Application with high Load and many, many users, 32bit App – not Ok, but 64 bit.

(Post#25, Mohhamed) Mohhamed Model

– To set SessionTimeout beetwen 30 min and one hour is very reasonable time

– To not to keep Session Model always alive to save resources (RAM, Diskspace…)

My thoughts about it

-In general case it suites for <100 users and >100 users, so, seems to be universal.

My Practical Conclusions

Set SessionTimeout in 45 min.

-Save users data on SessionTimeout

-Use 64 bit for >100 Users and in general case it gives more RAM resources

This entry was posted in Delphi, UniGui. Bookmark the permalink.