Load balancing considerations

Official Content
This documentation is valid for:

This article states several considerations to take into account to run a web application or service in a load-balancing environment.

Those considerations must be taken into account by architects, developers, and the operations team.

Scenario

The scenario that is covered here is the one of (a) Browsers or other applications (clients) connecting (or making requests) to (b) a Load balancer that 'balances the load' of (c) a Web application or service running in several instances of a farm or cluster and that connect to (d) one or several databases and other external resources or services.

Considerations and Recommendations

The following considerations and recommendations may affect

  • architecture decisions (eg.: using a distributed caching engine or not)
  • how you develop your application (eg.: decide if you use Blobs or not)
  • the configuration of your application (eg.: how you handle Logging),
  • the configuration of the Load Balancer (eg.: using sticky sessions or not)
  • the configuration of each instance of the farm (eg.: configuring containers to allow storing temporary files or not)

Session state

Handling this is required in applications that need to maintain session information between requests.

The following GeneXus features or feature options require session state handling:

If you use one or more of those options, then use some way of session replication, persistence or Server Affinity (Sticky Sessions).
More information at Session state handling.

URLs

All links to local resources or objects that GeneXus returns are relative to the web app, so you do not need to do anything unless you want to explicitly create and return an absolute URL to the browser or client. If you need an absolute URL you must get the base path from the database or from a configuration file and then create the string with the absolute URL using the base path + the relative path using the Link Function.

File data type

Avoid using the local file system for persisting files. Use an external storage provider, specifically the Storage Provider API for that.

If you can not avoid it, then use Server Affinity (Sticky Sessions).

Note that storing files may not be allowed by the PaaS or given infrastructure configuration.

Blob data type

Avoid using this data type, use BlobFile data type instead.

If you can not avoid it, then use Server Affinity (Sticky Sessions).
Note that when this data type is used, temporary files are stored and this may not be allowed by the PaaS or given infrastructure configuration.

BlobFile data typeImage data typeAudio data typeVideo data type

Use Object storage to persist those, by setting the Storage Provider property to an external storage provider or using Storage Provider API. Using an external storage provider, you avoid overloading the database with these binaries and also reduce the workload of the database and application servers since the traffic that results from requests that the browsers do to those resources will not affect them.

If you can not use Object storage to persist those, then use Server Affinity (Sticky Sessions).

Sockets

When using web notification features (Client.Socket External Object, Server.Socket external object), use an independent socket server, if not, broadcasts will not reach the browsers as expected.

More information: HowTo: Receiving and processing a notification message from an external app

Caching

As stated in Caching in GeneXus applications, the applications use caching mechanisms in several cases. Set up and use Distributed cache in GeneXus applications.

If you can not use a distributed caching provider, then use Server Affinity (Sticky Sessions).

Logging

Log information is created by generated programs and by Log external object.

Use agents to capture and send it to an external or centralized repository.

eg.:

Smart Devices applications

All the above-mentioned considerations apply to the rest services that are on the server-side of Smart Devices Applications. 

If Smart Devices Cache Management property is set 'On' (which is the default setting), refer to the above-mentioned recommendations for Caching.

Additionally, avoid reading in a Load Event or User Event variables assigned in the Start. If you can not avoid it, refer to the above-mentioned recommendations for Session state handling.

Applications with Integrated Security or GXflow

GAM and GXflow internally use 

So take into account the considerations stated in the corresponding sections of this document.