3.1. Session Monitoring
What You Watch in Production
With OPENMARU Cluster applied, sessions move out of the WAS into the data grid. What you need to watch day to day changes accordingly.
| What you want to know | Where the answer comes from |
|---|---|
| How many users are connected right now | Active session count metric |
| Whether traffic is rising or falling | Session creation and destruction rates per second |
| How much memory sessions use | Session memory usage metric |
| What a particular user's session holds | Session attribute lookup |
| Whether duplicate logins are actually happening | Duplicate login count metric |
| Whether sessions are the cause of slow responses | Trend in session count and memory usage |
All of these values are exposed as MBeans. No separate console or agent has to be installed.
What to Do When the Session Count Grows
When sessions grow and the data grid runs short, add data grid nodes. The WAS is left alone. For the sizing criteria, see "How Many Data Grid Nodes to Deploy" in Part 1.
Adding or removing WAS instances can be done independently of sessions. Because sessions live outside the WAS, restarting instances does not affect users.
Diagnostic Order When Something Goes Wrong
| Symptom | Metric to look at first | What it means |
|---|---|---|
| Users keep getting logged out | Active session count, destruction count | A sharp rise in the destruction count points to the timeout setting or the store connection |
| Responses are slow | Session memory usage | A large individual session means more data travels on every request |
| Low memory warnings | Session memory usage, active session count | Check whether large objects are being placed in the session |
| One account is used from several places | Duplicate login count | A rising value suggests account sharing |
| Only one instance is slow | Active session count per instance | A value skewed to one side points to the load balancer configuration |
What MBean Monitoring Is
An MBean (Managed Bean) is the standard way a Java application reports its own state to the outside. It is part of the Java standard called JMX (Java Management Extensions), and the WAS itself reports thread counts and memory usage the same way.
OPENMARU Cluster registers session metrics as MBeans. As a result, any tool that can read JMX can see the values, and there is no need to build a separate API.
Checking That It Is On
Metrics are turned on and off with the enableStatistics setting. The default is true, so they are on without any configuration. See "Turning On Metric Collection" in Part 2.
Memory usage is the one exception. Measuring it requires a Java agent, so it is off by default; you must turn on enableMemoryStatistics and add the WAS startup option for values to appear.
Where It Is Registered
One MBean is registered per application. The name is as follows.
com.opennaru.khan.session:type=SessionMonitor,appName=<application name>
appName is that application's context path. If it is deployed at the root context (/), ROOT is used. If a WAS hosts several applications, you see that many MBeans.