erlang

How to refine the debugging?

假装没事ソ 提交于 2019-12-06 13:28:44
Crash report (SASL) gives more or less where and why a bug happens. But is it possible to refine this (the function, the line de code, etc) ? If you can reproduce the fault, the best way to get more information is to put a dbg trace on sections in question and review that output. dbg:tracer(),dbg:p(all,c),dbg:tpl(Mod,Func,x). This usually does the trick for me. Replace Mod and Func with whatever module and function you want to debug. If you are looking for more detailed post-mortem logging then sasl and the error_logger are your friends. There are of course times when SASL does not give you

Erlang的Web库和框架

陌路散爱 提交于 2019-12-06 13:02:05
Yaws Yaws是一个高效处理动态页面的web服务器,因为Yaw由应用模块【appmods(application modules)】构建,所以其中的appmods可以被我们构造的API替代。 Yaws的文档做的不错,重要的是能够植入到监督树的层次结构中(supervision,Erlang/OTP 设计原则里面的概念,简单来说,为了系统的稳定可靠,一个进程应当由另外的进程来监督和管理,这些监督进程构成了监督树) Mochiweb 它应该算是在erlang的web相关的开发里面使用最多的,是个有自己独特之处的web服务器。 文档做的一般,有个”不好“(相对作者来说)的地方就是,mochiweb的很多模块使用参数化模块的语法特性(注:也叫抽象模块,erlang的一种编 程实践或者叫做语法规则,官方不再推荐使用,我也是在mochiweb里面第一次遇到这种写法),这样做的一个好处,使得mochiweb更容易嵌入到其 他的应用中。 Misultin 支持websockets,结构上与Mochiweb相似 可以去看Misultin的 wiki,有很多文档和非常棒的例子。 Cowboy 与mochiweb十分相似,相比之下:源码里面没有使用参数化模块的语法特性(看来作者对parameterized modules很头疼);使用单独的一个模块来处理所有的请求。

erlang on google app engine?

放肆的年华 提交于 2019-12-06 12:52:17
I know python can be run on GAE what is different erlang and python in lay man term? can erlang run on google app engine ? Erlang and Python are programming languages, and each language has one or more "runtimes" that allow you to run programs written in those languages. GAE supplies a Python runtime. GAE has no support for Erlang programs. 来源: https://stackoverflow.com/questions/1654759/erlang-on-google-app-engine

[转]RabbitMQ集群原理与搭建

蹲街弑〆低调 提交于 2019-12-06 12:47:26
摘要:实际生产应用中都会采用消息队列的集群方案,如果选择RabbitMQ那么有必要了解下它的集群方案原理 一般来说,如果只是为了学习RabbitMQ或者验证业务工程的正确性那么在本地环境或者测试环境上使用其单实例部署就可以了,但是出于MQ中间件本身的可靠性、并发性、吞吐量和消息堆积能力等问题的考虑,在生产环境上一般都会考虑使用RabbitMQ的集群方案。 对于RabbitMQ这么成熟的消息队列产品来说,搭建它并不难并且也有不少童鞋写过如何搭建RabbitMQ消息队列集群的博文,但可能仍然有童鞋并不了解其背后的原理,这会导致其遇到性能问题时无法对集群进行进一步的调优。本篇主要介绍RabbitMQ集群方案的原理,如何搭建具备负载均衡能力的中小规模RabbitMQ集群,并最后给出生产环境构建一个能够具备高可用、高可靠和高吞吐量的中小规模RabbitMQ集群设计方案。 一、RabbitMQ集群方案的原理 RabbitMQ这款消息队列中间件产品本身是基于Erlang编写,Erlang语言天生具备分布式特性(通过同步Erlang集群各节点的magic cookie来实现)。因此,RabbitMQ天然支持Clustering。这使得RabbitMQ本身不需要像ActiveMQ、Kafka那样通过ZooKeeper分别来实现HA方案和保存集群的元数据。集群是保证可靠性的一种方式

适合C# Actor的消息执行方式(1):Erlang中的模式匹配

ε祈祈猫儿з 提交于 2019-12-06 12:19:15
前言 Actor模型 为并行而生。由于现在单台机器中独立的计算单元也越来越多,Actor模型的重要性也越来越大。Actor模型的理念非常简单:天下万物皆为Actor,Actor之间通过发送消息进行通信。不同的Actor可以同时处理各自的消息,从而获得了大规模的并发能力。 Erlang基于Actor模型实现,我们甚至可以这样认为,没有Erlang在业界竖立的丰碑,Actor模型便不会如此受人关注。目前,几乎所有的主流开发平台上都有了Actor模型的实现,如Java平台下的 Jetlang 以及.NET平台下的 MS CCR 和 Retlang ;还有一些Actor框架专为特定语言设计,如 F#的MailboxProcessor 以及 Scala的Actor类库 ;甚至微软还基于MS CCR构建了一门新的语言 Axum 。 不过对于.NET平台下的开发人员来说,我们最常用的语言是C#。无论您是在使用MS CCR还是Retlang(亦或是我写的 ActorLite ),在消息的执行阶段总是略显尴尬。本文的目的便是提出一种适合C# Actor的消息执行方式,而这种执行方式还会成为我以后公开的C#中“模式匹配”的基础。 Erlang中的执行方式 本文将分为三个部分,您目前正在阅读的第一部分,将会观察Erlang是如何执行消息的。有对比才会有差距

Erlang and Redis: read performance

◇◆丶佛笑我妖孽 提交于 2019-12-06 12:01:05
I suddenly encountered performance problems when trying to read 1M records from Redis sorted set. I used ZSCAN with cursor and batch size 5K. Code was executed using Erlang R14 on the same machine that hosts Redis. Receiving of 5K elements batch takes near 1 second. Unfortunately, I failed to compile Erlang R16 on this machine, but I think it does not matter. For comparison, Node.js code with node_redis (hiredis parser) does 1M in 2 seconds. Same results for Python and PHP. Maybe I do something wrong? Thanks in advance. Here is my Erlang code: -module(redis_bench). -export([run/0]). -define

erlang zip:unzip/1 {error, bad_central_directory} and {error, bad_eocd}

非 Y 不嫁゛ 提交于 2019-12-06 11:53:37
I have always used erlang stdlib library zip:unzip/1 successfully. Last night i hit a bar with this error: E:\WimaxStatsParser-1.1>erl Eshell V5.9.2 (abort with ^G) 1> zip:unzip("e:/WimaxStatsParser-1.1/in/SomeZipFile.zip"). {error,bad_central_directory} 2> Some one help explain the cause for this ? and how i get around it ? ADDITIONS I got some other error on another file: {error,bad_eocd} . Please explain this as well. I am not able to reproduce your problem with the information you give. There are 2 functions that may send this error: get_cd_loop/5 and get_name_extra_comment/4 in stdlib-1

How to catch Exception Message in Erlang?

我的未来我决定 提交于 2019-12-06 11:46:17
This is the Exception message thrown by Gen_server when its not started. (ankit@127.0.0.1)32> R11 = system_warning:self_test("SysWarn"). ** exception exit: {noproc, {gen_server,call, [system_warning_sup, {start_child, {system_warning_SysWarn, {system_warning,start_link,[{system_warning_SysWarn}]}, permanent,10,worker, [system_warning]}}, infinity]}} in function gen_server:call/3 in call from system_warning_sup:'-start_child/1-lc$^0/1-0-'/1 in call from system_warning:self_test/1 (ankit@127.0.0.1)33> R11. * 1: variable 'R11' is unbound Now, What I want to do is to catch this exception message &

trouble when using anonymous functions inside erlang modules

不打扰是莪最后的温柔 提交于 2019-12-06 11:32:21
i was working with anonymous functionss in erlang when a problem caught my attention. the function is defined as follows -module(qt). -export([ra/0]). ra = fun() -> 4 end. this however does not work -export(Ra/0]). Ra = fun() -> 4 end. and neither does this can anyone tell me why erlang exhibits this behaviour ? An Erlang module cannot export variables, only functions. You can achieve something similar to exporting variables by exporting a function with zero arguments that simply returns a value (an anonymous function is a valid return value): -module(qt). -export([ra/0]). ra() -> fun() -> 4

Riak database fails after a short period

狂风中的少年 提交于 2019-12-06 11:24:04
I crerated a simple erlang application which periodically collects required data and puts it in a riak database. As I start my application it runs smoothly.. but after a period of time it stucks as PUT requests to riak database becomes too slow.. It is logs from my app: 2013-06-26 12:44:09.090 [info] <0.60.0> data processed in [16476 ms] 2013-06-26 12:45:51.472 [info] <0.60.0> data processed in [18793 ms] ... 2013-06-26 12:57:28.138 [info] <0.60.0> data processed in [15135 ms] 2013-06-26 13:07:01.484 [info] <0.60.0> data processed in [488420 ms] 2013-06-26 14:03:11.561 [info] <0.60.0> data