Приглашаем посетить
Кулинария (cook-lib.ru)

Chapter 16.  RPC: Interacting with Remote Services

Previous
Table of Contents
Next

16. RPC: Interacting with Remote Services

SIMPLY PUT, REMOTE PROCEDURE CALL (RPC) services provide a standardized interface for making function or method calls over a network.

Virtually every aspect of Web programming contains RPCs. HTTP requests made by Web browsers to Web servers are RPC-like, as are queries sent to database servers by database clients. Although both of these examples are remote calls, they are not really RPC protocols. They lack the generalization and standardization of RPC calls; for example, the protocols used by the Web server and the database server cannot be shared, even though they are made over the same network-level protocol.

To be useful, an RPC protocol should exhibit the following qualities:

  • Generalized Adding new callable methods should be easy.

  • Standardized Given that you know the name and parameter list of a method, you should be able to easily craft a request for it.

  • Easily parsable The return value of an RPC should be able to be easily converted to the appropriate native data types.

HTTP itself satisfies none of these criteria, but it does provide an extremely convenient transport layer over which to send RPC requests. Web servers have wide deployment, so it is pure brilliance to bootstrap on their popularity by using HTTP to encapsulate RPC requests. XML-RPC and SOAP, the two most popular RPC protocols, are traditionally deployed via the Web and are the focus of this chapter.

Using RCPs in High-Traffic Applications

Although RPCs are extremely flexible tools, they are intrinsically slow. Any process that utilizes RPCs immediately ties itself to the performance and availability of the remote service. Even in the best case, you are looking at doubling the service time on every page served. If there are any interruptions at the remote endpoint, the whole site can hang with the RPC queries. This may be fine for administrative or low-traffic services, but it is usually unacceptable for production or high-traffic pages.

The magic solution to minimizing impact to production services from the latency and availability issues of Web services is to implement a caching strategy to avoid direct dependence on the remote service. Caching strategies that can be easily adapted to handling RPC calls are discussed in Chapter 10, "Data Component Caching," and Chapter 11, "Computational Reuse."



Previous
Table of Contents
Next