Показаны сообщения с ярлыком erlang. Показать все сообщения
Показаны сообщения с ярлыком erlang. Показать все сообщения

вторник, 15 мая 2012 г.

Never use run_erl

In one of my projects I used run_erl to launch Erlang VM in daemon mode, rotate logs, etc. If seemed fine to use standard Erlang tool. run_erl is a part of Erlang distribution.

I discovered unexpected performance problem running production application with run_erl. Application caused high iowait without any reason.

It was hard to discover the certain reason, but after few hours I found out that run_erl fsyncs on every log message, causing inadequate io load. 

четверг, 29 декабря 2011 г.

gen_server antipattern

Two gen_server-s should never gen_server:call each other:

  1. gen_server A calls gen_server B: it sends request message and blocks on receive.
  2. gen_server B calls gen_server A: it sends request message and blocks on receive.
  3. Neither A nor B can respond each others requests, rendering a deadlock.

вторник, 13 января 2009 г.

md5 hexdigest in Erlang

Recently I got my hands dirty with Erlang.

Erlang's builtin md5 function gives out a binary type, while I needed a hexademical string. I found a solution somewhere in the internet, but it was buggy. Note that case statement. This is to fix the bug in the original solution (sorry, dont remember the link). Here is the snippet:


md5_hexdigest(String) ->
string:to_lower(
lists:flatten(
lists:map(
fun(V) ->
case httpd_util:integer_to_hexlist(V) of
[A, B] -> [A, B];
[B] -> [$0, B]
end
end,
binary_to_list(erlang:md5(String))
))).