Skip to content

Instantly share code, notes, and snippets.

View jkvor's full-sized avatar

Jacob Vorreuter jkvor

  • Google
  • San Francisco
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jkvor on github.
  • I am jkvor (https://keybase.io/jkvor) on keybase.
  • I have a public key whose fingerprint is 6FAC AB46 E9CD 8007 70F1 21BC CB61 9C17 E4F7 3935

To claim this, I am signing this object:

Overview

Logplex is the Heroku logging multiplexor. Components throughout the Heroku platform publish syslog packets that are received and processed by a grid of logplex nodes. Users may retrieve their logs through requests to the logplex API.

Logplex relies on channel, token, drain and session objects. This data is stored in redis, but also cached for fast lookups in a normalized format in ETS tables. When logplex boots, all of the keys are loaded from redis and cached in ETS. When an object is created or deleted through the logplex API, other logplex nodes are notified of the change (via Erlang rpc calls) so that they may update their local ETS cache. We would like to explore the possibility of using nsync to manage replicating the dataset into ETS. This would speed up logplex boot times and save us from making Erlang RPC calls to update local caches on remote nodes.

To get started, fork logplex on github and follow the directions below to get logplex running locally.

Once you are up and runni

-module(test_sup).
-behaviour(supervisor).
%% Supervisor callbacks
-export([init/1, start_child/0, start_link/0]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
start_child() ->
-module(test).
-behaviour(gen_server).
-export([start_link/0, init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
%% API functions
start_link() ->
gen_server:start(?MODULE, [], []).
init([]) ->
2010-10-29T14:00:30-07:00 app[web.1]: beginning request 0
2010-10-29T14:00:30-07:00 app[web.1]: finished request 0
2010-10-29T14:00:30-07:00 heroku[router]: GET growing-dusk-20.heroku.com/ dyno=web.1 queue=0 wait=0ms service=7ms bytes=215
2010-10-29T14:00:30-07:00 heroku[nginx]: GET / HTTP/1.1 | 208.66.27.62 | 246 | http | 200
2010-10-29T14:00:38-07:00 app[web.1]: beginning request 1
2010-10-29T14:01:08-07:00 heroku[router]: Error H12 (Request timeout) -> GET growing-dusk-20.heroku.com/timeout dyno=web.1 queue=0 wait=0ms service=0ms bytes=0
2010-10-29T14:01:08-07:00 heroku[nginx]: GET /timeout HTTP/1.1 | 208.66.27.62 | 3364 | http | 502
2010-10-29T14:01:23-07:00 app[web.1]: finished request 1
2010-10-29T14:01:23-07:00 app[web.1]: beginning request 2
class Bench
def counter
@@counter ||= 0
end
def call(env)
STDOUT.puts "beginning request #{counter}"
sleep 45 if env['PATH_INFO'] == '/timeout'
body = 'OK'
headers = {
#include <stdio.h>
#include "erl_driver.h"
typedef struct {
ErlDrvPort port;
} example_data;
static ErlDrvData example_drv_start(ErlDrvPort port, char *buff) {
example_data* d = (example_data*)driver_alloc(sizeof(example_data));
d->port = port;
-module(module_name).
-behaviour(gen_server).
%% gen_server callbacks
-export([start_link/0, init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3]).
%% API functions
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
{release,
{"foo","0.1"},
{erts,"5.7.2"},
[ {stdlib,"1.16.2"},
{kernel,"2.13.2"} ]
}.
-module(foo_app).
-behaviour(application).
-export([start/2, stop/1, init/1]).
start(_, _) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
stop(_) ->
ok.