Overview:
WebLogic Server provides various options for performance tuning to optimize the performance of your application. WLST (WebLogic Scripting Tool) can be used to automate the process of performance tuning.
Here are some ways to tune WebLogic Server using WLST:
Connection Pool Tuning
WLST can be used to modify the configuration of connection pools. You can tune various parameters like maximum connections, connection timeout, idle timeout, etc. to optimize the performance of the connection pool.
here’s an example of tuning a connection pool using WLST:
connect('<username>', '<password>', '<admin_url>')
edit()
startEdit()
cd('/JDBCSystemResources/<datasource_name>/JDBCResource/<datasource_name>')
cmo.getJDBCConnectionPoolParams().setStatementCacheSize(50)
cmo.getJDBCConnectionPoolParams().setTestConnectionsOnReserve(true)
cmo.getJDBCConnectionPoolParams().setTestFrequencySeconds(1200)
cmo.getJDBCConnectionPoolParams().setTestTableName('SQL SELECT 1 FROM DUAL')
save()
activate()
exit()
In the above script, we’re connecting to the WebLogic Server using the connect()
command, then starting an edit session and navigating to the JDBCConnectionPoolParams for a specific datasource. We’re then setting the statement cache size to 50, enabling connection testing on reserve, setting the test frequency to 1200 seconds, and specifying a test SQL query. Finally, we’re saving and activating our changes and exiting the WLST session.
Note that this is just one example of connection pool tuning and you may need to adjust these parameters based on your specific application requirements and usage patterns
Heap Size Tuning
WLST can be used to tune the heap size of WebLogic Server. You can set the minimum and maximum heap size to optimize the performance of your application.
here’s an example of how to tune the heap size using WLST for a WebLogic server:
# Connect to the admin server
connect(username, password, url)
# Get the server runtime mbean
serverRuntime = getMBean("ServerRuntimes/" + serverName)
# Get the heap size current and max values
heapSizeCurrent = serverRuntime.getJVMRuntime().getHeapSizeCurrent()
heapSizeMax = serverRuntime.getJVMRuntime().getHeapSizeMax()
# Print the current and max heap size values
print("Current heap size: " + str(heapSizeCurrent))
print("Max heap size: " + str(heapSizeMax))
# Set the new heap size values
heapSizeNew = 2048
serverRuntime.getJVMRuntime().setHeapSizeMax(heapSizeNew)
serverRuntime.getJVMRuntime().setHeapSizeMin(heapSizeNew)
# Save the changes and activate the changes
save()
activate()
In the above script, we first connect to the admin server using the connect()
method, providing the username, password, and URL of the admin server. Then we get the server runtime MBean using the getMBean()
method and retrieve the current and max heap size values using the getHeapSizeCurrent()
and getHeapSizeMax()
methods. We print these values to the console.
Next, we set the new heap size values to 2048 using the setHeapSizeMax()
and setHeapSizeMin()
methods. Finally, we save and activate the changes using the save()
and activate()
methods.
This is just an example script, and the optimal heap size for your WebLogic server may vary depending on your application and server configuration. It’s recommended to monitor your server’s performance and adjust the heap size accordingly.
Thread Pool Tuning
WLST can be used to modify the configuration of the thread pool. You can tune various parameters like maximum threads, minimum threads, thread timeout, etc. to optimize the performance of the thread pool.
here is an example of using WLST to tune the thread pool size in WebLogic:
# Connect to the Admin Server
connect('weblogic', 'welcome1', 't3://localhost:7001')
# Get the server runtime object
serverRuntime = getServerRuntime()
# Get the ThreadPoolRuntime object
threadPoolRuntime = serverRuntime.getThreadPoolRuntime()
# Set the minimum and maximum thread pool size
threadPoolRuntime.setMinThreadsConstraint(50)
threadPoolRuntime.setMaxThreadsConstraint(200)
# Save the changes
save()
activate()
In the above script, we first connect to the Admin Server using the connect
command, providing the username, password, and URL of the Admin Server.
Next, we get the serverRuntime
object, which represents the runtime state of the WebLogic Server instance. From there, we retrieve the threadPoolRuntime
object, which represents the thread pool for the server.
We then set the minimum and maximum thread pool sizes using the setMinThreadsConstraint
and setMaxThreadsConstraint
methods of the threadPoolRuntime
object.
Finally, we save and activate the changes using the save
and activate
commands.
You can customize the thread pool size values based on your specific performance requirements.
JMS Tuning
WLST can be used to modify the configuration of the JMS server. You can tune various parameters like message delivery mode, message persistence, etc. to optimize the performance of the JMS server.
Here are some WLST examples for tuning JMS in WebLogic:
Increasing the JMS Server Capacity:
connect(username, password, adminurl)
jmsServerName = 'MyJMSServer'
maxCapacity = 500
cd('JMSServers/'+jmsServerName)
cmo.setCapacityIncrement(maxCapacity)
Setting JMS Destination Paging:
connect(username, password, adminurl)
jmsServerName = 'MyJMSServer'
jmsDestinationName = 'MyQueue'
jmsModule = 'MyModule'
pagingParams = {"PageSize":1048576, "MaxPageSize":2097152, "PageSizeIncrement":262144}
cd('/JMSSystemResources/'+jmsModule+'/JMSResource/'+jmsModule+'/UniformDistributedQueues/'+jmsDestinationName)
cmo.setPagingParams(pagingParams)
Setting JMS Connection Factories:
connect(username, password, adminurl)
jmsModule = 'MyModule'
jmsCFName = 'MyJMSConnectionFactory'
jmsURL = 't3://localhost:7001'
cd('/JMSSystemResources/'+jmsModule+'/JMSResource/'+jmsModule+'/ConnectionFactories/'+jmsCFName+'/ConnectionFactories/'+jmsCFName)
cmo.setDefaultTargetingEnabled(true)
cmo.setSubDeploymentName('MySubDeployment')
cd('/JMSSystemResources/'+jmsModule+'/JMSResource/'+jmsModule+'/ConnectionFactories/'+jmsCFName+'/ConnectionFactories/'+jmsCFName+'/ClientParams/'+jmsCFName)
cmo.setClientIdPolicy('Restricted')
cd('/JMSSystemResources/'+jmsModule+'/JMSResource/'+jmsModule+'/ConnectionFactories/'+jmsCFName+'/ConnectionFactories/'+jmsCFName+'/TransactionParams/'+jmsCFName)
cmo.setXAConnectionFactoryEnabled(true)
There are many more tuning options available for JMS in WebLogic that can be accessed and set using WLST.
JVM Tuning
WLST can be used to modify the JVM parameters like garbage collection, JIT compiler, etc. to optimize the performance of the JVM.
Here’s an example of a WLST script for JVM tuning in WebLogic:
connect('weblogic', 'welcome1', 't3://localhost:7001')
domainRuntime()
cd('ServerRuntimes/myserver')
jvmRuntime=cmo.getJVMRuntime()
jvmArgs=jvmRuntime.getJVMProperties()
jvmArgs.add('-XX:MaxPermSize=256m')
jvmArgs.add('-Xmx1024m')
jvmRuntime.setJVMProperties(jvmArgs)
jvmRuntime.getJVMSystemProperties().add('-Dcom.sun.management.jmxremote')
jvmRuntime.getJVMSystemProperties().add('-Dcom.sun.management.jmxremote.port=9899')
jvmRuntime.getJVMSystemProperties().add('-Dcom.sun.management.jmxremote.authenticate=false')
jvmRuntime.getJVMSystemProperties().add('-Dcom.sun.management.jmxremote.ssl=false')
jvmRuntime.setHeapSizeMin(1024)
jvmRuntime.setHeapSizeMax(4096)
This script connects to the WebLogic server and navigates to the runtime MBean tree. It then sets the maximum size of the PermGen space to 256 MB, the maximum size of the heap space to 1024 MB, and enables JMX monitoring. Finally, it sets the minimum and maximum heap size to 1024 MB and 4096 MB, respectively.
In summary, WLST provides a powerful way to tune the performance of WebLogic Server by automating the process of configuration and monitoring.