We have a Virtual Server on F5 that is for a mobile app. On a specific day for some time when the simultaneous users exceed a particular number, the application starts to crash because of the application/server-side issues. Until the issue is permanently fixed from the Application and server-side, I need to write an irule that could limit the number of "Users" on the virtual server and when the limit is reached, present the rest with a maintenance message while the users that are already logged in should not face any issues.
The behavior of the mobile app is such that each user creates multiple TCP connections to the virtual server so, if we limit the number of connections to the Pool, what happens is that even the logged in users start getting issues with the application as the app tries to open new TCP connections for different tasks.
I tried another approach as mentioned below:
On rule init, Defined two new global variables i.e. Active_users and Total_Allowed_Users.
When HTTP request
if a particular URI is hit and there is a ABC_Cookie (which only signed in USers will have)
Increment Active_users by 1
if logout URI is hit
Decrement Active_users by 1
if user has no ABC_Cookie (i.e. he is not yet logged in)
Check if the limit has not yet reached, allow him in otherwise drop him with a message
All this is working fine however there is only one problem i.e if the user closes the App without hitting the logout button, i am not able to decrement the Active_users and unfortunately, most users close the app like this.
By the way, when the user closes the app, there is no HTTP request generated, however, all his open TCP sessions are RST from the mobile device.
Any clue how can this situation be resolved. Appreciate if experts can help with this.
How about setting an additional cookie while incrementing the counter. Maybe you could leverage the "HTTP::cookie expires" attribute to set some sort of inactivity timer in the users session. Like, when the users is not sending anymore HTTP requests, the additional cookie doesn't get updated with the expiration time anymore.
Not sure totally sure yet on how to acomplish this technically (as I'm quite new to F5/Devcentral), but I would like to help 😀