erlang

What is the difference between multicore programming in Erlang and other language?

别等时光非礼了梦想. 提交于 2019-12-09 04:04:02
问题 I read Joe Armstrong's 'Programming Erlang', and the 'n times faster in n core machine' theory. The efficient way to multicore programming in Erlang is to use lots of processes (threads). I'm a C++ programmer, so I am curious about the difference between making lots of threads in C++ and making lots of processes in Erlang. I understand dealing with threads in C/C++ is not that easy. Also I know locking/unlocking makes the system slow down. But it is not impossible , right? So.. why is Erlang

How to scale ejabberd Server machine on CentOS to handle 200 K connections?

六眼飞鱼酱① 提交于 2019-12-09 03:44:27
问题 I am working on a considerably good ejabberd instance with 40 core CPU machine and 160 GB RAM. The issue is I am unable to scale up to 200 K parallel connections. The sysctl config is as follows: net.ipv4.tcp_window_scaling = 1 net.core.rmem_max = 16777216 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 16384 16777216 #http://linux-ip.net/html/ether-arp.html#ether-arp-flux net.ipv4.conf.all.arp_filter = 1 kernel.exec-shield=1 kernel.randomize_va_space=1 net.ipv4.conf.all.rp

Dstributed Erlang, networking, echo server

给你一囗甜甜゛ 提交于 2019-12-09 01:28:27
so my year long project involves doing some pretty nasty stuff with Erlang. I am just starting to get to grips with it. I have very limited knowledge of networking and need to ask how/why something doesn't work. I followed the code from this guide, http://20bits.com/article/network-programming-in-erlang , that provides Erlang code for a server to echo back text that is fed into it The instructions to run it is to start the erlang code, he reccomends port 8888, and then telnet to the localhost and voila, access to the echo server My question is, would it be easy for me to run this server on my

Does Erlang always copy messages between processes on the same node?

不问归期 提交于 2019-12-08 23:47:07
问题 A faithful implementation of the actor message-passing semantics means that message contents are deep-copied from a logical point-of-view, even for immutable types. Deep-copying of message contents remains a bottleneck for implementations the actor model, so for performance some implementations support zero-copy message passing (although it's still deep-copy from the programmer's point-of-view). Is zero-copy message-passing implemented at all in Erlang? Between nodes it obviously can't be

Erlang ++ operator. Syntactic sugar, or separate operation?

岁酱吖の 提交于 2019-12-08 18:23:55
问题 Is Erlang's ++ operator simply syntactic sugar for lists:concat or is it a different operation altogether? I've tried searching this, but it's impossible to Google for "++" and get anything useful. 回答1: This is how the lists:concat/1 is implemented in the stdlib/lists module: concat(List) -> flatmap(fun thing_to_list/1, List). Where: flatmap(F, [Hd|Tail]) -> F(Hd) ++ flatmap(F, Tail); flatmap(F, []) when is_function(F, 1) -> []. and: thing_to_list(X) when is_integer(X) -> integer_to_list(X);

Erlang and Big Numbers

牧云@^-^@ 提交于 2019-12-08 17:28:44
问题 I am trying to store pi to about 200 decimal places, erlang concats it to about 15 digits, how can I keep the original and have it used in further calculations? 1> P = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513 282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233

RabbitMQ学习(一):RabbitMQ的安装

空扰寡人 提交于 2019-12-08 17:19:31
一、安装软件准备 RabbitMq下载地址 Erlang下载地址 RabbitMq和Erlang版本关联地址 二、windows环境下的安装 安装Erlang 安装RabbitMQ 启动Rabbitmq 点击 输入命令:rabbitmq-plugins enable rabbitmq_management 在浏览器中输入地址查看: http://127.0.0.1:15672/ 使用默认账号登录:guest/ guest 三、Linux环境下的安装 软件准备 我当时在下载这个时候比较慢,提供一个下载好的百度网盘地址: https://pan.baidu.com/s/1ddk62WucGKs8ObKK8wpH7w 密码:ehk5 安装Erlang环境 #安装依赖 yum install -y gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel git tar -xvf otp_src_22.1.tar.gz mv otp_src_22.1 erlang cd erlang #首先是./configure,检查编译环境并配置安装路径 ./configure --prefix=/usr/local/erlang --without-javac

How to get try / catch to work in erlang

ε祈祈猫儿з 提交于 2019-12-08 17:00:15
问题 i'm pretty new to erlang and i'm trying to get a basic try / catch statement to work. I"m using webmachine to process some requests and all i really want to do is parse some JSON data and return it. In the event that the JSON data is invalid, I just want to return an error msg. Here is the code I have so far. (the JSON data is invalid) to_text(ReqData, Context) -> Body = "{\"firstName\": \"John\"\"lastName\": \"Smith\"}", try decode(Body) of _ -> {"Success! Json decoded!",ReqData,Context}

Variable length of function argument list in Erlang

纵饮孤独 提交于 2019-12-08 16:45:45
问题 Is it possible to define function with argument list of variable length? I know I can write just: function() -> function([]). function(X) when not is_list(X) -> function([X]); function(X) -> do_something_with_arguments(X). But I want to avoid this technique. 回答1: One way to do it is to pass all arguments in a list: function(ListOfParameters) and then you can iterate over the said ListOfParameters . This way, you can have your function declaration be able to accept any number of "parameters",

Can't start appmon in erlang R17 RC1

霸气de小男生 提交于 2019-12-08 16:37:14
问题 I have Erlang/OTP 17 [RELEASE CANDIDATE 1] installed and i can't start appmon. I have tried: appmon:start(). ** exception error: undefined function appmon:start/0 I also tried: l(appmon). And I get the following error: {error,nofile} How can I make appmon work ? 回答1: appmon looks to have been removed, in favour of the new observer application. See the note here. There seems to be precious little online documentation on why, but presumably the docs included in your erlang installation would at