RPC Frameworks

RPC Frameworks

My final selection:

Apache Thrift (Facebook) + Apache Zookeeper (made by Yahoo, used everywhere)

  • We need a framework for building modular services.
  • Should be on a server-side only; Consequently the lack of security (ZeroMQ for example) is not a problem here.
  • Must support PHP as main language, and Javascript (on server, as node.js) as secondary, at least

List of RPC frameworks

MessagePack RPC http://msgpack.org/ http://avro.apache.org/ http://thrift.apache.org/ - Win32 missing http://bert-rpc.org/ http://www.xmlrpc.com/ http://json-rpc.org/ - GPL license http://code.google.com/p/protobuf/ - RPC missing


Apache Thrift

No callback functions. Made by Facebook, by people who started Protocol Buffers. Somebody call it Protobuf 2. Sometimes even used (by Evernote) as external API over HTTP (instead of REST).

Instead of trying to implement callbacks with Thrift (something that would have made the protocol significanty heavier I guess), I use a lightweight messaging service (STOMP) to inform the client of asynchronous events.

[Callbacks in Thrift Asynchronous Functions?](http://stackoverflow.com/questions/2554999/callbacks-in-thrift-asynchronous-functions)

Hacking with Thrift as browser-server RPC: Bidirectional browser-webserver RPC with Thrift

mod_thrift.erl: Ejabberd module that provides a Thrift interface for ejabberd (XMPP server). Of course written in Erlang, as ejabberd is.

IDE Syntax highlight support: Thrift 4 Eclipse Plugin Good audio introduction: Programming Throwdown: April 2012

Thrift Whitepaper Thrift: A pragmatic approach to service integration web services - Why did Facebook create Thrift? - Stack Overflow

Extremly fast: Exploring Facebook’s Thrift | LAMPlights

Apache Thrift Quickstart Tutorial « Source Open

Building an internal API / RPC

There are many ways to implement SOA, including REST and SOAP web services, language-specific implementations such as Java RMI, and older approaches using RPC frameworks such as CORBA (which dates back to the 90′s!).

Some folks also decide to build their own service / RPC layer on top of messaging frameworks such as Protocol Buffers or MsgPack. Others may even go as far as implementing their own custom network protocols at the wire level.

There is also Thrift, which I suggest we use.

RPC as a need, not feature

Large system generally comes with many components. In the past, it was normal that it is written in the one, same programming language. However, today, it is very common situation that some of the components would be easier to write in other languages.

For example, in a modern internet system, the frontend communicating layer is often written in a scripting language (PHP, Ruby, etc.) and the components in the back, specialy mission critical, are written in languages that have specific propertie for selected task (usualy higher performance and concurrency - C, Java, etc). And, new server technologies are emerging from a need to solve specific, new problems (such as Javascript on server).

In such environment, Remote Procedure Call (RPC) is a must. RPC is an implementation technique with which a program (RPC client) can delegate function calls to another program (RPC server) as if they were dispatched locally. A RPC client initiates a RPC with a request to a RPC server that specifies the function to be dispatched and the arguments. The server then handles the request, dispatches the corresponding function and sends back the response that encapsulates the invocation result to the client.

This mechanism enables one to use a suitable language for each component.


Further reading


http://blog.programmableweb.com/2011/09/23/short-list-of-restful-api-frameworks-for-php/ » Short List of RESTful API Frameworks for PHP http://www.quora.com/What-tips-would-you-offer-someone-who-is-just-starting-to-built-a-RESTful-API-in-PHP » (1) What tips would you offer someone who is just starting to built a RESTful API in PHP? - Quora

http://www.apifysnippets.com/ :: Apify http://bcosca.github.com/fatfree/ :: PHP Fat-Free Framework: Home http://peej.github.com/tonic/ :: Tonic: The RESTful Web App PHP Micro-Framework

API Documentation: Enterprise API Management and API Strategy | Apigee Is also open-source. API Community Swagger: A simple, open standard for describing REST APIs with JSON Swagger works with Restler.

Restler: Restler: Expose your business objects as REST end-points in JSON,XML,PLIST… for mobile/web/desktop app

FRAPI http://getfrapi.com/ » FRAPI - Focus on business logic, not presentation http://frapi.github.com/what/index.html » What is FRAPI

Slim Framework http://www.slimframework.com/ » Home - Slim Framework for PHP 5

REST in node.js

http://www.quora.com/Node-js/Which-Node-js-framework-is-best-for-building-a-RESTful-API » (1) Node.js: Which nodejs framework is best for building a restful api? - Quora

Favorite frameworks:

Honorable Mentions:

https://github.com/gjritter/nerve/ » gjritter/nerve https://github.com/keithnlarsen/restmvc.js » keithnlarsen/restmvc.js


REST Tool: Open-sourced with backbone.js: ApiDocco Old domain was http://apidocco.com/, but now renamed to: ApiEngine/apiengine-client

Others = non REST

Storm (more like RPC)

Open-sourced by Twitter in 2011. Storm is used by a number of companies (Twitter and Groupon being two of the better known) and relies on Zookeeper.

Tutorial · nathanmarz/storm Wiki Implementation of a spout that receives data from Scribe

Support for PHP and node.js: Lazyshot/storm-php Lazyshot/storm-node

Apache Thrift (RPC framework)

What is the advantage of using Thrift, as opposed to REST API?

If your service is completely internal to your product/company, using Thrift will be a huge win as it cuts down barriers to communication from various languages and configurations.

Thrift provides a great framework for developing and accessing remote services. It allows developers to create services that can be consumed by any application that is written in a language that there are Thrift bindings for (which is…just about every mainstream one, and more).

Thrift: The Missing Guide

Is it safe to have a Thrift service exposed to the Internet as an API for the public? - Quora So API Together: Evernote and Thrift | Evernote Tech Blog LibraryFeatures - Thrift Wiki Why Thrift, Why not HTTP RPC(JSON+gzip) - Stack Overflow Difference between Apache Thrift and ZeroMQ - Stack Overflow Difference between Thrift , JSON and REST - Stack Overflow Apache Thrift, it’s ok but nothing amazing

Thrift and ZeroMQ in pair, thrift to format the message, and ZeroMQ to transport it.

[thrift/contrib/zeromq at trunk · apache/thrift · GitHub](https://github.com/apache/thrift/tree/trunk/contrib/zeromq)

Thrift–Part One: Introduction « 1b1t (One Bit)

Thrift and PHP Creating a public API with Apache Thrift - PHP Thrift PHP server PHP Thrift Examples · GitHub

Apache Thrift Tutorial – A PHP client « Ian Chan’s Blog robwilkerson/Thrift-Client-Server-Example–PHP-

Thrift vs. Protocol Buffers Thrift provides a great framework for developing and accessing remote services. It allows developers to create services that can be consumed by any application that is written in a language that there are Thrift bindings for (which is just about every mainstream one, and more).

Biggest differences of Thrift vs Protocol Buffers? - Stack Overflow RPC is another key difference. Thrift generates code to implement RPC clients and servers wheres Protocol Buffers seems mostly designed as a data-interchange format alone.

What are the key differences between Apache Thrift, Google Protocol Buffers, MessagePack, ASN.1 and Apache Avro? - Stack Overflow

Not possible: PHP Thrift Asynchronous Functions with Callback php - Callbacks in Thrift Asynchronous Functions? - Stack Overflow

But obviously none of these are true bi-directional messaging. We’ve tried to keep the Thrift interfaces as simple as possible and focused on the core RPC use case, which has meant leaving some stuff like this out.

Fork of Apache Thrift, Add nonblocking PHP server for thrift volca/thrift thrift/test/php/TestNonblockingServer.php at trunk · volca/thrift

Fork of Thrift, Windows port: aubonbeurre/thrift at winthriftnb-0.9.x-1

But Trift and protobuf are by far the most popular and a common question people ask is — which one should I use?

Protocol Buffers, Avro, Thrift & MessagePack - igvita.com Thrift vs. Protocol Buffers | Digital Digressions by Stuart Sierra


There is an RPC based on MessagePack. MessagePack-RPC is the remote procedure call system on top of the MessagePack serialization library.

Design of RPC - MessagePack

MessagePack-RPC Features

  • Asynchronous RPC at the client side (I think it’s not possible in Thrift PHP library) And also, please remember
  • MessagePack supports “Streaming Deserializer”. When you got the data from the network, the server/client are able to deserialize in a streaming way.

Difference between MessagePack-RPC and Thrift Way faster. Introduction to MessagePack-RPC | MessagePack Blog

PHP QuickStart for PHP - MessagePack

Node.js implementation of the Msgpack-RPC bpot/node-msgpack-rpc austinchau/msgpack-rpc-node

Why Not MessagePack? cross platform - Should I use CORBA, MessagePack RPC or Thrift, or something else entirely? - Stack Overflow My thoughts on MessagePack — Gist

Mobile RPC

KryoNet runs on both the desktop and on Android. kryonet - TCP and UDP client/server library for Java Kryo (used to do the serialization in KryoNet) java - Kryo serialization library: is it used in production? - Stack Overflow

Avro is RPC Framework Apache Avro™ 1.7.1 Documentation Data Serialization + RPC with Avro & Ruby - igvita.com But without PHP client.

ICE: which uses Google Protocol Buffers for RPC

RestMQ - Redis based message queue

Protocol Buffers (Protobuf)

Made by Google.

Protocol buffers are now Google’s lingua franca for data – at time of writing, there are 48,162 different message types defined in the Google code tree across 12,183 .proto files. They’re used both in RPC systems and for persistent storage of data in a variety of storage systems. #

  • There is some (code generation stub) support for writing RPC, which could be enough. #
Syntax highlighting:

In Sublime Text 2: jrk/protobuf.sublime-package · GitHub In Eclipse: protoclipse - An Eclipse plug-in for “Google Protocol Buffers” - Google Project Hosting


PHP: Protobuf-PHP Another one: undr/phpbuf · GitHub RPC call implements: http://code.google.com/p/protobuf-socket-rpc/

ØMQ and Google Protocol Buffers


Remote Procedure Calls over ZeroMQ. ZeroRPC

ZeroRPC uses ZeroMQ as a transport, but uses a communication protocol that is transport-agnostic. Wire (or transport) layer; a combination of ZMQ and MessagePack.

Why we did implement this? Unmodified remote code? Build reliable, traceable, distributed systems with ZeroMQ - YouTube

Similar, but with browser: dotcloud/stack.io · GitHub

Communication among processes on the server-side is efficient because there is no intermediate broker. From the client-side, requests come into a node.js process via socket.io. Express-like middleware then processes these requests to add things like authentication and authorization.

Bridge RPC

RabbitMQ (broker based) at transport layer.

Bridge - RPC Framework for Building Modular Services and Cross-Language Applications Bridge is a new RPC framework

Compared to ZeroRPC / different in transport layer

ZeroRPC is pretty cool but it’s a different concept. It uses 0MQ sockets as the transport whereas we use RabbitMQ. This allows us to do zero-configuration service discovery and complex routing.

Bridge allows you to securely expose APIs to “untrusted” clients such as browsers and mobile clients. ZeroRPC does not do this because 0MQ doesn’t allow such access control.

Bridge currently uses a central broker, ZeroRPC is broker-less.


ZeroC’s Internet Communications Engine (ICE)

Welcome to ZeroC, the Home of Ice

Bindings / clients

ZeroC - Ice for PHP

A server framework implementing the ZeroC Ice RPC protocol for Node.js ajtack/hail


Connecting PHP and node.js, almost natively. substack/dnode

DNode protocol for PHP

bergie/dnode-php DNode: Make PHP and Node.js talk to each other - Henri Bergius

This project implements the DNode remote procedure call protocol for PHP. The intent is to enable PHP scripts to act as part of a distributed Node.js cloud, allowing Node to call PHP code, and PHP to call Node code.

Dnode-php uses the ReactPHP event loop (it must use it - it’s the natural way).

Author wrote on Twitter: the PHP client is faster than the #nodejs one. *Twitter

There is lightweight PHP client-only without callback support. erasys/dnode-php-sync-client

Dnode can have browser clients. javascript - What is the difference between dnode and nowjs? - Stack Overflow

Hook.io uses Dnode as it’s primary TCP transport Hook.io For Dummies, Part 1 - Introduction | Home


Introducing BERT and BERT-RPC BERT and BERT-RPC 1.0 Specification

Small community. Problem with learning the thing.

Bindings: dhotson/bert-php · GitHub Not sure if it can act as BERT-RPC servers. Problems with node.js bindings (not updated).

date 01. Jan 0001 | modified 10. Jun 2024
filename: RPC - Frameworks