|
|
| Author |
Message |
< Erlang ~ Setting -sname improves performance |
| Roman2K |
Posted: Fri Aug 10, 2007 4:30 pm |
|
|
|
Joined: 10 Aug 2007
Posts: 3
|
Hello. I'm new to Erlang and am experimenting various things to practice and learn.
Lately, I have written a simple "passthrough" TCP proxy which accepts connections on a certain port, establishes a connection with another host (its network address is hard-wired -- © Joe Armstrong -- in the code) and serves as a man in the middle to transfer data to and from the client and the host. Each session causes 2 processes to be spawned, one for the client->host (inbound) flow, the other one for the host->client (outbound) flow. The work is not distributed among remote hosts, it's all done on a single machine.
While benchmarking this proxy application using `ab', I noticed that simply specifying the `-sname foo' command line argument to `erl' before running the proxy improves its performance by around 25% (from ~1350 req/s to ~1700 req/s).
Both the proxy and `ab' were running on a dual core processor but the `-smp +S 2' arguments were not specified.
I am happy with the performance gain but it is quite surprising. Is there an explanation for such results? |
|
|
| Back to top |
|
| francesco |
Posted: Mon Aug 13, 2007 9:28 am |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
No, there is no explanation as far as I can see or am aware of. All the -sname does is to start a separate process (epmd) which handles the setup of the socket communication among the nodes. In the Erlang VM, the only difference is the traffic to distributed nodes is redirected to (and received by) servers explicitly dealing with the distributed side of things (security, forwarding, monitoring, etc). So if your system is not written to take advantage of a distributed environment, I have no idea what could have caused the performance increase.
On another related issue.. Testing with SMP (Very non empirical ones), increases of about 40% were seen when running the node on a dual core machine. Adding a second node instead of running with SMP resulted in increases of about 100%.
In conclusion, I would run more tests and get more data, as your results are strange.
Regards,
Francesco |
|
|
| Back to top |
|
| Roman2K |
Posted: Mon Aug 13, 2007 4:57 pm |
|
|
|
Joined: 10 Aug 2007
Posts: 3
|
Thank you for having taken the time to reply, francesco. At the time of the benchmark, I did have a running node on a networked machine with the same cookie as the local node.
Quote: So if your system is not written to take advantage of a distributed environment, I have no idea what could have caused the performance increase.
If by taking advantage of a distributed environment you mean spawning as much processes as possible, then my system did that, so the Erlang VM of my local node must have transparently spread the work on the networked node as well, but only when the `-sname' argument was set.
If it's the case then Erlang is even nicer than I thought. I love this language . I guess we should thank Joe Armstrong for having brought it to the masses. |
|
|
| Back to top |
|
| francesco |
Posted: Mon Aug 13, 2007 6:06 pm |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
Quote: If by taking advantage of a distributed environment you mean spawning as much processes as possible, then my system did that, so the Erlang VM of my local node must have transparently spread the work on the networked node as well, but only when the `-sname' argument was set.
That is not how the language or the VM works... The VM will spawn processes only on the nodes you tell it to spawn them on. Anything else would leave a large level of indeterminism due to the network latency and overhead. So:Code: spawn_link(Node, M,F,A)
Will spawn a process on a remote node.
will spawn it locally. It is either one or the other, and not one if you are running distributed and the other if you are running locally. Usually, you have a load balancing layer on top to take care of distribution.
I would take more benchmarks. If you still see strange behaviors, post the source code here and let us have a look at it. Joe might be a great scientist, but as far as I know, last time I saw him, he was still working on performing miracles.. Not quite there yet
A similar post to yours you might want to take a look at is here: http://www.trapexit.org/forum/viewtopic.php?t=9170
Regards,
Francesco
--
http://www.erlang-consulting.com |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|