
What you described has a Java parallel:
In the first program, I am reading on-demand from a database - just reading, not making any changes.
This is similar to EJB's entity bean. Usually EJB requires XA driver to preserve database state across the cluster, but in your read-only case, this is not needed. HDBC puts you into the IO monad. You need to get yourself out of IO monad if you believe your code is "pure".
In the second, I am requesting computations to be evaluated externally, in order to take advantage of a grid of machines.
This is similar to J2EE's clustering, where beans can sit on any node of the cluster and be accessed via RMI. The ability to handle (de)serialization is the key here. Java's solution is proprietary, while Microsoft dot NET has choosen SOAP to request computation over network. Network calls will also put you into the IO monad, which has to be hidden in your case.. If you came up with a solution, it might have invented the H2EE. Steve