I know that this subject has been brought up before, but I'm still
wondering what the value of a connection pool is with Riak. In my
app, I'm using Webmachine resources to talk to a gen_server which in
turn talks to Riak. So, in other words, the Webmachine resources
never talk to Riak directly, they must always talk to the gen_server
to deal with Riak. Since Erlang processes are so small and fast to
create, is there really any overhead in having the gen_server create a
new connection (with the same client id) each time it needs to access
Riak?
So the pseudo-code would look like this:
my_webmachine_resource.erl
========================
some_service:persist(MyRecord).
some_service.erl
==============
persist(MyRecord) ->
riak_repository:load(LoadSomething),
riak_repository:persist(MyRecord),
riak_repository:persist(SomethingElse).
riak_repository.erl (this is the gen_server)
================================
persist(...) -> call (...)
load(...) -> call(...)
call(....) ->
Pid = get_connection(ClientId),
DoAction(Pid, ....),
close_connection(Pid) %% Is this even necessary?
Thoughts?
Another approach I thought of was:
some_service.erl
==============
persist(SomeRecord) ->
riak_repository:execute(fun(Pid) ->
riak_repository:persist(..., Pid),
riak_repository:load(...., Pid).
end).
riak_repository.erl
==============
execute(Fun) ->
try
Pid = get_connection(),
Fun(Pid)
after
close_connection(Pid)
end
Is one of these approaches better than the other in dealing with Riak
and vclocks?
Thanks,
Andrew
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com