RPC Application: Installation and application of the Apache thrift Ubuntu 14.04

Source: Internet
Author: User

The project uses an RPC technology, open source Apache thrift, exactly what RPC is, what the purpose is, below is the most understandable summary.

An RPC usage scenario, principle and use method

1. What is RPC

RPC (remote Procedure call, long-distance procedure calls) is built on the socket, and for an analogy, the main program running on one machine can invoke the prepared subroutine on the other machine, just like LPC (local procedure Call).

The lower the level, the more complex the code, the greater the flexibility, the higher the efficiency, the higher the abstraction, the simpler the code, and the less efficient. The difference between socket and RPC illustrates this again.

In traditional programming concepts, the process is done locally by the programmer, and can only be confined to a piece of code that runs locally, that is, the running relationship between its main program and the process is a local call relationship. Therefore, this kind of structure is unable to adapt to the actual demand today with the development of the network. As we all know, the traditional process call pattern can not make full use of the resources of other hosts on the network (such as CPU, memory, etc.), and can not improve the sharing of the code between entities, so that the host resource is wasted.

With RPC, we can take advantage of non-shared-memory multi-processor environments, such as multiple workstations connected over a local area network, so you can easily distribute your applications across multiple workstations, as if the application were running on a multiprocessor computer. You can easily realize the process code sharing, improve the utilization of system resources, can also be a large number of numerical processing operations on the processing capacity of the system to run, thereby reducing the burden on the front-end machine.

RPC as a common C/s development method, efficient and reliable development. But the basic principle of the RPC method is to ignore the specifics of the communication with the simplicity of the module invocation, so that the programmer does not care about the communication protocol between C/S and focuses on the implementation process. That's it. RPC-generated communication packets may not have the most appropriate treatment for each application, and the same valid data is transferred compared to the socket method, and RPC consumes more network bandwidth.
RPC is implemented on the basis of the socket, which requires more network and system resources than the socket. In addition, while the program is optimized, the programmer can directly modify the Rpcgen generated by the puzzling source program, but for the pursuit of high-efficiency RPC design, The simplicity of the gains is greatly weakened.

2.structure of RPC and its calling mechanism

As mentioned earlier RPC is actually a C/s programming mode, a bit like the C/S Socket programming mode, but it Higher Layer . When we set up the RPC service, the client's invocation parameters pass through the underlying RPC transport channel, either UDP or TCP (or ti-rpc-independent), and go to the appropriate RPC application server based on the destination address provided before the transfer and the RPC upper application number. And the client is waiting until an answer is received or the time out timeout is signaled. When the server-side obtains the request message, it performs the appropriate operation and returns the result to the client, based on the instance entry address that tells the RPC system when the RPC is registered.

When an RPC call is finished, the corresponding thread sends the corresponding signal, and the client program continues to run.

In this process, a remote procedure has three elements that are uniquely identified: The program number, the version number, and the procedure number.

A program number is a remote procedure that distinguishes a set of related and unique processes. A program can have one or several different versions, and each version of the program contains a series of processes that can be called remotely, through the introduction of the version, so that the different versions of RPC can provide services at the same time. Each version contains a number of procedures that are available for remote invocation, each with its own unique procedure number.

3. RPC-based application system development

After a brief introduction to the RPC principle, we will continue to discuss how to develop RPC-based application systems.

In general, when developing RPC, we usually divide it into three steps:

A. define a client/server communication protocol: the communication protocol described here refers to the name that defines the service process, the data type of the calling parameter, and the data type of the return parameter, including the underlying transport type (which can be UDP or TCP). Of course, the RPC underlying function can also automatically select a connection type to establish TI-RPC. The simplest way to generate a protocol is to use a protocol compiler tool, often with Rpcgen, which I'll describe in detail in a later instance.

B. develop client programs.

C. develop server-side programs.

When developing client and server-side programs, RPC provides us with different levels of development routines called interfaces. Different levels of interfaces provide different levels of control over RPC. Generally can be divided into 5 levels of programming interface.

Two Apache thrift installation and use scheme

1. Installation method

Download Apache Thrift

2. Install the required dependent libraries

sudo apt-get install Libboost-dev libboost-test-dev libboost-program-options-dev Libboost-system-dev Libboost-filesystem-dev Libevent-dev automake Libtool Flex Bison pkg-config g++ Libssl-dev

3. Configure the installation: After extracting, go to the top level directory

./configure--with-boost=/usr/localmake Make Install

In this way, the installation is successful, there is no difficulty, such as viewing the version and the generated dynamic library 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/54/2F/ Wkiom1r7idfdesnqaafxjq_ctjc674.jpg "title=" 2014-11-30 21:54:46 screen. png "alt=" wkiom1r7idfdesnqaafxjq_ctjc674.jpg "/ >

4. How to use

adjourned

This article from "LINUXQT Jinan high-tech Zone" blog, please be sure to keep this source http://qtlinux.blog.51cto.com/3052744/1584856

RPC Application: Installation and application of the Apache thrift Ubuntu 14.04

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.