Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

Note
iconfalse

Please note that the contents on this page are currently being reviewed!

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.

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, they the tenants are loaded only when a request is made to a particular tenant. By default, lazy loading is enabled for tenants in all WSO2 products, but not for some artifacts (web applications and axis2 services) deployed for your tenants. Therefore, if you have these artifacts deployed in your tenants, you will you need to separately enable lazy loading for artifacts using the GhostDeployment setting. If a tenant See Configuring Lazy Loading for instructions. 
    If lazy loading is not utilised for a certain period of time, it will be unloaded from memoryenabled for artifacts, by default, these artifacts will comply with the Eager loading behavior that is explained below.
  • Eager Loading: Eager loading is a design pattern commonly used in computer programming. As opposed to Unlike lazy loading, eager loading initialises an object upon creation. If Eager loading is enabled in WSO2 products, existing ensures that tenants will be loaded without any delays initialized when the Carbon server starts . You can also enable this feature (without any delays). As explained above, Lazy loading is the default tenant loading policy in WSO2 products, and 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. See Configuring Eager Loading for instructions.
Info

Tenant unloading:

If a tenant is not utilized for a certain period of time (tenant idle time), it will be unloaded from memory. Therefore, the associated performance improvement and resource utilization efficiencies are optimal. Note that you can configure the tenant idle time when Lazy loading is used, but not when Eager loading is used.

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.

...

You can then proceed to configure the lazy loading idle time (for tenants).

Code Block
<Tenant>
   		 <LoadingPolicy>
      	 

...

	<LazyLoading>
           		 	<IdleTime>30</IdleTime>
       		 </LazyLoading>

...


       	

...

 <!--<EagerLoading>
           			<Include>*,!foo.com,!bar.com</Include>
       		 </EagerLoading>-->
  		</LoadingPolicy>
</Tenant>

...

...

Configuring the Lazy Loading idle time 

...

Configuring the lazy loading idle time (for tenants) 

You have the option of setting the required tenant idle time for lazy loading as explained below. 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. 

Note

Note that this configuration only applies to lazy loading of tenants and not artifacts.

Follow the steps given below.

  1. Open the Open the carbon.xml file file

  2. Be sure that the the <LazyLoading> element  element is enabled and and <EagerLoading> is  is commented out as per the default setting.
  3. Set the tenant idle time using the the <IdleTime> element  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.
Info

Alternatively, you can change the allowed tenant idle time during server startup by updating the product startup script. To do this, you need to add the -Dtenant.idle.time=<time_in_minutes> java property to the startup script of the product (./wso2server.sh file for Linux and wso2server.bat for Windows) as shown below, before starting the server.

Code Block
JAVA_OPTS \
    -Dtenant.idle.time=30 \


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, be sure to 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:

  • This setting is only applicable to web applications and axis2 services. 
  • This setting only applies if the artifacts (web applications and axis2 services) are using HTTP/S transports. However, sometimes your axis2 services may be using other transport types such as JMS. In such situations, it is not recommended to enable lazy loading for your artifacts.
  • When this setting is enabled for PaaS deployments, lazy loading applies for tenants as well as the tenant artifacts. As a result, for a tenant in a cloud environment, lazy loading is applicable on both levels.
  • Also, if an artifact has not been utilized for a certain period of time, it will be unloaded from memory. 


Follow the steps given below.

  1. Open the carbon.xml file (stored in the <PRODUCT_HOME>/repository/conf directory). 

    Code Block
    <GhostDeployment>
       <Enabled>false</Enabled>
    </GhostDeployment>

...

  1. Set the <Enabled> property to true.

Configuring Eager Loading

By default, lazy loading is enabled as the tenant loading policy. You can change this to eager loading by following the steps given below.

Note

Before you enable eager loading, note the following:

  • The configuration for enabling eager loading does not apply to web applications and axis2 services deployed as artifacts in your tenants. These artifacts follow the eager loading behavior by default unless the GhostDeployment setting is enabled, as explained above under Enabling lazy loading of artifacts.
  • When eager loading is enabled, tenants will be instantly loaded during server startup. However, if a tenant is not utilized for a certain period of time (30 minutes by default), it will be unloaded from the memory.
  • The server startup time may increase depending on the number of tenants and artifacts you have.
  • The server's memory usage will increase depending on the number of tenants and artifacts that are loaded.
  1. Open the carbon.xml file from the <PRODUCT_HOME>/repository/conf/ directory.

  2. 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>
  3. You can then list the specific tenant domains to which eager loading should apply, by using the <Include> element. See the following examples:
    • 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>