Anti-Pattern in AEM: Sharing is Not Always Good.


A big anti-pattern in Adobe Experience Manager is sharing sessions between threads. Besides other problems, it. can. slow. down. repository. read. and. writes. Shared sessions can be the source of memory leaks as well. Or, if a developer is combating memory leaks aggressively, a session can be closed while a thread is using it. Sessions take many forms. Pass a Resource, a Node, or a ResourceResolver between threads and a session has been shared. Services may unknowingly share sessions with threads. When passing a session to a service, a developer needs to be aware of that possibility.

Jörg Hoh came out with a helpful blog post about this. It makes a much larger impact on scaling within Apache Jackrabbit Oak (AEM 6+) than Apache Jackrabbit 2 (AEM/CQ5) because of structural changes within Oak to improve performance. He has some information about places where problems may not be expected. Better yet, he has examples of what to do (and what not to do).

This anti-pattern comes into play easily. I answered two queries about this from two different people yesterday in the space of five minutes. This concept counts as a Must Understand for AEM developers.

CQDump/Things on a content management systemAEM scaling patterns: Avoid shared sessions

About The Author

Deke departed Southern Alabama as a young man, leaving the humidity and fire ants behind. The fire ants are catching up with him. He works for Adobe. Despite that, his opinions expressed on this site are his own and should never, ever, be attributed or blamed on Adobe. Ask him what he thinks of chiggars sometime. Home Page | GitHub | Adobe Blog | Twitter | LinkedIn