A fast remote procedure call library for datacenters

What is eRPC?

eRPC is a fast Remote Procedure Call library designed for modern datacenter networks. It runs over both Ethernet and InfiniBand, and performs comparably to RDMA. Currently, eRPC is intended for use in C++ applications running on bare-metal clusters.


Get started

Here's a hello, world example of how to use eRPC. The server and client run on separate machines, named fawn-pluto0 and fawn-pluto1, respectively. The client sends an RPC to the server containing the text "hello", and the server replies with "world". You can browse the example in the eRPC repository.


#include <stdio.h>
#include "rpc.h"

erpc::Rpc<erpc::CTransport> *rpc;

void req_handler(erpc::ReqHandle *req_handle, void *) {
  printf("%s\n", reinterpret_cast<char *>(req_handle->get_req_msgbuf()->buf));
  auto &resp = req_handle->pre_resp_msgbuf;
  rpc->resize_msg_buffer(&resp, strlen("world"));
  sprintf(reinterpret_cast<char *>(resp.buf), "world");

  rpc->enqueue_response(req_handle, &resp);

int main() {
  std::string server_uri = "fawn-pluto0:31850";
  erpc::Nexus nexus(server_uri, 0, 0);
  nexus.register_req_func(17 /* request type */, req_handler);

  rpc = new erpc::Rpc<erpc::CTransport>(&nexus, nullptr, 0, nullptr);
  rpc->run_event_loop(10000 /* 10 seconds */);



#include <stdio.h>
#include "rpc.h"

erpc::Rpc<erpc::CTransport> *rpc;
erpc::MsgBuffer req;
erpc::MsgBuffer resp;

void cont_func(void *, void *) { printf("%s\n", resp.buf); }

void sm_handler(int, erpc::SmEventType, erpc::SmErrType, void *) {}

int main() {
  erpc::Nexus nexus("fawn-pluto1:31850", 0, 0);

  rpc = new erpc::Rpc<erpc::CTransport>(&nexus, nullptr, 0, sm_handler);
  int session_num = rpc->create_session("fawn-pluto0:31850", 0);

  while (!rpc->is_connected(session_num)) rpc->run_event_loop_once();

  req = rpc->alloc_msg_buffer_or_die(strlen("hello"));
  sprintf(reinterpret_cast<char *>(req.buf), "%s", "hello");
  resp = rpc->alloc_msg_buffer_or_die(strlen("world"));

  rpc->enqueue_request(session_num, 17, &req, &resp, cont_func, nullptr);
  rpc->run_event_loop(1000 /* 1 second */);

  delete rpc;



eRPC is available under the Apache License, Version 2.0.


Email Anuj Kalia ([email protected]) if you have any questions or suggestions, or open an Issue or PR on GitHub.