Giter Site home page Giter Site logo

rpc_reactive's Introduction

Author Pablo Picouto García

My image

Reactive RPC

Here we cover with some examples and explanations how most famous RPC as gRPC or Thrift works.

gRPC

Simple gRCP

My image

An example of how gRPC works between client-server

Reactive

My image

An example of how to use streams gRPC between client-server

Configuration

Once that you have your contracts(proto) ready, you need to build your classes which will be used for the communication between client and server. In these examples we decide to use the maven plugin.

The plugin you need to add in your pom is

  <plugin>
         <groupId>org.xolstice.maven.plugins</groupId>
         <artifactId>protobuf-maven-plugin</artifactId>
         <version>0.5.0</version>
         <configuration>
              <protocArtifact>
                        com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}
              </protocArtifact>
              <pluginId>grpc-java</pluginId>
              <pluginArtifact>
                        io.grpc:protoc-gen-grpc-java:1.4.0:exe:${os.detected.classifier}
              </pluginArtifact>
              </configuration>
              <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
              </executions>
  </plugin>


Thrift

My image

An example of how thrift RPC works between client-server

Configuration

Just like with gRPC once that you have your contracts(thrift) ready, you need to build your classes which will be used for the communication between client and server. In these examples we decide to use the twitter scrooge maven plugin.

The plugin you need to add in your pom is

          <plugin>
                <groupId>com.twitter</groupId>
                <artifactId>scrooge-maven-plugin</artifactId>
                <version>18.2.0</version>
                <configuration>
                    <thriftSourceRoot>src/main/scala/finagle/thrift/idl/</thriftSourceRoot>
                    <thriftNamespaceMappings>
                        <thriftNamespaceMapping>
                            <from>finagle.thrift.idl</from>
                            <to>finagle.thrift</to>
                        </thriftNamespaceMapping>
                    </thriftNamespaceMappings>
                    <language>scala</language> <!-- default is scala -->
                    <thriftOpts>
                        <!-- add other Scrooge command line options using thriftOpts -->
                        <thriftOpt>--finagle</thriftOpt>
                    </thriftOpts>
                    <!-- tell scrooge to not to build the extracted thrift files (defaults to true) -->
                    <buildExtractedThrift>false</buildExtractedThrift>
                </configuration>
                <executions>
                    <execution>
                        <id>thrift-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>thrift-test-sources</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


Avro

My image

An example of how avro encoder/decoder works between client-server

An example of how avro RPC works between client-server

Configuration

Just like with gRPC once that you have your contracts(avro) ready, you need to build your classes which will be used for the communication between client and server. In these examples we use avro-maven-plugin<.

The plugin you need to add in your pom is

           <plugin>
                <groupId>org.apache.avro</groupId>
                <artifactId>avro-maven-plugin</artifactId>
                <version>1.8.2</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>schema</goal>
                            <goal>protocol</goal>
                            <goal>idl-protocol</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
                            <outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Benchmarks

My image

For this benchmark we made 1000 request with Json body for Rest and proto and thrift for RPC.

  • Rest Http finagle client against Grizzly server.

  • Rest Http finagle client against Finagle server.

  • gRPC using standard implementation.

  • gRPC Reactive using reactive StreamObserver.

  • Thrift RPC using Apache thrift.

  • Avro RPC Using Apache Avro.

Results

My image

rpc_reactive's People

Contributors

politrons avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.