Blog

Play 2.0: Scalable Caching and Session Store Plugins with Aerospike

Author's photo
Ashish Shinde
Principal Software Developer
February 24, 2016|3 min read

The performance of the caching tier could make or break your application.

We at Aerospike have released caching and session store plugins for the Play Framework. Thanks to these plugins, you’ll be able to use the Aerospike database quickly and easily within the Play 2.0 Framework from Java or Scala, and with no application code changes. Although Aerospike’s reliability and persistence allow it to be used as the core database for an application, Aerospike’s extremely low and predictable latency, combined with its ability to both read and write rapidly and expire data accurately, make it an excellent choice for both caching and session management.

Caching is an important optimization for modern web applications. You could implement a read cache of models that do not change frequently – thus reducing the load of your slower data source and increasing throughput. You could, in fact, cache entire HTTP responses if the response is guaranteed to be correct, or if a slightly stale response is acceptable.

The session store is another component within a modern application that benefits from extremely low latency and high availability. When working at higher levels of scale, the session store must be accessed from every application server. As it stores key information like authentication tokens or shopping carts, the availability of this store is primordial to the entire application’s performance and usability. While using a database for session storage is often debated, the per-request overhead of browser cookies means database session storage is becoming common practice. To achieve that, you need a database that can consistently provide low latency.

For example, consider a web application that provides group chat or chatting rooms. Information about users participating in rooms, presence information, user status, etc. can be cached. These objects have a strong bias toward read access, although they must be updated constantly. Information like recently viewed friends or pointers to recent chat rooms would be in a session store.

Although both caches and session stores can be unreliable by design, higher availability and larger data sizes provide great operational benefits. If your cache is continually having problems, database load goes way up, possibly enough to cause very significant user experience problems and a late-night scramble to restart and undergo maintenance. If you can provide session information that lasts longer, a user can pop back into your application and retrieve recent state, regardless of browser or device.

The Aerospike Play Framework plugins support the following:

  • Named caches

  • Cache key expiration

  • Storage and retrieval of POJOs

These plugins are made available to the community under the Apache 2 license, and can be found on Github here. We look forward to your comments and community contributions to this effort.