How to use Sun RPC for large slow procedure calls
Kemp at DOCKMASTER.NCSC.MIL
Kemp at DOCKMASTER.NCSC.MIL
Sat Oct 7 00:35:54 AEST 1989
Gregory Bond writes:
> [description of RPC based database application that sometimes
> takes a long time for lookups]
>
> Does anyone have any idea how to approach this sort of RPC
> application? [...] Or do I drop Sun RPC entirely as the wrong
> tool and handcraft something using "raw" TCP sockets?
No need to use sockets. However you are correct in stating that
lengthening the RPC timeouts is a bad idea.
The accepted solution to this very common situation is to use callback
RPC's, in a scenario something like this:
1. Client requests an action
2. Server does whatever can be guaranteed to finish quickly (checking
request validity, user authentication, whatever) and acknowledges
the request
3. Server does the lengthy job (computation or database lookup) and
when it's finished, sends a callback RPC to the client
This is analagous to asynchronous I/O, and requires a similar amount of
care by the programmer to do the job right. Nonetheless, it *is* the
right way to do it. I am constantly annoyed by people who write Sunview
programs that do lots of computation in notifier event routines, instead
of just starting a job and returning. What you are left with is a
window that just sits there for seconds or minutes, refusing to refresh
itself.
If you want to get fancy, you could have a 'progress meter' that gives
the user some feedback as to how his database query is progressing (and
lets him know if the database server or the net goes down), and gives
him some opportunity to abort the job if it is taking too long or not
going in the right direction.
Dave Kemp <Kemp at dockmaster.ncsc.mil>
More information about the Comp.unix.wizards
mailing list