-
-
Notifications
You must be signed in to change notification settings - Fork 751
Improving Performance by using the PoolableBroadcasterFactory
The DefaultBroadcasterFactory
keeps references to all created Broadcaster
s, and for applications that heavily creates new Broadcaster
s, executing the retrieval operation can cause serious performance issues. If your application creates a lot of Broadcasters, you can take a look at the PoolableBroadcasterFactory
, which can be used to significantly improve throughput of an application. By default, Apache Commons Pool2 is used, so you need to add the following dependency:
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.3</version>
Next, in your web.xml, define:
<init-param>
<param-name>org.atmosphere.cpr.broadcasterFactory</param-name>
<param-value>org.atmosphere.pool.PoolableBroadcasterFactory</param-value>
</init-param>
By default the PoolableBroadcastFactory
uses an unbounded Apache commons-pool2 implementation. There is also a bounded version available.
Finally, you can configure or define your own pool provider by adding in web.xml:
<init-param>
<param-name>org.atmosphere.pool.poolableProvider</param-name>
<param-value>your class that implements org.atmosphere.pool.PoolableProvider</param-value>
</init-param>
For example, to use the BoundedApachePoolableProvider, set
<init-param>
<param-name>org.atmosphere.pool.poolableProvider</param-name>
<param-value>org.atmosphere.pool.BoundedApachePoolableProvider</param-value>
</init-param>
and then it max size
<init-param>
<param-name>org.atmosphere.pool.BoundedApachePoolableProvider.size</param-name>
<param-value>200</param-value>
</init-param>
The complete implementation can be found here.
- Understanding Atmosphere
- Understanding @ManagedService
- Using javax.inject.Inject and javax.inject.PostConstruct annotation
- Understanding Atmosphere's Annotation
- Understanding AtmosphereResource
- Understanding AtmosphereHandler
- Understanding WebSocketHandler
- Understanding Broadcaster
- Understanding BroadcasterCache
- Understanding Meteor
- Understanding BroadcastFilter
- Understanding Atmosphere's Events Listeners
- Understanding AtmosphereInterceptor
- Configuring Atmosphere for Performance
- Understanding JavaScript functions
- Understanding AtmosphereResourceSession
- Improving Performance by using the PoolableBroadcasterFactory
- Using Atmosphere Jersey API
- Using Meteor API
- Using AtmosphereHandler API
- Using Socket.IO
- Using GWT
- Writing HTML5 Server-Sent Events
- Using STOMP protocol
- Streaming WebSocket messages
- Configuring Atmosphere's Classes Creation and Injection
- Using AtmosphereInterceptor to customize Atmosphere Framework
- Writing WebSocket sub protocol
- Configuring Atmosphere for the Cloud
- Injecting Atmosphere's Components in Jersey
- Sharing connection between Browser's windows and tabs
- Understanding AtmosphereResourceSession
- Manage installed services
- Server Side: javadoc API
- Server Side: atmosphere.xml and web.xml configuration
- Client Side: atmosphere.js API