DEV Community

Discussion on: ORMs, Lazy Loading and Web Applications

Collapse
 
ruidfigueiredo profile image
Rui Figueiredo

Hi Jonathan,

Yes, you could store the context in the user session. However, I've never seen that being done and I suspect that is because that wouldn't scale very well (a lot of overhead per user) and it would introduce difficulties if you were to have load balancing.

Collapse
 
jonathan_hepp profile image
Jonathan Hepp

First, arguably nothing scales very well if badly implemented.
And second, not every software is Twitter. There is a huge realm of enterprise software where the domain and the user base is well defined enough that throwing out the context after every request would be a waste. Like I said, use cases.
Furthermore, the application doesn't even have to stick to one model or another, large systems can define a context for entities that are to be discarded after every request, like reporting data. And have another context attached to session for data related to the user. It is even possible to have a specific context that is application scoped, and never gets destroyed, that can hold general configuration data.
That's what profiling is for.