DWR comes packaged with different server load monitors which help balance server load between multiple users. The type of monitor chosen will depend on your application's need.
The Throttling Server Load Monitor at its basic level works by controlling the maximum number of currently connected threads and the maximum hits per second to the server. To control load this load monitor will adjust the time a connection is allowed to stay connected, and the time that the reverse ajax api will wait before connecting to the server again. By adjusting the connected time and the disconnected time the Thottling Server Load Monitor can help give users a better overall experience during times of heavy load.
Since it is inefficient to check load everytime a client requests a new connection, this server monitor runs a separate load management thread that will run at most once every 5 seconds while there are incoming connections. When no more incoming connections are being received the load monitor will simply shutdown and sleep until a new connection is requested. Note that the thread will verify that load at least once per hour even if no connections are being received.
When the server is throttling connections there are three possible modes that the server could be in.
<servlet> <servlet-name>dwr-invoker</servlet-name> <display-name>DWR Servlet</display-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>activeReverseAjaxEnabled</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name> <param-value>org.directwebremoting.impl.ThrottlingServerLoadMonitor</param-value> </init-param> </servlet>
At this point DWR will now use the ThrottlingServerLoadMonitor to balance reverse ajax connections.