[Glass] load balancer configuration

Otto Behrens otto at finworks.biz
Tue Dec 26 21:22:48 PST 2023


Thank you for your response, Johan. Compliments of the season to you and
may the coming year be the best.

I would like to understand this better. Because of the disadvantages that
you list (and in the article), we were always under the impression that our
app would do better without session affinity and with a fair load balancer
(because we know we have requests that take too long and we do not want to
block unlucky users). The major disadvantage of our approach is that we
persist session state so that it can be shared across sessions. This must
be a heavy weight approach because the stacks are deep and with ajax calls
this becomes worse.

What I do not understand is how our application can work if a session fires
asynchronous ajax requests. We conceptually have to process an ajax
response as it re-renders and replaces part of the document, which could
end in a mess if multiple requests are done in parallel. I don't understand
how the app would be faster if these requests are sent to the same GS
session, except if the session state is temporary in the session.

We prevent multiple clicks on the same button with a bit of java script.
(As soon as you click on a button, we replace it with text) I must also
admit that I don't see how the locking problem you describe in the article
would manifest under normal circumstances. From what we've seen, it happens
if a user randomly clicks around in the browser (clicking the browser's
back button also). The user would be delayed. But does this mean that other
requests routed to the same session when it "delays for a bit" would also
be blocked?

Mind that with Seaside, requests for the same session cannot be processed
> in parallel.
> This is why at Yesplan, I use sticky sessions to route all requests for a
> single session. An old write-up about that approach is still online (and we
> still do it this way): [1].
>

How do you get requests for the same session in parallel? I think it may be
that with JavaScript in the browser you cannot prevent concurrent requests
without queuing requests in the event queue. I don't understand enough of
this to give an opinion. I just don't see how the app will work properly
because we replace the same html tree in the document with different ajax
responses.


> We use the Seaside session url query parameter (‘_s’) to hash requests to
> an upstream. Depending on the hash distribution, this may have the downside
> that load is not evenly distributed across all upstreams.
> To possibly solve that, we have already been thinking to let the Seaside
> application add another parameter to the generated urls based on how many
> sessions exist and, as such, let Seaside control the Nginx load balancing
> distribution.
>

Does this imply you will have to somehow share session state across
sessions? How would you do that (if persisting is too expensive).


> Also, in our experience, when one upstream times out, Nginx will re-route
> the request to another upstream. This, of course, still means the end user
> is waiting for the request longer than necessary.
> Having an nginx configuration that does sticky sessions unless a request
> is not accepted after a specified amount of time would be the ideal
> situation imho.
>

Yes, this sounds good.


>
> Johan
>
> [1]
> https://jbrichau.github.io/blog/when-to-use-http-session-affinity-in-glass
>
> On 20 Dec 2023, at 13:04, Otto Behrens via Glass <
> glass at lists.gemtalksystems.com> wrote:
>
> Hi,
>
> We are using nginx to load balance in front of GemStone that runs a
> Seaside application. Some of our requests run too long (we are working hard
> to cut them down) and in general, the time it takes to service a request in
> our application varies between 0.1 and about 4 seconds. We are improving
> and getting more towards the lower end of that.
>
> Because of this, we use the least_conn directive and we persist session
> state so that we could use any of our GemStone upstream sessions to service
> a request. Requests are generally load balanced to idle sessions and there
> are theoretically no requests that wait for another to get serviced.
> Perhaps this is not optimal and you have better suggestions. It has worked
> ok for a long time, but should we consider another approach?
>
> When our code misbehaves and a request takes let's say 60 seconds to
> handle, things go pear shaped (yes we want to eliminate them). The user
> clicks "back" on the browser or closes the browser and nginx picks it up
> with:
> "epoll_wait() reported that client prematurely closed connection, so
> upstream connection is closed too while sending request to upstream"
>
> We suspect our problem is: when this happens, it appears as if nginx then
> routes requests to that same upstream, which is unable to handle it because
> it is busy handling the previous request (which is taking too long), even
> with some upstream sessions sitting idle. Some users then end up with no
> response.
>
> Ideally, we would like to catch the situation in the GemStone session and
> stop processing the request (when nginx closes the upstream connection).
> Alternatively, we could set timeouts long enough so that if the browser
> prematurely closes the connection, nginx does not close the upstream
> connection.
>
> Do you have a suggestion to handle this? Does it make sense to get
> timeouts (which ones?) to align so that this does not happen?
>
> Thanks a lot
> Otto Behrens
> +27 82 809 2375
> [image: FINWorks]
> [image: FINWorks] <http://za.linkedin.com/in/waltherbehrens>
> www.finworks.biz
>
> Disclaimer & Confidentiality Note: This email is intended solely for the
> use of the individual or entity named above as it may contain information
> that is confidential and privileged. If you are not the intended recipient,
> be advised that any dissemination, distribution or copying of this email is
> strictly prohibited. FINWorks cannot be held liable by any person other
> than the addressee in respect of any opinions, conclusions, advice or other
> information contained in this email.
> _______________________________________________
> Glass mailing list
> Glass at lists.gemtalksystems.com
> https://lists.gemtalksystems.com/mailman/listinfo/glass
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/archives/glass/attachments/20231227/e95e909b/attachment.htm>


More information about the Glass mailing list