Is eager loading a bad idea?.
Somebody said that eager loading was a bad idea in distributed systems. I don't know, i have to think about this a minute.
When I am eager loading, which means for me at the start time, or at a predicted time, i load what i need in advance and cache all i loaded. if the loading/cache is optimized , what really is the problem?
I like the concept of eager loading much better then that of lazy loading which sometimes occur at the most inappro times.If I am going to load the same data, isn't it preferable that i do that at my lowest peak..
I am researching as to the pitfalls of eager loading. Can anyone eloborate?
[I bla-bla-bla]
Eager loading rocks! The trick about eager loading is to do it asynchronously in the background, maybe in a trickle mode or in a low priority thread so as not to impact the normal operation of the application too much and allow fast startup. In our commerical caching product folks can just drop in their own custom eager loader by just changing an XML deployment document which is very handy. By adding management agents to watch the cache, it can be quite easy to add groovy predictive caching eager loaders.
This reminds me a little of the Prevayler thread. In distributed systems many of the pitfalls and percieved slow-downs are often related to performing synchronous operations and increasing latency. Transferring large amounts of information around a network, to where its required isn't a bad thing - though its generally a bad idea to block threads for a significant amount of time while things happen - its much better to use an asynchronous model (see the SEDA paper for more details).
e.g. if a database is slow to update, rather than blocking a Servlet making your application appear slow and using up scarce threads on your heavily loaded web server, try just post a command object to a JMS Queue and perform the database write asynchronously. Your servlet now is faster and can support a higher throughput.
Similarly adding eager loading synchronously to an operation in your system will slow things down, since your Servlet may have to wait for the eager loading to complete. However if the eager loading can be done asynchronously in the background, you get all the great benefits of predictive caching yet without the slowdown.
So in summary, eager loading, asynchronous processing and SEDA style architectures are good.
4:43:25 AM
|