美文网首页
RPC、Yar、gRPC

RPC、Yar、gRPC

作者: michael_jia | 来源:发表于2016-12-03 15:37 被阅读328次

自 11 月后端结构调整正式启动已有月余,效果初现;
PHP Yar(Yet Another RPC Framework)是我们采取的措施之一;
版本 1.3 开发过程中,Yar 服务 5XX 错误频频,问题解决速度远低于期望;
调试(Debug)技术、测试技术、观测手段的匮乏,恐怕是其中最大的原因之一;
源于超人在 PHPUnit 上的 最新尝试,我们试图在这方面上一个台阶:高质量的敏捷交付;

RPC(Remote Procedure Calling) Mechanism

A remote procedure is uniquely identified by the triple: (program number, version number, procedure number) The program number identifies a group of related remote procedures, each of which has a unique procedure number. A program may consist of one or more versions. Each version consists of a collection of procedures which are available to be called remotely. Version numbers enable multiple versions of an RPC protocol to be available simultaneously. Each version contains a a number of procedures that can be called remotely. Each procedure has a procedure number.

Yar 在 GitHub

Yar is a RPC framework which aims to provide a simple and easy way to do communication between PHP applications.
It has the ability to concurrently call multiple remote services.

  • 是一个 PECL 扩展,属于 Web Service 分类;
  • 采用 HTTP 协议传输数据;
  • 多种 data packager:php,json,msgpack;
    msgpack 需要单独安装扩展;
  • Runtime Configure


示例
  • yarserver.php
<?php
class API {
    public function testName($name) {
        error_log("Hello, $name\n", 3, "/logs/yar.log");
        return "Hello, $name";
    }
    public function testAdd($a, $b) {
        $c = $a + $b;
        error_log("$a + $b = $c\n", 3, "/logs/yar.log");
        return "$a + $b = $c";
    }
}
$service = new Yar_Server(new API());
$service->handle();
<?php
    $client = new Yar_Client("http://api.example.com/yarserver.php");
    echo $client->testName("michael");
    echo $client->testAdd(2,3);
如何对 RPC 服务进行单独测试?
关于 gRPC

Google 名下的开源项目;


Works across languages and platforms
  • gRPC Concepts
    Like many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. By default, gRPC uses protocol buffers as the Interface Definition Language (IDL) for describing both the service interface and the structure of the payload messages.
  • A Basic PHP Programmer’s Introduction to Working with gRPC
  • Why use gRPC?
    With gRPC you can define your service once in a .proto file and implement clients and servers in any of gRPC’s supported languages, which in turn can be run in environments ranging from servers inside Google to your own tablet - all the complexity of communication between different languages and environments is handled for you by gRPC. You also get all the advantages of working with protocol buffers, including efficient serialization, a simple IDL(Interface Definition Language), and easy interface updating.
  • Protocol Buffers - Google's data interchange format.
    Protocol Buffers (a.k.a., protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. You can find protobuf's documentation on the Google Developers site.
  • Protocol Buffers are similar to the Apache Thrift (used by Facebook) or Microsoft Bond protocols.
    Comparison of data serialization formats.
  • gRPC library for PHP
  • SOASOA Reference Model
  • HTTP Status Code 499
    HTTP 499 in Nginx means that the client closed the connection before the server answered the request. In my experience it is usually caused by client side timeout. As I know it's an Nginx specific error code.

https://gist.github.com/dzlab/2e6e79419877dc29d2efc63ae5974fd5
https://danielmiessler.com/blog/log-post-data-nginx/#gs.ZM_5pEY
http://developers.redhat.com/blog/2016/05/23/configuring-nginx-to-log-post-data-on-linux-rhel/
http://stackoverflow.com/questions/4939382/logging-post-data-from-request-body
https://laracasts.com/discuss/channels/general-discussion/laravel-and-rpc
http://restfulapi.nl/#what1
http://www.jsonrpc.org/
https://miniflux.net/documentation/json-rpc-api
http://pages.cs.wisc.edu/~remzi/OSTEP/dist-intro.pdf

相关文章

  • RPC、Yar、gRPC

    自 11 月后端结构调整正式启动已有月余,效果初现;PHP Yar(Yet Another RPC Framewo...

  • golang grpc

    golang grpc rpc种类 grpc含义 gRPC是Google的RPC框架,开源、高性能、跨语言,基于H...

  • gRPC介绍

    [TOC] gRPC gRPC介绍 gRPC是什么? RPC和RESTful的区别是什么? RPC的消息传输可以是...

  • 2019-01-26Yar实现RPC

    用Yar扩展实现RPC RPC (Remote Procedure Call),远程过程调用。是一种进程间通信技术...

  • gRPC SkyLB.md

    gRPC SkyLB gRPC 作为一款高性能、通用的 RPC 框架,相比传统的RPC框架有着自己天然的优势: p...

  • grpc简介

    gRPC[https://grpc.io/] 是一种与语言无关的高性能远程过程调用 (RPC) 框架。 gRPC ...

  • gRPC 学习笔记

     gRPC 学习笔记,记录gprc一些基本概念.  gRPC正如其他 RPC 系统,gRPC 基于如下思想:定义一...

  • grpc初探

    1 grpc的定义 grpc good rpc grpc使用protobuf文件声明服务,服务端和客户端都通使用...

  • C++ —— github —— 开源库记录(1-10)

    gRPC - An RPC library and framework(1) 链接:https://github....

  • 什么是RPC?

    1. 基本的RPC模型 主要介绍RPC是什么,基本的RPC代码,RPC与REST的区别,gRPC的使用 1.1 基...

网友评论

      本文标题:RPC、Yar、gRPC

      本文链接:https://www.haomeiwen.com/subject/gldcmttx.html