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.
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
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.
Extremly fast: Exploring Facebook’s Thrift | LAMPlights
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.
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.
- What is a good guide for writing and implementing a REST API? - Quora
- API Anti Patterns
- How To Design A Good API and Why it Matters - YouTube
- RESTful API Design: Second Edition - Webinar - Video & slides
- Give it a REST
- Architectural Styles and the Design of Network-based Software Architectures
- How To Create An API? (10 Tutorials)
REST in PHP
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
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.
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
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.
Apache Thrift (RPC framework)
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).
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 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.
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?
There is an RPC based on MessagePack. MessagePack-RPC is the remote procedure call system on top of the MessagePack serialization library.
- 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
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
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. #
In Sublime Text 2: jrk/protobuf.sublime-package · GitHub In Eclipse: protoclipse - An Eclipse plug-in for “Google Protocol Buffers” - Google Project Hosting
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.
RabbitMQ (broker based) at transport layer.
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.
- Bridge’s binary serialization is MessagePack
- Written in erlang (using Cowboy and RabbitMQ)
- no PHP option (no PHP client)
- No configuration files or IDLs (contrary to Apache Thrift, for example)
- Bridge was designed for both client-server and server-server interactivity, with bidirectional communication to any client front-end applications
- So, Flotype (http://www.flotype.com/) (from NowJS) is now Bridge? Y Combinator Startup Flotype Rebrands As Bridge And Launches A New Product To Save Startups Millions Of Dollars - Business Insider
- Problem with licence
ZeroC’s Internet Communications Engine (ICE)
Problem with licence.
Bindings / clients
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
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
Hook.io uses Dnode as it’s primary TCP transport Hook.io For Dummies, Part 1 - Introduction | Home
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).