In WSO2 products based on Carbon 4.4.0 or later versions, you have the option of setting the required tenant loading policy by enabling either either Lazy Loading or or Eager Loading of tenants.
...
of tenants. Additionally, you can separately control the loading policy for web applications and axis2 services deployed in your tenants using the GhostDeployment setting.
Note |
---|
By default, Lazy Loading is enabled for tenants in all WSO2 products. |
First, read the following descriptions to understand how Lazy loading and Eager loading work:
- Lazy Loading: Lazy loading of tenants ensures that all tenants are not loaded at the time the server starts. Instead Instead, they the tenants are loaded only when on demand (upon a request is made sent to a particular tenant). If a tenant is not utilised for a certain period of time, it will be unloaded from memory.Eager Loading: Eager loading is a design pattern commonly used in computer programming. As opposed to lazy loading, eager loading initialises an object upon creation. If Eager loading is enabled in WSO2 products, existing tenants will be loaded without any delays when the Carbon server starts. You can also enable this feature for specific tenants, When a tenant receives a request, the particular tenant and all tenant-specific artifacts except web applications and axis2 services get loaded. Therefore, if you have these artifacts (web applications and axis2 services) deployed in your tenants, you will need to separately enable lazy loading for artifacts using the
GhostDeployment
setting. If lazy loading is not enabled for artifacts, by default, these artifacts will comply with the Eager loading behavior that is explained below.
Tenants (including the tenant-specific artifacts) are unloaded from memory if the tenant remains idle for a specified amount of time. You can configure the allowed tenant idle time. See Configuring Lazy Loading for instructions. - Eager Loading: Unlike lazy loading, eager loading ensures that tenants will be initialized when the server starts (without any delays). You can switch to Eager loading if required. Note that you also have the option of enabling Eager loading for specific tenants so that only the required tenants will be loaded when the server starts.
Lazy Loading is enabled as the tenant loading policy in WSO2 products by default. You can either configure the default setting (Lazy Loading) or replace it with Eager Loading as explained below.
Note |
---|
Note that at any given time, there can only be one configuration (Lazy Loading or Eager Loading) enabled. |
Enabling Eager Loading
By default, Lazy Loading is enabled as the tenant loading policy. You can change this to Eager Loading as follows:
...
- If you have web applications and axis2 services deployed for your tenants, you will want these artifacts to behave according to the Eager loading policy. Therefore, it is recommended that you disable lazy loading for artifacts when Eager loading is enabled.
When eager loading is enabled, tenants (and the tenant-specific artifacts) are expected to remain in memory without unloading until the server shuts down. However, due to a known issue in the system, tenants (and the tenant-specific artifacts) will unload from the system if the tenants are idle for more than 30 minutes. You can overcome this condition by applying a system property to change the allowed tenant idle time. See Configuring Eager Loading for instructions.
Now, see the instructions given below to configure the required tenant loading policy for your system.
Table of Contents |
---|
Configuring Lazy Loading
As explained above, Lazy Loading (for tenants) is enabled as the loading policy in WSO2 products, by default. To verify that Lazy loading is enabled, open the carbon.xml file (stored in the <PRODUCT_HOME>/repository/conf
...
directory) and see that <LazyLoading>
is uncommented as shown below.
...
Code Block |
---|
<Tenant>
<LoadingPolicy>
|
...
<LazyLoading> <IdleTime>30</IdleTime> </LazyLoading> |
...
|
...
<!--<EagerLoading> <Include>*,!foo.com,!bar.com</Include> </EagerLoading>--> </LoadingPolicy> </Tenant> |
...
- If the setting should apply to all tenants, add
<Include>*</Include>
. - If the setting should apply to all tenants, except foo.com and bar.com, add
<Include>*,!foo.com,!bar.com</Include>.
- If the setting should apply only to foo.com and bar.com, add
<Include>foo.com,bar.com</Include>
.
Configuring the Lazy Loading idle time
...
Enabling lazy loading of artifacts (web applications and axis2 services)
If you have lazy loading enabled, and if you have web applications and axis2 services deployed as artifacts in your tenants, you need to separately enable lazy loading for artifacts. This will ensure that these artifacts are first loaded in ghost form. The actual artifacts are deployed only when the artifact is requested.
Note |
---|
Before you enable lazy loading of artifacts, note the following:
|
Follow the steps given below.
Open the
carbon.xml
file (stored in the<PRODUCT_HOME>/repository/conf
directory).Code Block <GhostDeployment> <Enabled>false</Enabled> </GhostDeployment>
- Set the
<Enabled>
property totrue
.
Configuring the tenant unloading time (for Lazy Loading)
...
If you have Lazy loading enabled, you can configure the allowed tenant idle time. For example, if you set the idle time to 30 minutes, tenants that are idle for more than 30 minutes will be unloaded automatically in your system.
Follow the steps given below.
You can configure this value using two methods.
- Specify the tenant idle time when you configure the tenant loading policy:
Open the
carbon.xml
...
file.
- Be sure
...
- that the
<LazyLoading>
element is enabled and<EagerLoading>
is commented out as per the default setting. Set the tenant idle time
- that the
...
using the
<IdleTime>
...
element as shown below.
Code Block <Tenant> <LoadingPolicy> <LazyLoading> <IdleTime>30</IdleTime> </LazyLoading>--> <!--<EagerLoading> <Include>*,!foo.com,!bar.com</Include> </EagerLoading>--> </LoadingPolicy> </Tenant>
...
Note that the loading policy configurations explained above only applies for tenants and not for artifacts. If required, you can enable Lazy Loading for artifacts by using the following code segment in the carbon.xml
file. You cannot enable Eager Loading for artifacts.
Code Block |
---|
<GhostDeployment>
<Enabled>false</Enabled>
</GhostDeployment> |
Alternatively, you can specify the tenant idle time when you start the server:
- Open the product startup script (.
/wso2server.sh
file for Linux andwso2server.bat
for Windows), which is stored in the<PRODUCT_HOME>/bin
directory. Add the following system property.
Code Block $JAVA_OPTS \ -Dtenant.idle.time=<value_in_minutes. \
Restart the server.
- Open the product startup script (.
Configuring Eager Loading
Follow the instructions given below to change the tenant loading policy to eager loading and to change the tenant idle time.
Note |
---|
Before you enable eager loading, note the following:
|
Open the
carbon.xml
file from the<PRODUCT_HOME>/repository/conf/
directory.Enable the
<EagerLoading>
element and comment out<LazyLoading>
as shown below.Code Block <Tenant> <LoadingPolicy> <!--<LazyLoading> <IdleTime>30</IdleTime> </LazyLoading>--> <EagerLoading> <Include>*,!foo.com,!bar.com</Include> </EagerLoading> </LoadingPolicy> </Tenant>
- You can then list the specific tenant domains to which eager loading should apply, by using the
<Include>
element. See the following examples:
Info | ||
---|---|---|
Due to a known issue, when eager loading is enabled, tenants will be unloaded from memory if the tenant remains idle for more than 30 minutes. This issues will be resolved in the Carbon 4.5.0 release. In current product releases, you have the option of changing the allowed idle time (which is 30 minutes, by default) using a system property:
|